From aa07f1bdd607a6dead9cdec59ff950f6e9a5c28c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 26 Feb 2024 23:47:39 +0000 Subject: Load terrain deform fixture data from JSON --- test/Jamfile.jam | 2 +- test/fixtures/geoData/deform/1.json | 73 +++++++++++++++++++++++++++++++++++++ test/test-geoData.cpp | 34 +++-------------- 3 files changed, 79 insertions(+), 30 deletions(-) create mode 100644 test/fixtures/geoData/deform/1.json (limited to 'test') diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 733ef05..1b07b5a 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -46,7 +46,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 : -- : fixtures/height/SD19.asc : test ; +run test-geoData.cpp : -- : [ sequence.insertion-sort [ glob-tree $(fixtures)/geoData : *.json ] fixtures/height/SD19.asc ] : test ; run test-network.cpp : : : test ; run test-persistence.cpp : -- : [ sequence.insertion-sort [ glob-tree $(fixtures)/json : *.json ] ] : test ; run test-text.cpp : -- : test-glContainer : test ; diff --git a/test/fixtures/geoData/deform/1.json b/test/fixtures/geoData/deform/1.json new file mode 100644 index 0000000..33ac86d --- /dev/null +++ b/test/fixtures/geoData/deform/1.json @@ -0,0 +1,73 @@ +[ + [ + [ + [ + 70100, + 123000, + 6000 + ], + [ + 50100, + 52300, + 6000 + ], + [ + 191000, + 283000, + 8000 + ], + [ + 241000, + 123330, + -2000 + ] + ], + [ + [ + [ + [ + 20000, + 20000, + 90000 + ], + [ + 1, + 1, + -1.5 + ] + ], + "/tmp/geoData0.tga" + ], + [ + [ + [ + 30000, + 164000, + 90000 + ], + [ + 1, + -1, + -1.5 + ] + ], + "/tmp/geoData1.tga" + ], + [ + [ + [ + 288000, + 162000, + 90000 + ], + [ + -1, + -1, + -1.5 + ] + ], + "/tmp/geoData2.tga" + ] + ] + ] +] diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index e1f8fce..36d008b 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -205,34 +205,10 @@ BOOST_DATA_TEST_CASE(findEntries, BOOST_CHECK_EQUAL(fixedTerrtain.findEntry(from, to).idx(), heh); } -using DeformTerrainData - = std::tuple, std::vector, const char *>>>; +using DeformTerrainData = std::tuple, + std::vector, std::string>>>; -template -std::ostream & -operator<<(std::ostream & s, const Ray & ray) -{ - return s << "Ray" << std::make_pair(ray.start, ray.direction); -} - -BOOST_DATA_TEST_CASE(setTriangle, - boost::unit_test::data::make({ - {{ - {70100, 123000, 6000}, - {50100, 52300, 6000}, - {191000, 283000, 8000}, - {241000, 123330, -2000}, - }, - { - {{{20000, 20000, 90000}, glm::normalize(Direction3D {1, 1, -1.5F})}, - "/tmp/geoData0.tga"}, - {{{30000, 164000, 90000}, glm::normalize(Direction3D {1, -1, -1.5F})}, - "/tmp/geoData1.tga"}, - {{{288000, 162000, 90000}, glm::normalize(Direction3D {-1, -1, -1.5F})}, - "/tmp/geoData2.tga"}, - }}, - }), - points, cams) +BOOST_DATA_TEST_CASE(deform, loadFixtureJson("geoData/deform/1.json"), points, cams) { auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); BOOST_CHECK_NO_THROW(gd->setHeights(points)); @@ -276,8 +252,8 @@ BOOST_DATA_TEST_CASE(setTriangle, TestTerrain t {gd}; SceneRenderer ss {tro.size, tro.output}; std::for_each(cams.begin(), cams.end(), [&ss, &t, &tro](const auto & cam) { - ss.camera.setView(cam.first.start, cam.first.direction); + ss.camera.setView(cam.first.first, glm::normalize(cam.first.second)); BOOST_CHECK_NO_THROW(ss.render(t)); - Texture::save(tro.outImage, cam.second); + Texture::save(tro.outImage, cam.second.c_str()); }); } -- cgit v1.2.3