summaryrefslogtreecommitdiff
path: root/test/test-pack.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-05-01 18:14:49 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-05-01 18:14:49 +0100
commita6457aea04d1705f5b03f9c9e628bebbefdcf64c (patch)
tree8c944e698d8e1691561186ea18b9024e65225739 /test/test-pack.cpp
parentAdd method to get GL buffer name of glContainer (diff)
downloadilt-a6457aea04d1705f5b03f9c9e628bebbefdcf64c.tar.bz2
ilt-a6457aea04d1705f5b03f9c9e628bebbefdcf64c.tar.xz
ilt-a6457aea04d1705f5b03f9c9e628bebbefdcf64c.zip
Add the pack container
Keeps its elements densely packed together without any interest in order
Diffstat (limited to 'test/test-pack.cpp')
-rw-r--r--test/test-pack.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/test-pack.cpp b/test/test-pack.cpp
new file mode 100644
index 0000000..1f9f061
--- /dev/null
+++ b/test/test-pack.cpp
@@ -0,0 +1,41 @@
+#define BOOST_TEST_MODULE pack
+
+#include <boost/test/data/test_case.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include "pack.h"
+#include <vector>
+
+using IntegerVectorPack = pack<int, std::vector>;
+
+BOOST_FIXTURE_TEST_SUITE(pint, IntegerVectorPack)
+
+BOOST_AUTO_TEST_CASE(basics)
+{
+ BOOST_CHECK_EQUAL(size(), 0);
+ BOOST_CHECK_NO_THROW(emplace(1));
+ BOOST_CHECK_NO_THROW(emplace(2));
+ BOOST_CHECK_NO_THROW(emplace(3));
+ BOOST_CHECK_NO_THROW(emplace(4));
+ BOOST_CHECK_EQUAL(size(), 4);
+ {
+ std::array expected1 {1, 2, 3, 4};
+ BOOST_CHECK_EQUAL_COLLECTIONS(begin(), end(), expected1.begin(), expected1.end());
+ }
+
+ BOOST_CHECK_NO_THROW(erase(begin() + 1));
+ BOOST_CHECK_EQUAL(size(), 3);
+ {
+ std::array expected1 {1, 4, 3};
+ BOOST_CHECK_EQUAL_COLLECTIONS(begin(), end(), expected1.begin(), expected1.end());
+ }
+
+ BOOST_CHECK_NO_THROW(erase(--end()));
+ BOOST_CHECK_EQUAL(size(), 2);
+ {
+ std::array expected1 {1, 4};
+ BOOST_CHECK_EQUAL_COLLECTIONS(begin(), end(), expected1.begin(), expected1.end());
+ }
+}
+
+BOOST_AUTO_TEST_SUITE_END()