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

Function FL_TEST_FILE

tests/fl/stl/string.cpp:20–6468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#include "test.h"
19
20FL_TEST_FILE(FL_FILEPATH) {
21
22using namespace fl;
23
24
25//=============================================================================
26// SECTION: Tests from str.cpp
27//=============================================================================
28
29FL_TEST_CASE("Str basic operations") {
30 FL_SUBCASE("Construction and assignment") {
31 fl::string s1;
32 FL_CHECK(s1.size() == 0);
33 FL_CHECK(s1.c_str()[0] == '\0');
34
35 fl::string s2("hello");
36 FL_CHECK(s2.size() == 5);
37 FL_CHECK(fl::strcmp(s2.c_str(), "hello") == 0);
38
39 fl::string s3 = s2;
40 FL_CHECK(s3.size() == 5);
41 FL_CHECK(fl::strcmp(s3.c_str(), "hello") == 0);
42
43 s1 = "world";
44 FL_CHECK(s1.size() == 5);
45 FL_CHECK(fl::strcmp(s1.c_str(), "world") == 0);
46 }
47
48 FL_SUBCASE("Comparison operators") {
49 fl::string s1("hello");
50 fl::string s2("hello");
51 fl::string s3("world");
52
53 FL_CHECK(s1 == s2);
54 FL_CHECK(s1 != s3);
55 }
56
57 FL_SUBCASE("Indexing") {
58 fl::string s("hello");
59 FL_CHECK(s[0] == 'h');
60 FL_CHECK(s[4] == 'o');
61 FL_CHECK(s[5] == '\0'); // Null terminator
62 }
63
64 FL_SUBCASE("Append") {
65 fl::string s("hello");
66 s.append(" world");
67 FL_CHECK(s.size() == 11);
68 FL_CHECK(fl::strcmp(s.c_str(), "hello world") == 0);
69 }
70
71 FL_SUBCASE("CRGB to Str") {
72 CRGB c(255, 0, 0);
73 fl::string s = c.toString();
74 FL_CHECK_EQ(s, "CRGB(255,0,0)");
75 }
76
77 FL_SUBCASE("Copy-on-write behavior") {

Callers

nothing calls this directly

Calls 15

strcmpFunction · 0.85
strlenFunction · 0.85
snprintfFunction · 0.85
toStringMethod · 0.80
is_owningMethod · 0.80
is_referencingMethod · 0.80
substringMethod · 0.80
stringClass · 0.50
to_stringFunction · 0.50
sizeFunction · 0.50
string_viewClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected