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

Function FL_TEST_FILE

tests/fl/stl/initializer_list.cpp:5–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "fl/stl/int.h"
4
5FL_TEST_FILE(FL_FILEPATH) {
6
7using namespace fl;
8
9FL_TEST_CASE("fl::initializer_list basic functionality") {
10 FL_SUBCASE("empty initializer_list") {
11 fl::initializer_list<int> empty;
12
13 // Note: std::initializer_list doesn't have empty() method
14 FL_CHECK_EQ(empty.size(), 0);
15 FL_CHECK_EQ(empty.begin(), empty.end());
16 }
17
18 FL_SUBCASE("initializer_list with elements") {
19 fl::initializer_list<int> list = {1, 2, 3, 4, 5};
20
21 FL_CHECK_EQ(list.size(), 5);
22 FL_CHECK(list.begin() != list.end());
23 }
24
25 FL_SUBCASE("access elements via iterators") {
26 fl::initializer_list<int> list = {10, 20, 30};
27
28 auto it = list.begin();
29 FL_CHECK_EQ(*it, 10);
30 ++it;
31 FL_CHECK_EQ(*it, 20);
32 ++it;
33 FL_CHECK_EQ(*it, 30);
34 ++it;
35 FL_CHECK(it == list.end());
36 }
37
38 FL_SUBCASE("range-based iteration") {
39 fl::initializer_list<int> list = {1, 2, 3, 4};
40 int sum = 0;
41
42 for (auto val : list) {
43 sum += val;
44 }
45
46 FL_CHECK_EQ(sum, 10);
47 }
48}
49
50FL_TEST_CASE("fl::initializer_list with different types") {
51 FL_SUBCASE("double values") {
52 fl::initializer_list<double> list = {1.5, 2.5, 3.5};
53
54 FL_CHECK_EQ(list.size(), 3);
55
56 auto it = list.begin();
57 FL_CHECK(doctest::Approx(*it).epsilon(0.001) == 1.5);
58 ++it;
59 FL_CHECK(doctest::Approx(*it).epsilon(0.001) == 2.5);
60 ++it;
61 FL_CHECK(doctest::Approx(*it).epsilon(0.001) == 3.5);
62 }

Callers

nothing calls this directly

Calls 6

ApproxFunction · 0.50
beginFunction · 0.50
endFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected