summaryrefslogtreecommitdiff
path: root/test/test-lib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-lib.cpp')
-rw-r--r--test/test-lib.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/test/test-lib.cpp b/test/test-lib.cpp
index 5f0b5e5..17c0f63 100644
--- a/test/test-lib.cpp
+++ b/test/test-lib.cpp
@@ -3,6 +3,7 @@
#include "testHelpers.h"
#include <boost/test/data/test_case.hpp>
#include <boost/test/unit_test.hpp>
+#include <stream_support.h>
#include <collections.h>
#include <glArrays.h>
@@ -66,6 +67,46 @@ BOOST_AUTO_TEST_CASE(triangle_strip_iter)
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());
+ BOOST_CHECK_EQUAL_COLCOL(out, TRIANGLE_STRIP_EXPECTED);
+}
+
+BOOST_AUTO_TEST_CASE(triangle_strip_range_adapter)
+{
+ using TriTuple = std::tuple<int, int, int>;
+ std::vector<TriTuple> outRange;
+ std::ranges::copy(TRIANGLE_STRIP_IN | triangleTriples, std::back_inserter(outRange));
+ constexpr std::array<TriTuple, 4> TRIANGLE_STRIP_EXPECTED_TUPLES {{{0, 1, 2}, {2, 1, 3}, {2, 3, 4}, {4, 3, 5}}};
+ BOOST_CHECK_EQUAL_COLCOL(outRange, TRIANGLE_STRIP_EXPECTED_TUPLES);
+}
+
+using MergeCloseData = std::tuple<std::vector<int>, int, std::vector<int>>;
+
+BOOST_DATA_TEST_CASE(mergeCloseInts,
+ boost::unit_test::data::make<MergeCloseData>({
+ {{0}, 0, {0}},
+ {{0, 1}, 0, {0, 1}},
+ {{0, 1}, 2, {0, 1}},
+ {{0, 1, 2}, 2, {0, 2}},
+ {{0, 1, 4}, 2, {0, 4}},
+ {{0, 1, 2}, 4, {0, 2}},
+ {{0, 4, 8}, 4, {0, 8}},
+ {{0, 4, 10, 14}, 4, {0, 14}},
+ {{0, 3, 6}, 2, {0, 3, 6}},
+ {{0, 3, 4}, 2, {0, 4}},
+ {{0, 5, 7, 12}, 4, {0, 6, 12}},
+ {{0, 3, 4, 5, 10, 17, 18, 19}, 2, {0, 4, 10, 19}},
+ }),
+ collection, tolerance, expected)
+{
+ auto mutableCollection {collection};
+ BOOST_REQUIRE_NO_THROW((mergeClose(
+ mutableCollection,
+ [](int left, int right) {
+ return std::abs(left - right);
+ },
+ [](int left, int right) {
+ return (left + right) / 2;
+ },
+ tolerance)));
+ BOOST_CHECK_EQUAL_COLCOL(mutableCollection, expected);
}