summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-01-01 16:44:19 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-01-01 16:44:19 +0000
commit7c03d93c367b842c464dca30e121bc4c20547c36 (patch)
tree6df340dc3b0bd16f6ced2a051a68fc8a3c67a08c /test
parentFirst iteration with font/text support (diff)
downloadilt-7c03d93c367b842c464dca30e121bc4c20547c36.tar.bz2
ilt-7c03d93c367b842c464dca30e121bc4c20547c36.tar.xz
ilt-7c03d93c367b842c464dca30e121bc4c20547c36.zip
Generic solution for glGen/glDel arrays, then tidy-up the uses
Diffstat (limited to 'test')
-rw-r--r--test/Jamfile.jam1
-rw-r--r--test/test-lib.cpp50
2 files changed, 51 insertions, 0 deletions
diff --git a/test/Jamfile.jam b/test/Jamfile.jam
index f8987d0..e487044 100644
--- a/test/Jamfile.jam
+++ b/test/Jamfile.jam
@@ -22,6 +22,7 @@ project : requirements
run test-collection.cpp ;
run test-obj.cpp ;
run test-maths.cpp ;
+run test-lib.cpp ;
run test-network.cpp ;
run test-persistence.cpp : -- : [ sequence.insertion-sort [ glob fixtures/json/*.json fixtures/json/bad/*.json ] ] ;
run test-text.cpp ;
diff --git a/test/test-lib.cpp b/test/test-lib.cpp
new file mode 100644
index 0000000..e464f2f
--- /dev/null
+++ b/test/test-lib.cpp
@@ -0,0 +1,50 @@
+#define BOOST_TEST_MODULE test_lib
+
+#include "test-helpers.hpp"
+#include <boost/test/data/test_case.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <GL/glew.h>
+#include <glArrays.h>
+#include <set>
+
+std::set<GLuint> active;
+void
+generator(GLsizei n, GLuint * out)
+{
+ static GLuint next {1};
+
+ while (n--) {
+ active.insert(next);
+ *out++ = next++;
+ }
+}
+
+void
+deleter(GLsizei n, GLuint * in)
+{
+ BOOST_CHECK(std::all_of(in, in + n, [](GLuint id) {
+ return active.erase(id) > 0;
+ }));
+}
+
+using TestArray = glArrays<5, &generator, &deleter>;
+
+BOOST_AUTO_TEST_CASE(generate_and_delete)
+{
+ {
+ TestArray a;
+ }
+ BOOST_CHECK(active.empty());
+}
+
+BOOST_AUTO_TEST_CASE(generate_move_and_delete)
+{
+ {
+ TestArray a;
+ BOOST_CHECK_EQUAL(TestArray::size, active.size());
+ TestArray b {std::move(a)};
+ BOOST_CHECK_EQUAL(TestArray::size, active.size());
+ }
+ BOOST_CHECK(active.empty());
+}