summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Jamfile.jam4
-rw-r--r--test/perf-terrain.cpp18
-rw-r--r--test/test-terrain.cpp19
3 files changed, 40 insertions, 1 deletions
diff --git a/test/Jamfile.jam b/test/Jamfile.jam
index eab3996..7fa7bfc 100644
--- a/test/Jamfile.jam
+++ b/test/Jamfile.jam
@@ -61,9 +61,11 @@ run test-instancing.cpp : : : <library>test ;
run test-glContainer.cpp : : : <library>test ;
run test-pack.cpp : : : <library>test ;
run test-terrain.cpp : : : <library>test <library>..//OpenMeshCore ;
+run perf-terrain.cpp : : : <library>test <library>..//OpenMeshCore <library>benchmark ;
compile test-static-enumDetails.cpp ;
compile test-static-stream_support.cpp ;
explicit perf-assetFactory ;
explicit perf-persistence ;
-alias perf : perf-assetFactory perf-persistence ;
+explicit perf-terrain ;
+alias perf : perf-assetFactory perf-persistence perf-terrain ;
explicit perf ;
diff --git a/test/perf-terrain.cpp b/test/perf-terrain.cpp
new file mode 100644
index 0000000..e998f60
--- /dev/null
+++ b/test/perf-terrain.cpp
@@ -0,0 +1,18 @@
+#include <benchmark/benchmark.h>
+#include <game/terrain2.h>
+
+namespace {
+ const TerrainMesh tm {FIXTURESDIR "height/SD19.asc"};
+
+ void
+ terrain_findPoint(benchmark::State & state)
+ {
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(tm.findPoint({315555, 495556}));
+ }
+ }
+}
+
+BENCHMARK(terrain_findPoint);
+
+BENCHMARK_MAIN();
diff --git a/test/test-terrain.cpp b/test/test-terrain.cpp
index b2358d6..d062853 100644
--- a/test/test-terrain.cpp
+++ b/test/test-terrain.cpp
@@ -1,4 +1,5 @@
#define BOOST_TEST_MODULE terrain
+#include <boost/test/data/test_case.hpp>
#include <boost/test/unit_test.hpp>
#include <stream_support.h>
@@ -46,3 +47,21 @@ BOOST_AUTO_TEST_CASE(trianglesContainsPoints)
}
BOOST_AUTO_TEST_SUITE_END();
+
+using FindPointData = std::tuple<glm::vec2, int>;
+
+static const TestTerrainMesh fixedTerrtain;
+
+// No boundary cases as these can produce different valid results depending on starting point
+BOOST_DATA_TEST_CASE(findPointOnTerrain,
+ boost::unit_test::data::make<FindPointData>({
+ {{0, 0}, -1}, {{xllcorner, 0}, -1}, {{0, yllcorner}, -1}, {{xllcorner + 1, yllcorner + 2}, 0},
+ {{xllcorner + (cellsize * (nrows - 1)) - 2, yllcorner + (cellsize * (ncols - 1)) - 1}, 79200},
+ {{315555, 495556}, 44400}, // perf test target
+ })
+ * boost::unit_test::data::make<int>(
+ {0, 1, 2, 3, 4, 5, 6, 10, 100, 150, 200, 1000, 1234, 17439, 79201, 79200, 79199}),
+ p, fh, start)
+{
+ BOOST_CHECK_EQUAL(fh, fixedTerrtain.findPoint(p, TerrainMesh::FaceHandle(start)).idx());
+}