diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-10-31 00:29:35 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-10-31 00:29:35 +0000 |
commit | 583aa8eb078090fd48c6d6db8ee69da5ad8811fb (patch) | |
tree | 64ff5e4aa73849f9377310cb985dd79e58028b63 /test/test-terrain.cpp | |
parent | Initial commit of findPoint on terrain (diff) | |
download | ilt-583aa8eb078090fd48c6d6db8ee69da5ad8811fb.tar.bz2 ilt-583aa8eb078090fd48c6d6db8ee69da5ad8811fb.tar.xz ilt-583aa8eb078090fd48c6d6db8ee69da5ad8811fb.zip |
Initial commit of walk/walkUtil terrain
Diffstat (limited to 'test/test-terrain.cpp')
-rw-r--r-- | test/test-terrain.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/test-terrain.cpp b/test/test-terrain.cpp index d062853..429207c 100644 --- a/test/test-terrain.cpp +++ b/test/test-terrain.cpp @@ -65,3 +65,44 @@ BOOST_DATA_TEST_CASE(findPointOnTerrain, { BOOST_CHECK_EQUAL(fh, fixedTerrtain.findPoint(p, TerrainMesh::FaceHandle(start)).idx()); } + +using WalkTerrainData = std::tuple<glm::vec2, glm::vec2, std::vector<int>>; + +BOOST_DATA_TEST_CASE(walkTerrain, + boost::unit_test::data::make<WalkTerrainData>({ + {{310002, 490003}, {310002, 490003}, {0}}, + {{310003, 490002}, {310003, 490002}, {1}}, + {{310002, 490003}, {310003, 490002}, {0, 1}}, + {{310003, 490002}, {310002, 490003}, {1, 0}}, + {{310002, 490003}, {310202, 490003}, {0, 1, 2, 3, 4, 5, 6, 7, 8}}, + {{310202, 490003}, {310002, 490003}, {8, 7, 6, 5, 4, 3, 2, 1, 0}}, + {{310002, 490003}, {310002, 490203}, {0, 399, 398, 797, 796, 1195, 1194, 1593, 1592}}, + }), + from, to, visits) +{ + std::vector<int> visited; + BOOST_CHECK_NO_THROW(fixedTerrtain.walk(from, to, [&visited](auto fh) { + visited.emplace_back(fh.idx()); + })); + BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); +} + +BOOST_DATA_TEST_CASE(walkTerrainUntil, + boost::unit_test::data::make<WalkTerrainData>({ + {{310002, 490003}, {310002, 490003}, {0}}, + {{310003, 490002}, {310003, 490002}, {1}}, + {{310002, 490003}, {310003, 490002}, {0, 1}}, + {{310003, 490002}, {310002, 490003}, {1, 0}}, + {{310002, 490003}, {310202, 490003}, {0, 1, 2, 3, 4}}, + {{310202, 490003}, {310002, 490003}, {8, 7, 6, 5, 4}}, + {{310002, 490003}, {310002, 490203}, {0, 399, 398, 797, 796}}, + }), + from, to, visits) +{ + std::vector<int> visited; + BOOST_CHECK_NO_THROW(fixedTerrtain.walkUntil(from, to, [&visited](auto fh) { + visited.emplace_back(fh.idx()); + return visited.size() >= 5; + })); + BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); +} |