TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
18 / 18
100.0%
Branches:
13 / 13
100.0%
Functions:
5 / 5
100.0%

util/checks.cpp
Line Branch Exec Source
1 #include "terraingen/util/checks.h"
2
3 #include <stdexcept>
4 #include <string>
5
6 namespace terraingen {
7
8 namespace {
9
10 164 [[noreturn]] void Fail(std::string_view what, std::string_view requirement) {
11
5/5
✓ Branch 2 taken 164 times.
✓ Branch 5 taken 164 times.
✓ Branch 8 taken 164 times.
✓ Branch 11 taken 164 times.
✓ Branch 14 taken 164 times.
820 throw std::invalid_argument(std::string(what) + " must be " + std::string(requirement));
12 }
13
14 } // namespace
15
16 55888935 void RequirePositive(double value, std::string_view what) {
17
2/2
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 55888813 times.
55888935 if (!IsPositive(value)) {
18 122 Fail(what, "positive and finite");
19 }
20 55888813 }
21
22 7363069 void RequireNonNegative(double value, std::string_view what) {
23
2/2
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 7363041 times.
7363069 if (!IsNonNegative(value)) {
24 28 Fail(what, "finite and not negative");
25 }
26 7363041 }
27
28 103414 void RequireFinite(double value, std::string_view what) {
29
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 103411 times.
103414 if (!std::isfinite(value)) {
30 3 Fail(what, "finite");
31 }
32 103411 }
33
34 1010903 void RequireUnitInterval(double value, std::string_view what) {
35
2/2
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1010892 times.
1010903 if (!IsInUnitInterval(value)) {
36 11 Fail(what, "in [0, 1]");
37 }
38 1010892 }
39
40 } // namespace terraingen
41