TerrainGen coverage


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

distribution/combined.h
Line Branch Exec Source
1 /// @file
2 /// @brief Checks and lookups shared by the distributions built from others or from pieces.
3 #pragma once
4
5 #include "terraingen/distribution/size_frequency.h"
6
7 #include <cstddef>
8 #include <span>
9 #include <string>
10 #include <vector>
11
12 namespace terraingen::detail {
13
14 /// The kind every one of `distributions` has.
15 /// @param what The combination, for messages, such as "A minimum".
16 /// @throws std::invalid_argument for no inputs, a null input or mixed kinds.
17 SfdKind CommonKind(std::span<const SizeFrequencyDistribution* const> distributions,
18 const std::string& what);
19
20 /// Where `distribution` may be evaluated, in metres: everywhere when it allows extrapolation,
21 /// otherwise its valid range.
22 DiameterRange UsableRange(const SizeFrequencyDistribution& distribution);
23
24 /// Checks the join at `start` (metres) of a piece giving N = `above` after one giving `below`.
25 /// @param tolerance The relative mismatch allowed.
26 /// @param allowDiscontinuities Whether a larger downward jump is allowed.
27 /// @throws std::invalid_argument for a rise, or a drop beyond `tolerance` unless allowed.
28 void CheckJoin(double below, double above, double start, double tolerance,
29 bool allowDiscontinuities);
30
31 /// The index of the piece that applies at `diameter` (metres): the last whose `start` is below it,
32 /// so the lower piece applies at a join.
33 /// @param pieces Pieces with increasing `start`.
34 template <typename Piece>
35 8252618 std::size_t IndexOfStart(const std::vector<Piece>& pieces, double diameter) {
36 8252618 std::size_t index = 0;
37
12/12
unsigned long terraingen::detail::IndexOfStart<terraingen::PowerLawSegment>(std::vector<terraingen::PowerLawSegment, std::allocator<terraingen::PowerLawSegment> > const&, double):
✓ Branch 1 taken 551117 times.
✓ Branch 2 taken 123237 times.
✓ Branch 4 taken 285587 times.
✓ Branch 5 taken 265530 times.
✓ Branch 6 taken 285587 times.
✓ Branch 7 taken 388767 times.
unsigned long terraingen::detail::IndexOfStart<terraingen::SfdPiece>(std::vector<terraingen::SfdPiece, std::allocator<terraingen::SfdPiece> > const&, double):
✓ Branch 1 taken 7863851 times.
✓ Branch 2 taken 5906074 times.
✓ Branch 4 taken 5906074 times.
✓ Branch 5 taken 1957777 times.
✓ Branch 6 taken 5906074 times.
✓ Branch 7 taken 7863851 times.
14444279 while (index + 1 < pieces.size() && pieces[index + 1].start < diameter) {
38 6191661 ++index;
39 }
40 8252618 return index;
41 }
42
43 } // namespace terraingen::detail
44