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

Function FL_TEST_FILE

tests/fl/stl/cstddef.cpp:6–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "fl/stl/static_assert.h"
5
6FL_TEST_FILE(FL_FILEPATH) {
7
8using namespace fl;
9
10///////////////////////////////////////////////////////////////////////////////
11// Test suite for fl/cstddef.h
12//
13// This file tests the FastLED equivalents of stddef.h types:
14// - fl::size_t
15// - fl::ptrdiff_t
16// - fl::nullptr_t
17// - fl::max_align_t
18// - FL_OFFSETOF macro
19///////////////////////////////////////////////////////////////////////////////
20
21FL_TEST_CASE("fl::size_t basic properties") {
22 FL_SUBCASE("size_t is unsigned") {
23 fl::size_t zero = 0;
24 fl::size_t one = 1;
25
26 FL_CHECK(zero < one);
27
28 // size_t is unsigned, so decrementing 0 wraps around
29 fl::size_t wrapped = zero - 1;
30 FL_CHECK(wrapped > zero);
31 }
32
33 FL_SUBCASE("size_t can hold array sizes") {
34 fl::size_t small = 10;
35 fl::size_t medium = 1000;
36 fl::size_t large = 100000;
37
38 FL_CHECK_EQ(small, 10);
39 FL_CHECK_EQ(medium, 1000);
40 FL_CHECK_EQ(large, 100000);
41 }
42
43 FL_SUBCASE("size_t arithmetic") {
44 fl::size_t a = 100;
45 fl::size_t b = 50;
46
47 FL_CHECK_EQ(a + b, 150);
48 FL_CHECK_EQ(a - b, 50);
49 FL_CHECK_EQ(a * 2, 200);
50 FL_CHECK_EQ(a / 2, 50);
51 }
52
53 FL_SUBCASE("size_t comparison") {
54 fl::size_t a = 100;
55 fl::size_t b = 200;
56 fl::size_t c = 100;
57
58 FL_CHECK(a < b);
59 FL_CHECK(b > a);
60 FL_CHECK(a == c);
61 FL_CHECK(a != b);
62 FL_CHECK(a <= c);
63 FL_CHECK(a >= c);

Callers

nothing calls this directly

Calls 1

find_valueFunction · 0.85

Tested by

no test coverage detected