diff options
Diffstat (limited to 'geom_bottleneck/tests/test_hera_bottleneck.cpp')
-rw-r--r-- | geom_bottleneck/tests/test_hera_bottleneck.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/geom_bottleneck/tests/test_hera_bottleneck.cpp b/geom_bottleneck/tests/test_hera_bottleneck.cpp index 922a4b0..f22e415 100644 --- a/geom_bottleneck/tests/test_hera_bottleneck.cpp +++ b/geom_bottleneck/tests/test_hera_bottleneck.cpp @@ -6,6 +6,7 @@ #include "bottleneck.h" using PairVector = std::vector<std::pair<double, double>>; +using PairVectorF = std::vector<std::pair<float, float>>; std::vector<std::string> split_on_delim(const std::string& s, char delim) { @@ -113,6 +114,33 @@ TEST_CASE("simple cases", "bottleneckDistApprox") } +TEST_CASE("float version", "check_template") +{ + PairVectorF diagram_A, diagram_B; + float delta = 0.01; + //float internal_p = hera::get_infinity<double>(); + + SECTION("trivial: two empty diagrams") { + REQUIRE( 0.0 == hera::bottleneckDistApprox<PairVectorF>(diagram_A, diagram_B, delta)); + REQUIRE( 0.0 == hera::bottleneckDistExact<PairVectorF>(diagram_A, diagram_B)); + } + + SECTION("trivial: two single-point diagrams-2") { + + diagram_A.emplace_back(10, 20); // (5, 5) + diagram_B.emplace_back(130, 138); // (4, 4) + + float d1 = hera::bottleneckDistApprox<PairVectorF>(diagram_A, diagram_B, delta); + float d2 = hera::bottleneckDistApprox<PairVectorF>(diagram_B, diagram_A, delta); + float d3 = hera::bottleneckDistExact<PairVectorF>(diagram_B, diagram_A); + float correct_answer = 5; + REQUIRE( fabs(d1 - correct_answer) <= delta * correct_answer ); + REQUIRE( fabs(d2 - correct_answer) <= delta * correct_answer ); + + } + +} + TEST_CASE("infinity points", "bottleneckDistApprox") { |