TerrainGen coverage


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

layers/detail.cpp
Line Branch Exec Source
1 #include "terraingen/layers/detail.h"
2
3 #include <cmath>
4 #include <stdexcept>
5 #include <utility>
6
7 namespace terraingen {
8
9 6 DetailLayer::DetailLayer(std::shared_ptr<const Source> full, std::shared_ptr<const Source> smooth,
10 6 double weight, Surface surface)
11 6 : FormulaLayer(surface), full_(std::move(full)), smooth_(std::move(smooth)), weight_(weight) {
12
5/6
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 5 times.
6 if (!full_ || !smooth_) {
13
1/1
✓ Branch 2 taken 1 time.
1 throw std::invalid_argument("A detail layer needs both sources");
14 }
15
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 4 times.
5 if (!std::isfinite(weight_)) {
16
1/1
✓ Branch 2 taken 1 time.
1 throw std::invalid_argument("Detail weight must be finite");
17 }
18 10 }
19
20 2291 float DetailLayer::HeightAt(float height, double x, double y, double /*spacing*/,
21 const Ground* /*ground*/) const {
22 2291 const float full = full_->HeightAt(x, y);
23 2291 const float smooth = smooth_->HeightAt(x, y);
24
5/6
✓ Branch 1 taken 2291 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 2290 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 2290 times.
2291 if (std::isnan(full) || std::isnan(smooth)) {
25 1 return height;
26 }
27 2290 return static_cast<float>(static_cast<double>(height) +
28 2290 weight_ * (static_cast<double>(full) - static_cast<double>(smooth)));
29 }
30
31 } // namespace terraingen
32