MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/stl/algorithm.cpp:9–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include "fl/math/random.h"
8
9FL_TEST_FILE(FL_FILEPATH) {
10
11using namespace fl;
12
13FL_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
46FL_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};

Callers

nothing calls this directly

Calls 15

reverseFunction · 0.85
max_elementFunction · 0.85
min_elementFunction · 0.85
equalFunction · 0.85
lexicographical_compareFunction · 0.85
equal_containerFunction · 0.85
fillFunction · 0.85
find_if_notFunction · 0.85
remove_ifFunction · 0.85
sortFunction · 0.85
stable_sortFunction · 0.85
shuffleFunction · 0.85

Tested by

no test coverage detected