| 5 | #include "fl/stl/static_assert.h" |
| 6 | |
| 7 | FL_TEST_FILE(FL_FILEPATH) { |
| 8 | |
| 9 | using namespace fl; |
| 10 | |
| 11 | namespace { |
| 12 | |
| 13 | // Helper class to test move semantics |
| 14 | struct MoveTestTypePair { |
| 15 | int value; |
| 16 | bool moved_from = false; |
| 17 | bool moved_to = false; |
| 18 | |
| 19 | MoveTestTypePair() : value(0) {} |
| 20 | explicit MoveTestTypePair(int v) : value(v) {} |
| 21 | |
| 22 | // Copy constructor |
| 23 | MoveTestTypePair(const MoveTestTypePair& other) : value(other.value) {} |
| 24 | |
| 25 | // Move constructor |
| 26 | MoveTestTypePair(MoveTestTypePair&& other) noexcept |
| 27 | : value(other.value), moved_to(true) { |
| 28 | other.moved_from = true; |
| 29 | other.value = 0; |
| 30 | } |
| 31 | |
| 32 | // Copy assignment |
| 33 | MoveTestTypePair& operator=(const MoveTestTypePair& other) { |
| 34 | value = other.value; |
| 35 | return *this; |
| 36 | } |
| 37 | |
| 38 | // Move assignment |
| 39 | MoveTestTypePair& operator=(MoveTestTypePair&& other) noexcept { |
| 40 | value = other.value; |
| 41 | moved_to = true; |
| 42 | other.moved_from = true; |
| 43 | other.value = 0; |
| 44 | return *this; |
| 45 | } |
| 46 | |
| 47 | bool operator==(const MoveTestTypePair& other) const { |
| 48 | return value == other.value; |
| 49 | } |
| 50 | |
| 51 | bool operator<(const MoveTestTypePair& other) const { |
| 52 | return value < other.value; |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | } // anonymous namespace |
| 57 | |
| 58 | FL_TEST_CASE("fl::pair default constructor") { |
| 59 | FL_SUBCASE("pair with default constructible types") { |
| 60 | pair<int, double> p; |
| 61 | FL_CHECK_EQ(p.first, 0); |
| 62 | FL_CHECK_EQ(p.second, 0.0); |
| 63 | } |
| 64 |
nothing calls this directly
no test coverage detected