From ece082232fd0020fd63b5cc4a5a33eb36e3a3d9a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 9 Feb 2025 12:44:20 +0000 Subject: Add tests which explicit count verts/edges/faces after terrain mesh modification --- test/test-geoData-counts.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 test/test-geoData-counts.cpp (limited to 'test/test-geoData-counts.cpp') 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 +#include +#include +#include + +#include "game/geoData.h" + +using GeoMutation = std::function; +using Something = std::tuple; +BOOST_TEST_DONT_PRINT_LOG_VALUE(GeoMutation); + +BOOST_DATA_TEST_CASE(deformLogical, + boost::unit_test::data::make({ + {"nochange", [](GeoData &) {}, 16, 33, 18}, // No change base case + {"simple", + [](GeoData & geoData) { + Surface surface; + // Basic triangle, no crossing, simple case + geoData.setHeights(std::array {{ + {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 {{ + {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 {{ + {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()); +} -- cgit v1.2.3 From ec29d7bb5e786549eaa960016ddf511fad010cc5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 9 Feb 2025 15:23:15 +0000 Subject: Split GeoData mesh basics into a subclass Declutters the class for terrain related things --- test/test-geoData-counts.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'test/test-geoData-counts.cpp') diff --git a/test/test-geoData-counts.cpp b/test/test-geoData-counts.cpp index cad078d..bb43fdb 100644 --- a/test/test-geoData-counts.cpp +++ b/test/test-geoData-counts.cpp @@ -60,5 +60,4 @@ BOOST_DATA_TEST_CASE(deformLogical, 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()); } -- cgit v1.2.3 From b73c73e8a925bd14fcb8954377939e127a0614d0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Feb 2025 23:55:04 +0000 Subject: Add timeouts to more geoData tests --- test/test-geoData-counts.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/test-geoData-counts.cpp') diff --git a/test/test-geoData-counts.cpp b/test/test-geoData-counts.cpp index bb43fdb..446a68a 100644 --- a/test/test-geoData-counts.cpp +++ b/test/test-geoData-counts.cpp @@ -9,6 +9,8 @@ using GeoMutation = std::function; using Something = std::tuple; BOOST_TEST_DONT_PRINT_LOG_VALUE(GeoMutation); +BOOST_TEST_DECORATOR(*boost::unit_test::timeout(2)); + BOOST_DATA_TEST_CASE(deformLogical, boost::unit_test::data::make({ {"nochange", [](GeoData &) {}, 16, 33, 18}, // No change base case -- cgit v1.2.3