TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
9 / 9
100.0%
Branches:
16 / 16
100.0%
Functions:
2 / 2
100.0%

albedo/maturity.cpp
Line Branch Exec Source
1 #include "terraingen/albedo/maturity.h"
2
3 #include "terraingen/util/checks.h"
4
5 #include <cmath>
6 #include <stdexcept>
7
8 namespace terraingen {
9
10 6 double OpticalMaturity(double r750, double r950, const OpticalMaturityOrigin& origin) {
11
6/6
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 4 times.
6 if (!(IsPositive(r750) && std::isfinite(r950))) {
12
1/1
✓ Branch 2 taken 2 times.
2 throw std::invalid_argument("Optical maturity needs a positive 750 nm reflectance");
13 }
14 4 return std::hypot(r750 - origin.reflectance, r950 / r750 - origin.ratio);
15 }
16
17 1025803 double ReflectanceAtMaturity(double reflectance, double reference, double maturity,
18 double originReflectance) {
19
8/8
✓ Branch 1 taken 1025802 times.
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 1025801 times.
✓ Branch 5 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 1025800 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 1025800 times.
1025803 if (!(IsPositive(reference) && IsNonNegative(maturity) && std::isfinite(originReflectance))) {
20 throw std::invalid_argument(
21
1/1
✓ Branch 2 taken 3 times.
3 "Reflectance at a maturity needs a positive reference and a non-negative maturity");
22 }
23 1025800 const double origin = std::fmin(originReflectance, reflectance);
24 1025800 return origin + (reflectance - origin) * maturity / reference;
25 }
26
27 } // namespace terraingen
28