summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Jamfile.jam2
-rw-r--r--test/test-geoData-counts.cpp64
2 files changed, 65 insertions, 1 deletions
diff --git a/test/Jamfile.jam b/test/Jamfile.jam
index 3ab4c4c..c5c49d2 100644
--- a/test/Jamfile.jam
+++ b/test/Jamfile.jam
@@ -47,7 +47,7 @@ lib test : [ glob *.cpp : test-*.cpp perf-*.cpp ] ;
run test-collection.cpp ;
run test-maths.cpp ;
run test-lib.cpp ;
-run test-geoData.cpp : -- : [ sequence.insertion-sort [ glob-tree $(fixtures)/geoData : *.json ] fixtures/height/SD19.asc ] : <library>test ;
+run [ glob test-geoData*.cpp ] : -- : [ sequence.insertion-sort [ glob-tree $(fixtures)/geoData : *.json ] fixtures/height/SD19.asc ] : <library>test ;
run test-network.cpp : : : <library>test ;
run test-persistence.cpp : -- : [ sequence.insertion-sort [ glob-tree $(fixtures)/json : *.json ] ] : <library>test ;
run test-text.cpp : -- : test-glContainer : <library>test ;
diff --git a/test/test-geoData-counts.cpp b/test/test-geoData-counts.cpp
new file mode 100644
index 0000000..cad078d
--- /dev/null
+++ b/test/test-geoData-counts.cpp
@@ -0,0 +1,64 @@
+#include <OpenMesh/Core/IO/MeshIO.hh>
+#include <boost/test/data/test_case.hpp>
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test_suite.hpp>
+
+#include "game/geoData.h"
+
+using GeoMutation = std::function<void(GeoData &)>;
+using Something = std::tuple<const char *, GeoMutation, size_t, size_t, size_t>;
+BOOST_TEST_DONT_PRINT_LOG_VALUE(GeoMutation);
+
+BOOST_DATA_TEST_CASE(deformLogical,
+ boost::unit_test::data::make<Something>({
+ {"nochange", [](GeoData &) {}, 16, 33, 18}, // No change base case
+ {"simple",
+ [](GeoData & geoData) {
+ Surface surface;
+ // Basic triangle, no crossing, simple case
+ geoData.setHeights(std::array<GlobalPosition3D, 3> {{
+ {2000, 8000, 1000},
+ {2000, 4000, 1000},
+ {6000, 8000, 1000},
+ }},
+ {.surface = &surface, .nearNodeTolerance = 0});
+ },
+ 19, 42, 24},
+ {"simple-cross",
+ [](GeoData & geoData) {
+ Surface surface;
+ // Basic triangle, with crossing, reasonably simple case
+ geoData.setHeights(std::array<GlobalPosition3D, 3> {{
+ {2000, 8000, 1000},
+ {3000, 4000, 1000},
+ {4000, 9000, 1000},
+ }},
+ {.surface = &surface, .nearNodeTolerance = 0});
+ },
+ 19, 42, 24},
+ {"quad-multi-cross",
+ [](GeoData & geoData) {
+ Surface surface;
+ // Basic quad, with crossing, spans into adjacent original triangle, should remove that edge
+ geoData.setHeights(std::array<GlobalPosition3D, 4> {{
+ {2000, 8000, 1000},
+ {3000, 4000, 1000},
+ {4000, 9000, 1000},
+ {8000, 2000, 1000},
+ }},
+ {.surface = &surface, .nearNodeTolerance = 0});
+ },
+ 20, 45, 26},
+ }),
+ name, func, expVertices, expEdges, expFaces)
+{
+ auto geoData = GeoData::createFlat({0, 0}, {30'000, 30'000}, 1000);
+
+ BOOST_REQUIRE_NO_THROW(func(geoData));
+ OpenMesh::IO::write_mesh(geoData, std::format("/tmp/mesh-{}.obj", name));
+
+ BOOST_CHECK_EQUAL(geoData.n_vertices(), expVertices);
+ BOOST_CHECK_EQUAL(geoData.n_edges(), expEdges);
+ BOOST_CHECK_EQUAL(geoData.n_faces(), expFaces);
+ BOOST_CHECK_NO_THROW(geoData.sanityCheck());
+}