summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-02-26 23:47:39 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-02-26 23:47:39 +0000
commitaa07f1bdd607a6dead9cdec59ff950f6e9a5c28c (patch)
treea54ddc944b7f9f93585e05bff17904bf996b26ac
parentAdd helper for loading fixtures for data tests from fixture JSON (diff)
downloadilt-aa07f1bdd607a6dead9cdec59ff950f6e9a5c28c.tar.bz2
ilt-aa07f1bdd607a6dead9cdec59ff950f6e9a5c28c.tar.xz
ilt-aa07f1bdd607a6dead9cdec59ff950f6e9a5c28c.zip
Load terrain deform fixture data from JSON
-rw-r--r--test/Jamfile.jam2
-rw-r--r--test/fixtures/geoData/deform/1.json73
-rw-r--r--test/test-geoData.cpp34
3 files changed, 79 insertions, 30 deletions
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 : <library>test ;
+run 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/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<GlobalPosition3D>, std::vector<std::pair<Ray<GlobalPosition3D>, const char *>>>;
+using DeformTerrainData = std::tuple<std::vector<GlobalPosition3D>,
+ std::vector<std::pair<std::pair<GlobalPosition3D, Direction3D>, std::string>>>;
-template<typename T>
-std::ostream &
-operator<<(std::ostream & s, const Ray<T> & ray)
-{
- return s << "Ray" << std::make_pair(ray.start, ray.direction);
-}
-
-BOOST_DATA_TEST_CASE(setTriangle,
- boost::unit_test::data::make<DeformTerrainData>({
- {{
- {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<DeformTerrainData>("geoData/deform/1.json"), points, cams)
{
auto gd = std::make_shared<GeoData>(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());
});
}