From 7c03d93c367b842c464dca30e121bc4c20547c36 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 1 Jan 2022 16:44:19 +0000 Subject: Generic solution for glGen/glDel arrays, then tidy-up the uses --- test/test-lib.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/test-lib.cpp (limited to 'test/test-lib.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 +#include + +#include +#include +#include + +std::set 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()); +} -- cgit v1.2.3