| 3 | #include "test.h" |
| 4 | |
| 5 | FL_TEST_FILE(FL_FILEPATH) { |
| 6 | |
| 7 | using namespace fl; |
| 8 | |
| 9 | FL_TEST_CASE("fl::multi_set basic operations") { |
| 10 | fl::multi_set<int> ms; |
| 11 | |
| 12 | FL_SUBCASE("Empty multiset") { |
| 13 | FL_CHECK(ms.empty()); |
| 14 | FL_CHECK(ms.size() == 0); |
| 15 | } |
| 16 | |
| 17 | FL_SUBCASE("Insert single element") { |
| 18 | auto it = ms.insert(42); |
| 19 | FL_CHECK(ms.size() == 1); |
| 20 | FL_CHECK(ms.contains(42)); |
| 21 | FL_CHECK(*it == 42); |
| 22 | } |
| 23 | |
| 24 | FL_SUBCASE("Insert duplicate keys") { |
| 25 | ms.insert(5); |
| 26 | ms.insert(5); |
| 27 | ms.insert(5); |
| 28 | |
| 29 | FL_CHECK(ms.size() == 3); |
| 30 | FL_CHECK(ms.count(5) == 3); |
| 31 | |
| 32 | // All values should be findable |
| 33 | auto range = ms.equal_range(5); |
| 34 | int count = 0; |
| 35 | for (auto it = range.first; it != range.second; ++it) { |
| 36 | count++; |
| 37 | } |
| 38 | FL_CHECK(count == 3); |
| 39 | } |
| 40 | |
| 41 | FL_SUBCASE("Insert different keys") { |
| 42 | ms.insert(1); |
| 43 | ms.insert(2); |
| 44 | ms.insert(3); |
| 45 | |
| 46 | FL_CHECK(ms.size() == 3); |
| 47 | FL_CHECK(ms.count(1) == 1); |
| 48 | FL_CHECK(ms.count(2) == 1); |
| 49 | FL_CHECK(ms.count(3) == 1); |
| 50 | } |
| 51 | |
| 52 | FL_SUBCASE("Find operations") { |
| 53 | ms.insert(10); |
| 54 | ms.insert(20); |
| 55 | |
| 56 | auto it = ms.find(10); |
| 57 | FL_CHECK(it != ms.end()); |
| 58 | FL_CHECK(*it == 10); |
| 59 | |
| 60 | auto missing = ms.find(999); |
| 61 | FL_CHECK(missing == ms.end()); |
| 62 | } |
nothing calls this directly
no test coverage detected