diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-23 18:09:16 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-23 18:09:16 +0000 |
commit | 8734626b2c6fc36acc59e0d7bf7e51d4cff719de (patch) | |
tree | aafec70ddb21a08a8ec6617bbb21e9de162f45b1 /test | |
parent | Use otherObjects where possible for find (diff) | |
download | ilt-8734626b2c6fc36acc59e0d7bf7e51d4cff719de.tar.bz2 ilt-8734626b2c6fc36acc59e0d7bf7e51d4cff719de.tar.xz ilt-8734626b2c6fc36acc59e0d7bf7e51d4cff719de.zip |
Use typed collections for apply/applyOne
Diffstat (limited to 'test')
-rw-r--r-- | test/test-collection.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test-collection.cpp b/test/test-collection.cpp index 7fadcf9..5aae9f0 100644 --- a/test/test-collection.cpp +++ b/test/test-collection.cpp @@ -21,6 +21,12 @@ public: return false; } + [[nodiscard]] virtual bool + yes() const + { + return true; + } + unsigned int total {0}; }; @@ -137,6 +143,8 @@ BOOST_AUTO_TEST_SUITE_END() using TestUniqueCollection = UniqueCollection<Base, Sub>; BOOST_TEST_DONT_PRINT_LOG_VALUE(TestUniqueCollection::Objects::const_iterator) BOOST_TEST_DONT_PRINT_LOG_VALUE(TestUniqueCollection::Objects::const_reverse_iterator) +BOOST_TEST_DONT_PRINT_LOG_VALUE(TestUniqueCollection::Objects::iterator) +BOOST_TEST_DONT_PRINT_LOG_VALUE(TestUniqueCollection::Objects::reverse_iterator) BOOST_FIXTURE_TEST_SUITE(utc, TestUniqueCollection) @@ -204,6 +212,26 @@ BOOST_AUTO_TEST_CASE(no_others) emplace(std::make_unique<Sub>()); } +BOOST_AUTO_TEST_CASE(applyAll) +{ + create<Base>(); + BOOST_CHECK_EQUAL(0, apply<Sub>(&Base::add)); + BOOST_CHECK_EQUAL(1, apply<Base>(&Base::add)); + create<Sub>(); + BOOST_CHECK_EQUAL(1, apply<Sub>(&Base::add)); + BOOST_CHECK_EQUAL(2, apply<Base>(&Base::add)); +} + +BOOST_AUTO_TEST_CASE(applyOneType) +{ + create<Base>(); + BOOST_CHECK_EQUAL(objects.end(), applyOne<Sub>(&Base::yes)); + BOOST_CHECK_EQUAL(objects.begin(), applyOne<Base>(&Base::yes)); + create<Sub>(); + BOOST_CHECK_EQUAL(objects.begin() + 1, applyOne<Sub>(&Base::yes)); + BOOST_CHECK_EQUAL(objects.begin(), applyOne<Base>(&Base::yes)); +} + BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_CASE(wrapped_ptr_file_cons) |