diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-23 13:00:03 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-23 13:00:03 +0000 |
commit | a53a6672b8fc89834b1ec3aa7afae150a617473f (patch) | |
tree | efd2ab5e32cd75e2e36ad53042725c91346b7cfa /test | |
parent | Make Collections::objects protected, extend interface (diff) | |
download | ilt-a53a6672b8fc89834b1ec3aa7afae150a617473f.tar.bz2 ilt-a53a6672b8fc89834b1ec3aa7afae150a617473f.tar.xz ilt-a53a6672b8fc89834b1ec3aa7afae150a617473f.zip |
Populate typed collection of pointers
create and emplace only, so far
Diffstat (limited to 'test')
-rw-r--r-- | test/test-collection.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/test-collection.cpp b/test/test-collection.cpp index 00298bb..5c67a8c 100644 --- a/test/test-collection.cpp +++ b/test/test-collection.cpp @@ -34,7 +34,7 @@ public: } }; -using TestCollection = SharedCollection<Base>; +using TestCollection = SharedCollection<Base, Sub>; BOOST_TEST_DONT_PRINT_LOG_VALUE(TestCollection::Objects::const_iterator) BOOST_TEST_DONT_PRINT_LOG_VALUE(TestCollection::Objects::const_reverse_iterator) @@ -51,12 +51,24 @@ BOOST_AUTO_TEST_CASE(empty) BOOST_AUTO_TEST_CASE(a_base) { auto b = create<Base>(); + BOOST_CHECK_EQUAL(objects.size(), 1); + BOOST_CHECK(std::get<OtherObjects<Sub>>(otherObjects).empty()); BOOST_REQUIRE(apply(&Base::add)); BOOST_CHECK_EQUAL(b->total, 1); const auto i = applyOne(&Base::add); BOOST_CHECK_EQUAL(i, end()); } +BOOST_AUTO_TEST_CASE(emplace_others) +{ + emplace(std::make_shared<Base>()); + BOOST_CHECK_EQUAL(objects.size(), 1); + BOOST_CHECK(std::get<OtherObjects<Sub>>(otherObjects).empty()); + emplace(std::make_shared<Sub>()); + BOOST_CHECK_EQUAL(objects.size(), 2); + BOOST_CHECK_EQUAL(std::get<OtherObjects<Sub>>(otherObjects).size(), 1); +} + BOOST_AUTO_TEST_CASE(a_rbase) { auto b = create<Base>(); @@ -69,6 +81,8 @@ BOOST_AUTO_TEST_CASE(a_rbase) BOOST_AUTO_TEST_CASE(a_sub) { auto s = create<Sub>(); + BOOST_CHECK_EQUAL(objects.size(), 1); + BOOST_CHECK_EQUAL(std::get<OtherObjects<Sub>>(otherObjects).size(), 1); BOOST_REQUIRE(apply(&Base::add)); BOOST_CHECK_EQUAL(s->total, 2); const auto i = applyOne(&Base::add); |