TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
17 / 17
100.0%
Branches:
14 / 14
100.0%
Functions:
4 / 4
100.0%

distribution/production_surface.cpp
Line Branch Exec Source
1 #include "terraingen/distribution/production_surface.h"
2
3 #include <stdexcept>
4 #include <utility>
5
6 namespace terraingen {
7
8 467 ProductionSurface::ProductionSurface(std::shared_ptr<const SizeFrequencyDistribution> production,
9 467 double ageGyr, const Chronology& chronology)
10 : SizeFrequencyDistribution(SfdKind::Density,
11 466 production ? production->ValidRange() : DiameterRange{}),
12
2/2
✓ Branch 1 taken 466 times.
✓ Branch 2 taken 1 time.
933 production_(std::move(production)), ageGyr_(ageGyr) {
13
6/6
✓ Branch 1 taken 466 times.
✓ Branch 2 taken 1 time.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 464 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 464 times.
467 if (!production_ || production_->Kind() != SfdKind::ProductionRate) {
14
1/1
✓ Branch 2 taken 3 times.
3 throw std::invalid_argument("A production surface needs a production rate distribution");
15 }
16
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 462 times.
464 if (!chronology) {
17
1/1
✓ Branch 2 taken 2 times.
2 throw std::invalid_argument("A production surface needs a chronology");
18 }
19 462 SetAllowExtrapolation(production_->AllowsExtrapolation());
20
2/2
✓ Branch 1 taken 458 times.
✓ Branch 5 taken 457 times.
462 scale_ = chronology(ageGyr_) / production_->Cumulative(1000.0);
21 477 }
22
23 7043468 double ProductionSurface::CumulativeAt(double diameter) const {
24 7043468 return scale_ * CumulativeOf(*production_, diameter);
25 }
26
27 6 double ProductionSurface::IncrementalAt(double diameter) const {
28 6 return scale_ * IncrementalOf(*production_, diameter);
29 }
30
31 105766 double ProductionSurface::InvertCumulative(double target, double dMin, double dMax) const {
32 105766 return InvertCumulativeOf(*production_, target / scale_, dMin, dMax);
33 }
34
35 } // namespace terraingen
36