From da6b8b00f742249138077ce9bcd92d8fd4f48ef8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 13 Jan 2024 14:35:39 +0000 Subject: Use std::span for iterator/data pointer in glContainer --- test/test-glContainer.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'test/test-glContainer.cpp') diff --git a/test/test-glContainer.cpp b/test/test-glContainer.cpp index cd57a6b..9d4f198 100644 --- a/test/test-glContainer.cpp +++ b/test/test-glContainer.cpp @@ -8,10 +8,13 @@ #include "glContainer.h" +// Force generation of all functions +template class glContainer; + BOOST_TEST_DONT_PRINT_LOG_VALUE(glContainer::iterator); BOOST_TEST_DONT_PRINT_LOG_VALUE(glContainer::const_iterator); -BOOST_TEST_DONT_PRINT_LOG_VALUE(glContainer::reserve_iterator); -BOOST_TEST_DONT_PRINT_LOG_VALUE(glContainer::const_reserve_iterator); +BOOST_TEST_DONT_PRINT_LOG_VALUE(glContainer::reverse_iterator); +BOOST_TEST_DONT_PRINT_LOG_VALUE(glContainer::const_reverse_iterator); BOOST_GLOBAL_FIXTURE(ApplicationBase); BOOST_GLOBAL_FIXTURE(TestMainWindow); @@ -20,14 +23,14 @@ BOOST_FIXTURE_TEST_SUITE(i, glContainer) BOOST_AUTO_TEST_CASE(createDestroy, *boost::unit_test::timeout(1)) { - BOOST_CHECK(!data_); + BOOST_CHECK(!data_.data()); BOOST_CHECK_NO_THROW(map()); - BOOST_REQUIRE(!data_); + BOOST_REQUIRE(!data_.data()); BOOST_CHECK_NO_THROW(emplace_back(0)); BOOST_CHECK_NO_THROW(map()); - BOOST_REQUIRE(data_); + BOOST_REQUIRE(data_.data()); BOOST_CHECK_NO_THROW(unmap()); - BOOST_CHECK(!data_); + BOOST_CHECK(!data_.data()); } BOOST_AUTO_TEST_CASE(push_back_test, *boost::unit_test::timeout(1)) @@ -38,10 +41,12 @@ BOOST_AUTO_TEST_CASE(push_back_test, *boost::unit_test::timeout(1)) BOOST_CHECK_NO_THROW(push_back(2)); BOOST_CHECK_NO_THROW(push_back(3)); BOOST_CHECK_NO_THROW(push_back(4)); - BOOST_CHECK_EQUAL(capacity_, 4); - BOOST_CHECK_EQUAL(size_, 4); + BOOST_CHECK_NO_THROW(push_back(5)); + BOOST_CHECK_EQUAL(capacity_, 8); + BOOST_CHECK_EQUAL(size_, 5); + BOOST_CHECK_EQUAL(data_.size(), 5); { - std::array expected1 {1, 2, 3, 4}; + std::array expected1 {1, 2, 3, 4, 5}; BOOST_CHECK_EQUAL_COLLECTIONS(begin(), end(), expected1.begin(), expected1.end()); BOOST_CHECK_EQUAL_COLLECTIONS(rbegin(), rend(), expected1.rbegin(), expected1.rend()); } @@ -161,7 +166,7 @@ BOOST_AUTO_TEST_CASE(getters) BOOST_CHECK_EQUAL(2, at(1)); BOOST_CHECK_EQUAL(1, (*this)[0]); BOOST_CHECK_EQUAL(2, (*this)[1]); - BOOST_CHECK_EQUAL(data_, data()); + BOOST_CHECK_EQUAL(data_.data(), data()); BOOST_CHECK_THROW(std::ignore = at(2), std::out_of_range); const auto & constCont {*this}; @@ -178,7 +183,7 @@ BOOST_AUTO_TEST_CASE(getters) BOOST_CHECK_EQUAL(2, constCont.at(1)); BOOST_CHECK_EQUAL(1, constCont[0]); BOOST_CHECK_EQUAL(2, constCont[1]); - BOOST_CHECK_EQUAL(data_, constCont.data()); + BOOST_CHECK_EQUAL(data_.data(), constCont.data()); BOOST_CHECK_THROW(std::ignore = constCont.at(2), std::out_of_range); } -- cgit v1.2.3