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

Function FL_TEST_FILE

tests/fl/stl/array.cpp:11–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include "fl/stl/static_assert.h"
10
11FL_TEST_FILE(FL_FILEPATH) {
12
13using namespace fl;
14
15FL_TEST_CASE("fl::array - Basic construction and initialization") {
16 FL_SUBCASE("Default constructor") {
17 array<int, 5> arr;
18 FL_CHECK_EQ(arr.size(), 5);
19 FL_CHECK_FALSE(arr.empty());
20 }
21
22 // Note: Fill constructor disabled due to undefined fill_n function
23 // FL_SUBCASE("Fill constructor") {
24 // array<int, 5> arr(42);
25 // FL_CHECK_EQ(arr.size(), 5);
26 // for (size i = 0; i < 5; ++i) {
27 // FL_CHECK_EQ(arr[i], 42);
28 // }
29 // }
30
31 FL_SUBCASE("Initializer list constructor") {
32 array<int, 5> arr = {1, 2, 3, 4, 5};
33 FL_CHECK_EQ(arr[0], 1);
34 FL_CHECK_EQ(arr[1], 2);
35 FL_CHECK_EQ(arr[2], 3);
36 FL_CHECK_EQ(arr[3], 4);
37 FL_CHECK_EQ(arr[4], 5);
38 }
39
40 FL_SUBCASE("Initializer list with fewer elements") {
41 array<int, 5> arr = {1, 2, 3};
42 FL_CHECK_EQ(arr[0], 1);
43 FL_CHECK_EQ(arr[1], 2);
44 FL_CHECK_EQ(arr[2], 3);
45 // Note: arr[3] and arr[4] are default-initialized
46 }
47
48 FL_SUBCASE("Zero-size array") {
49 array<int, 0> arr;
50 FL_CHECK_EQ(arr.size(), 0);
51 FL_CHECK(arr.empty());
52 }
53}
54
55FL_TEST_CASE("fl::array - Copy and move semantics") {
56 FL_SUBCASE("Copy constructor") {
57 array<int, 3> arr1 = {1, 2, 3};
58 array<int, 3> arr2(arr1);
59 FL_CHECK_EQ(arr2[0], 1);
60 FL_CHECK_EQ(arr2[1], 2);
61 FL_CHECK_EQ(arr2[2], 3);
62 }
63
64 FL_SUBCASE("Copy assignment") {
65 array<int, 3> arr1 = {1, 2, 3};
66 array<int, 3> arr2;
67 arr2 = arr1;
68 FL_CHECK_EQ(arr2[0], 1);

Callers

nothing calls this directly

Calls 15

to_arrayFunction · 0.85
ApproxFunction · 0.50
swapFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45
atMethod · 0.45
frontMethod · 0.45
backMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
cbeginMethod · 0.45

Tested by

no test coverage detected