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

Function FL_TEST_FILE

tests/fl/stl/cstring.cpp:19–756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "test.h"
18
19FL_TEST_FILE(FL_FILEPATH) {
20
21// Note: We do NOT use "using namespace fl;" because string functions
22// would conflict with system C library functions (strcmp, strcpy, etc.)
23// Instead, we explicitly use fl:: prefix for all function calls.
24
25// ============================================================================
26// String Length and Comparison Tests
27// ============================================================================
28
29FL_TEST_CASE("fl::strlen") {
30 FL_SUBCASE("empty string") {
31 FL_CHECK_EQ(fl::strlen(""), 0);
32 }
33
34 FL_SUBCASE("single character") {
35 FL_CHECK_EQ(fl::strlen("a"), 1);
36 }
37
38 FL_SUBCASE("normal string") {
39 FL_CHECK_EQ(fl::strlen("hello"), 5);
40 FL_CHECK_EQ(fl::strlen("FastLED"), 7);
41 }
42
43 FL_SUBCASE("string with spaces") {
44 FL_CHECK_EQ(fl::strlen("hello world"), 11);
45 }
46
47 FL_SUBCASE("string with special characters") {
48 FL_CHECK_EQ(fl::strlen("test\n\t"), 6);
49 }
50}
51
52FL_TEST_CASE("fl::strcmp") {
53 FL_SUBCASE("equal strings") {
54 FL_CHECK_EQ(fl::strcmp("hello", "hello"), 0);
55 FL_CHECK_EQ(fl::strcmp("", ""), 0);
56 }
57
58 FL_SUBCASE("first less than second") {
59 FL_CHECK(fl::strcmp("abc", "abd") < 0);
60 FL_CHECK(fl::strcmp("a", "b") < 0);
61 }
62
63 FL_SUBCASE("first greater than second") {
64 FL_CHECK(fl::strcmp("abd", "abc") > 0);
65 FL_CHECK(fl::strcmp("b", "a") > 0);
66 }
67
68 FL_SUBCASE("different lengths") {
69 FL_CHECK(fl::strcmp("hello", "hello world") < 0);
70 FL_CHECK(fl::strcmp("hello world", "hello") > 0);
71 }
72
73 FL_SUBCASE("case sensitive") {
74 FL_CHECK(fl::strcmp("Hello", "hello") != 0);
75 FL_CHECK(fl::strcmp("HELLO", "hello") != 0);
76 }

Callers

nothing calls this directly

Calls 15

strlenFunction · 0.85
strcmpFunction · 0.85
strncmpFunction · 0.85
strcpyFunction · 0.85
strncpyFunction · 0.85
memsetFunction · 0.85
strcatFunction · 0.85
strncatFunction · 0.85
strstrFunction · 0.85
strchrFunction · 0.85
strrchrFunction · 0.85
strspnFunction · 0.85

Tested by

no test coverage detected