diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-04-04 20:06:36 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-04-04 20:06:36 +0100 |
commit | 30b027f84772d4b1d18eebd03b83ce3a5966d5fe (patch) | |
tree | bf1f424ee3c92516d652934cf502ee06f60c57e5 /test/test-lib.cpp | |
parent | Simplify vector addition/subtraction with differnt types (diff) | |
parent | Remove wireframe mode from test renders (diff) | |
download | ilt-30b027f84772d4b1d18eebd03b83ce3a5966d5fe.tar.bz2 ilt-30b027f84772d4b1d18eebd03b83ce3a5966d5fe.tar.xz ilt-30b027f84772d4b1d18eebd03b83ce3a5966d5fe.zip |
Merge remote-tracking branch 'origin/deform-terrain'
Two related issues remain:
* Terrain self shadowing is common and handled poorly
* Odd, but mathematically correct patterns/stripes in feature boundaries
Neither of these relate directly to deformation.
Diffstat (limited to 'test/test-lib.cpp')
-rw-r--r-- | test/test-lib.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test-lib.cpp b/test/test-lib.cpp index 58b769a..5f0b5e5 100644 --- a/test/test-lib.cpp +++ b/test/test-lib.cpp @@ -4,6 +4,7 @@ #include <boost/test/data/test_case.hpp> #include <boost/test/unit_test.hpp> +#include <collections.h> #include <glArrays.h> #include <glad/gl.h> #include <set> @@ -49,3 +50,22 @@ BOOST_AUTO_TEST_CASE(generate_move_and_delete) } BOOST_CHECK(active.empty()); } + +constexpr std::array TRIANGLE_STRIP_IN {0, 1, 2, 3, 4, 5}; +static_assert(std::distance(strip_begin(TRIANGLE_STRIP_IN), strip_end(TRIANGLE_STRIP_IN)) == 4); + +BOOST_AUTO_TEST_CASE(triangle_strip_iter) +{ + constexpr std::array TRIANGLE_STRIP_EXPECTED {0, 1, 2, 2, 1, 3, 2, 3, 4, 4, 3, 5}; + + std::vector<int> out; + std::for_each(strip_begin(TRIANGLE_STRIP_IN), strip_end(TRIANGLE_STRIP_IN), [&out](const auto & t) { + const auto [a, b, c] = t; + out.push_back(a); + out.push_back(b); + out.push_back(c); + }); + BOOST_REQUIRE_EQUAL(out.size(), (TRIANGLE_STRIP_IN.size() - 2) * 3); + BOOST_CHECK_EQUAL_COLLECTIONS( + out.begin(), out.end(), TRIANGLE_STRIP_EXPECTED.begin(), TRIANGLE_STRIP_EXPECTED.end()); +} |