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

Function FL_TEST_FILE

tests/fl/slice.cpp:8–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "fl/stl/int.h"
7
8FL_TEST_FILE(FL_FILEPATH) {
9
10using namespace fl;
11
12// Test basic span construction and access
13FL_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
50FL_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 }

Callers

nothing calls this directly

Calls 15

sliceMethod · 0.80
getParentCoordMethod · 0.80
getLocalCoordMethod · 0.80
sizeFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected