| 6 | #include "fl/stl/int.h" |
| 7 | |
| 8 | FL_TEST_FILE(FL_FILEPATH) { |
| 9 | |
| 10 | using namespace fl; |
| 11 | |
| 12 | // Test basic span construction and access |
| 13 | FL_TEST_CASE("fl::span - basic construction") { |
| 14 | FL_SUBCASE("default constructor") { |
| 15 | span<int> s; |
| 16 | FL_CHECK_EQ(s.size(), 0); |
| 17 | FL_CHECK_EQ(s.data(), nullptr); |
| 18 | FL_CHECK(s.empty()); |
| 19 | } |
| 20 | |
| 21 | FL_SUBCASE("pointer and size constructor") { |
| 22 | int arr[] = {1, 2, 3, 4, 5}; |
| 23 | span<int> s(arr, 5); |
| 24 | FL_CHECK_EQ(s.size(), 5); |
| 25 | FL_CHECK_EQ(s.data(), arr); |
| 26 | FL_CHECK_EQ(s[0], 1); |
| 27 | FL_CHECK_EQ(s[4], 5); |
| 28 | FL_CHECK(!s.empty()); |
| 29 | } |
| 30 | |
| 31 | FL_SUBCASE("C-array constructor") { |
| 32 | int arr[] = {10, 20, 30}; |
| 33 | span<int> s(arr); |
| 34 | FL_CHECK_EQ(s.size(), 3); |
| 35 | FL_CHECK_EQ(s[0], 10); |
| 36 | FL_CHECK_EQ(s[1], 20); |
| 37 | FL_CHECK_EQ(s[2], 30); |
| 38 | } |
| 39 | |
| 40 | FL_SUBCASE("fl::array constructor") { |
| 41 | fl::array<int, 4> arr = {7, 8, 9, 10}; |
| 42 | span<int> s(arr); |
| 43 | FL_CHECK_EQ(s.size(), 4); |
| 44 | FL_CHECK_EQ(s[0], 7); |
| 45 | FL_CHECK_EQ(s[3], 10); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // Test const conversions |
| 50 | FL_TEST_CASE("fl::span - const conversions") { |
| 51 | FL_SUBCASE("non-const to const span") { |
| 52 | int arr[] = {1, 2, 3}; |
| 53 | span<int> s(arr); |
| 54 | span<const int> cs = s; |
| 55 | FL_CHECK_EQ(cs.size(), 3); |
| 56 | FL_CHECK_EQ(cs[0], 1); |
| 57 | FL_CHECK_EQ(cs[2], 3); |
| 58 | } |
| 59 | |
| 60 | FL_SUBCASE("const array to const span") { |
| 61 | const int arr[] = {5, 6, 7}; |
| 62 | span<const int> s(arr); |
| 63 | FL_CHECK_EQ(s.size(), 3); |
| 64 | FL_CHECK_EQ(s[0], 5); |
| 65 | } |
nothing calls this directly
no test coverage detected