summaryrefslogtreecommitdiff
path: root/test/test-instancing.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-05-07 01:41:31 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-05-07 01:41:31 +0100
commit9ab2aad4aa00afe3373b3a779377fa049459fb4d (patch)
tree18bf013e3be660b0769cd1a601e670eb79355324 /test/test-instancing.cpp
parentRename strings.h to something that won't conflict with a system header (diff)
parentTemplated BufferedLocation and single buffer storage for RVC locations (diff)
downloadilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.tar.bz2
ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.tar.xz
ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.zip
Merge branch 'containers'
Diffstat (limited to 'test/test-instancing.cpp')
-rw-r--r--test/test-instancing.cpp65
1 files changed, 30 insertions, 35 deletions
diff --git a/test/test-instancing.cpp b/test/test-instancing.cpp
index 8745484..7d8ea55 100644
--- a/test/test-instancing.cpp
+++ b/test/test-instancing.cpp
@@ -17,14 +17,8 @@ BOOST_FIXTURE_TEST_SUITE(i, InstanceVertices<int>)
BOOST_AUTO_TEST_CASE(createDestroy)
{
- BOOST_CHECK(!data);
- map();
- BOOST_REQUIRE(data);
- BOOST_CHECK_EQUAL(0, next);
BOOST_CHECK(unused.empty());
BOOST_CHECK(index.empty());
- unmap();
- BOOST_CHECK(!data);
}
BOOST_AUTO_TEST_CASE(acquireRelease)
@@ -32,12 +26,12 @@ BOOST_AUTO_TEST_CASE(acquireRelease)
{
auto proxy = acquire();
*proxy = 20;
- BOOST_CHECK_EQUAL(1, next);
+ BOOST_CHECK_EQUAL(1, size());
BOOST_REQUIRE_EQUAL(1, index.size());
BOOST_CHECK_EQUAL(0, index.front());
BOOST_CHECK(unused.empty());
}
- BOOST_CHECK_EQUAL(0, next);
+ BOOST_CHECK_EQUAL(0, size());
BOOST_CHECK(unused.empty());
BOOST_CHECK(index.empty());
}
@@ -47,13 +41,13 @@ BOOST_AUTO_TEST_CASE(acquireReleaseMove)
{
auto proxy1 = acquire();
*proxy1 = 20;
- BOOST_CHECK_EQUAL(1, next);
+ BOOST_CHECK_EQUAL(1, size());
auto proxy2 = std::move(proxy1);
proxy2 = 40;
- BOOST_CHECK_EQUAL(1, next);
- BOOST_CHECK_EQUAL(data[0], 40);
+ BOOST_CHECK_EQUAL(1, size());
+ BOOST_CHECK_EQUAL(at(0), 40);
}
- BOOST_CHECK_EQUAL(0, next);
+ BOOST_CHECK_EQUAL(0, size());
BOOST_CHECK(unused.empty());
BOOST_CHECK(index.empty());
}
@@ -62,13 +56,13 @@ BOOST_AUTO_TEST_CASE(autoMapUnmap)
{
{
auto proxy = acquire();
- BOOST_CHECK(data);
+ BOOST_CHECK(data_);
std::ignore = bufferName();
- BOOST_CHECK(data);
- BOOST_CHECK_EQUAL(1, count());
- BOOST_CHECK(!data);
+ BOOST_CHECK(data_);
+ BOOST_CHECK_EQUAL(1, size());
+ BOOST_CHECK(!data_);
}
- BOOST_CHECK_EQUAL(0, count());
+ BOOST_CHECK_EQUAL(0, size());
}
BOOST_AUTO_TEST_CASE(initialize)
@@ -89,7 +83,7 @@ BOOST_AUTO_TEST_CASE(resize)
proxies.push_back(acquire(n));
expected.emplace_back(n);
}
- BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), data, data + COUNT);
+ BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), data(), data() + COUNT);
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), proxies.begin(), proxies.end());
}
@@ -100,11 +94,11 @@ BOOST_AUTO_TEST_CASE(shuffle)
BOOST_CHECK_EQUAL(1, proxies.emplace_back(acquire(1)));
BOOST_CHECK_EQUAL(2, proxies.emplace_back(acquire(2)));
BOOST_CHECK_EQUAL(3, proxies.emplace_back(acquire(3)));
- BOOST_CHECK_EQUAL(4, next);
- BOOST_CHECK_EQUAL(data + 0, proxies[0].get());
- BOOST_CHECK_EQUAL(data + 1, proxies[1].get());
- BOOST_CHECK_EQUAL(data + 2, proxies[2].get());
- BOOST_CHECK_EQUAL(data + 3, proxies[3].get());
+ BOOST_CHECK_EQUAL(4, size());
+ BOOST_CHECK_EQUAL(at(0), *proxies[0].get());
+ BOOST_CHECK_EQUAL(at(1), *proxies[1].get());
+ BOOST_CHECK_EQUAL(at(2), *proxies[2].get());
+ BOOST_CHECK_EQUAL(at(3), *proxies[3].get());
BOOST_CHECK(unused.empty());
BOOST_REQUIRE_EQUAL(4, index.size());
BOOST_CHECK_EQUAL(0, index[0]);
@@ -113,28 +107,29 @@ BOOST_AUTO_TEST_CASE(shuffle)
BOOST_CHECK_EQUAL(3, index[3]);
// Remove 1, 3 moves to [1]
proxies.erase(proxies.begin() + 1);
+ BOOST_REQUIRE_EQUAL(3, proxies.size());
BOOST_REQUIRE_EQUAL(4, index.size());
BOOST_REQUIRE_EQUAL(1, unused.size());
BOOST_CHECK_EQUAL(1, unused[0]);
- BOOST_CHECK_EQUAL(data + 0, proxies[0].get());
- BOOST_CHECK_EQUAL(data + 2, proxies[1].get());
- BOOST_CHECK_EQUAL(data + 1, proxies[2].get());
- // Remove 1, 2 moves to [1]
+ BOOST_CHECK_EQUAL(at(0), *proxies[0].get());
+ BOOST_CHECK_EQUAL(at(2), *proxies[1].get());
+ BOOST_CHECK_EQUAL(at(1), *proxies[2].get());
+ // Remove 1, 2 moves to [1]
proxies.erase(proxies.begin() + 1);
BOOST_REQUIRE_EQUAL(4, index.size());
BOOST_REQUIRE_EQUAL(2, unused.size());
BOOST_CHECK_EQUAL(1, unused[0]);
BOOST_CHECK_EQUAL(2, unused[1]);
- BOOST_CHECK_EQUAL(data + 0, proxies[0].get());
- BOOST_CHECK_EQUAL(data + 1, proxies[1].get());
+ BOOST_CHECK_EQUAL(at(0), *proxies[0].get());
+ BOOST_CHECK_EQUAL(at(1), *proxies[1].get());
// Add new, takes 2 at [2]
BOOST_CHECK_EQUAL(4, proxies.emplace_back(acquire(4)));
BOOST_REQUIRE_EQUAL(4, index.size());
BOOST_REQUIRE_EQUAL(1, unused.size());
BOOST_CHECK_EQUAL(1, unused[0]);
- BOOST_CHECK_EQUAL(data + 0, proxies[0].get());
- BOOST_CHECK_EQUAL(data + 1, proxies[1].get());
- BOOST_CHECK_EQUAL(data + 2, proxies[2].get());
+ BOOST_CHECK_EQUAL(at(0), *proxies[0].get());
+ BOOST_CHECK_EQUAL(at(1), *proxies[1].get());
+ BOOST_CHECK_EQUAL(at(2), *proxies[2].get());
}
BOOST_DATA_TEST_CASE(shuffle_random, boost::unit_test::data::xrange(0, 10), x)
@@ -158,7 +153,7 @@ BOOST_DATA_TEST_CASE(shuffle_random, boost::unit_test::data::xrange(0, 10), x)
break;
}
- BOOST_REQUIRE_EQUAL(next, proxies.size());
+ BOOST_REQUIRE_EQUAL(size(), proxies.size());
for (const auto & [n, p] : proxies) {
BOOST_REQUIRE_EQUAL(n, p);
}
@@ -169,10 +164,10 @@ BOOST_DATA_TEST_CASE(shuffle_random, boost::unit_test::data::xrange(0, 10), x)
}
}
BOOST_TEST_CONTEXT(index) {
- BOOST_REQUIRE_EQUAL(iused.size(), next);
+ BOOST_REQUIRE_EQUAL(iused.size(), size());
if (!iused.empty()) {
BOOST_REQUIRE_EQUAL(*iused.begin(), 0);
- BOOST_REQUIRE_EQUAL(*iused.rbegin(), next - 1);
+ BOOST_REQUIRE_EQUAL(*iused.rbegin(), size() - 1);
}
}
}