diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-23 14:21:12 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-23 14:21:12 +0000 |
commit | 035299f23a9207bb521b19e2f77154c276cf3033 (patch) | |
tree | 33d24274a6eb716d1d92f9bff074c3e81b8fb71e /test | |
parent | Other objects support in operator= (diff) | |
download | ilt-035299f23a9207bb521b19e2f77154c276cf3033.tar.bz2 ilt-035299f23a9207bb521b19e2f77154c276cf3033.tar.xz ilt-035299f23a9207bb521b19e2f77154c276cf3033.zip |
Other objects support in removeAll/clear
removeAll requires a type that is one of Others, clear clears everything
regardless of type.
Diffstat (limited to 'test')
-rw-r--r-- | test/test-collection.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test-collection.cpp b/test/test-collection.cpp index 0cd08d5..13df95c 100644 --- a/test/test-collection.cpp +++ b/test/test-collection.cpp @@ -143,6 +143,30 @@ BOOST_AUTO_TEST_CASE(move_assign) BOOST_CHECK(other.empty()); } +BOOST_AUTO_TEST_CASE(clearAll) +{ + create<Base>(); + create<Sub>(); + emplace(std::make_unique<Base>()); + emplace(std::make_unique<Sub>()); + + clear(); + BOOST_CHECK(objects.empty()); + BOOST_CHECK(std::get<OtherObjects<Sub>>(otherObjects).empty()); +} + +BOOST_AUTO_TEST_CASE(removeAllOfSub) +{ + create<Base>(); + create<Sub>(); + emplace(std::make_unique<Base>()); + emplace(std::make_unique<Sub>()); + + removeAll<Sub>(); + BOOST_CHECK_EQUAL(objects.size(), 2); + BOOST_CHECK(std::get<OtherObjects<Sub>>(otherObjects).empty()); +} + BOOST_AUTO_TEST_SUITE_END() BOOST_FIXTURE_TEST_SUITE(btc, UniqueCollection<Base>) |