| 7 | #include "fl/math/random.h" |
| 8 | |
| 9 | FL_TEST_FILE(FL_FILEPATH) { |
| 10 | |
| 11 | using namespace fl; |
| 12 | |
| 13 | FL_TEST_CASE("fl::reverse") { |
| 14 | FL_SUBCASE("reverse empty vector") { |
| 15 | fl::vector<int> v; |
| 16 | fl::reverse(v.begin(), v.end()); |
| 17 | FL_CHECK(v.empty()); |
| 18 | } |
| 19 | |
| 20 | FL_SUBCASE("reverse single element") { |
| 21 | fl::vector<int> v = {42}; |
| 22 | fl::reverse(v.begin(), v.end()); |
| 23 | FL_CHECK_EQ(v[0], 42); |
| 24 | } |
| 25 | |
| 26 | FL_SUBCASE("reverse multiple elements") { |
| 27 | fl::vector<int> v = {1, 2, 3, 4, 5}; |
| 28 | fl::reverse(v.begin(), v.end()); |
| 29 | FL_CHECK_EQ(v[0], 5); |
| 30 | FL_CHECK_EQ(v[1], 4); |
| 31 | FL_CHECK_EQ(v[2], 3); |
| 32 | FL_CHECK_EQ(v[3], 2); |
| 33 | FL_CHECK_EQ(v[4], 1); |
| 34 | } |
| 35 | |
| 36 | FL_SUBCASE("reverse even number of elements") { |
| 37 | fl::vector<int> v = {1, 2, 3, 4}; |
| 38 | fl::reverse(v.begin(), v.end()); |
| 39 | FL_CHECK_EQ(v[0], 4); |
| 40 | FL_CHECK_EQ(v[1], 3); |
| 41 | FL_CHECK_EQ(v[2], 2); |
| 42 | FL_CHECK_EQ(v[3], 1); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | FL_TEST_CASE("fl::max_element") { |
| 47 | FL_SUBCASE("max_element empty range") { |
| 48 | fl::vector<int> v; |
| 49 | auto it = fl::max_element(v.begin(), v.end()); |
| 50 | FL_CHECK(it == v.end()); |
| 51 | } |
| 52 | |
| 53 | FL_SUBCASE("max_element single element") { |
| 54 | fl::vector<int> v = {42}; |
| 55 | auto it = fl::max_element(v.begin(), v.end()); |
| 56 | FL_CHECK_EQ(*it, 42); |
| 57 | } |
| 58 | |
| 59 | FL_SUBCASE("max_element finds maximum") { |
| 60 | fl::vector<int> v = {3, 7, 2, 9, 1, 5}; |
| 61 | auto it = fl::max_element(v.begin(), v.end()); |
| 62 | FL_CHECK_EQ(*it, 9); |
| 63 | } |
| 64 | |
| 65 | FL_SUBCASE("max_element with duplicates") { |
| 66 | fl::vector<int> v = {1, 9, 3, 9, 2}; |
nothing calls this directly
no test coverage detected