From 04078dbb3fe4acd09d150e016c2b2e0d5d036950 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 5 Nov 2023 13:07:32 +0000 Subject: Add methods to walk the boundary of the terrain mesh --- test/perf-geoData.cpp | 11 +++++++++++ test/test-geoData.cpp | 10 ++++++++++ 2 files changed, 21 insertions(+) (limited to 'test') diff --git a/test/perf-geoData.cpp b/test/perf-geoData.cpp index 2d79a90..4fed632 100644 --- a/test/perf-geoData.cpp +++ b/test/perf-geoData.cpp @@ -23,9 +23,20 @@ namespace { }); } } + + void + terrain_walkBoundary(benchmark::State & state) + { + for (auto _ : state) { + tm.boundaryWalk([](auto heh) { + benchmark::DoNotOptimize(heh); + }); + } + } } BENCHMARK(terrain_findPoint); BENCHMARK(terrain_walk); +BENCHMARK(terrain_walkBoundary); BENCHMARK_MAIN(); diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 258bd9c..34c9cb6 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -118,6 +118,16 @@ BOOST_DATA_TEST_CASE(findRayIntersect, BOOST_CHECK_CLOSE_VEC(fixedTerrtain.intersectRay({p, d}).value(), i); } +BOOST_AUTO_TEST_CASE(boundaryWalk) +{ + size_t count {}; + fixedTerrtain.boundaryWalk([&count](auto heh) { + BOOST_CHECK(fixedTerrtain.is_boundary(heh)); + count++; + }); + BOOST_CHECK_EQUAL(count, 2 * (ncols + nrows - 2)); +} + using WalkTerrainData = std::tuple>; BOOST_DATA_TEST_CASE(walkTerrain, -- cgit v1.2.3