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

Function FL_TEST_FILE

tests/fl/stl/strstream.cpp:45–1173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#include "fl/stl/string.h"
44
45FL_TEST_FILE(FL_FILEPATH) {
46
47FL_TEST_CASE("sstream basic operations") {
48 FL_SUBCASE("Construction and assignment") {
49 fl::sstream s;
50 FL_CHECK(s.str().size() == 0);
51 FL_CHECK(s.str().c_str()[0] == '\0');
52
53 fl::sstream s2("hello");
54 FL_CHECK(s2.str().size() == 5);
55 FL_CHECK(fl::strcmp(s2.str().c_str(), "hello") == 0);
56
57 fl::sstream s3 = s2;
58 FL_CHECK(s3.str().size() == 5);
59 FL_CHECK(fl::strcmp(s3.str().c_str(), "hello") == 0);
60
61 s = "world";
62 FL_CHECK(s.str().size() == 5);
63 FL_CHECK(fl::strcmp(s.str().c_str(), "world") == 0);
64 }
65
66 FL_SUBCASE("Comparison operators") {
67 fl::sstream s1("hello");
68 fl::sstream s2("hello");
69 fl::sstream s3("world");
70
71 FL_CHECK(s1.str() == s2.str());
72 FL_CHECK(s1.str() != s3.str());
73 }
74
75 FL_SUBCASE("Indexing") {
76 fl::sstream s("hello");
77 FL_CHECK(s.str()[0] == 'h');
78 FL_CHECK(s.str()[4] == 'o');
79 FL_CHECK(s.str()[5] == '\0'); // Null terminator
80 }
81
82 FL_SUBCASE("Append") {
83 fl::sstream s("hello");
84 s << " world";
85 FL_CHECK(s.str().size() == 11);
86 FL_CHECK(fl::strcmp(s.str().c_str(), "hello world") == 0);
87 }
88
89 FL_SUBCASE("CRGB to fl::sstream") {
90 CRGB c(255, 0, 0);
91 fl::sstream s;
92 s << c;
93 FL_CHECK(s.str().size() == 13); // "CRGB(255,0,0)" is 13 chars
94 FL_CHECK(fl::strcmp(s.str().c_str(), "CRGB(255,0,0)") == 0);
95 }
96}
97
98FL_TEST_CASE("sstream integer type handling") {
99 FL_SUBCASE("uint8_t displays as number") {
100 fl::sstream s;
101 fl::u8 val = 65; // ASCII 'A'
102 s << val;

Callers

nothing calls this directly

Calls 15

strcmpFunction · 0.85
strstrFunction · 0.85
test_template_typeFunction · 0.85
test_string_typesFunction · 0.85
test_char_typesFunction · 0.85
test_fl_int_typesFunction · 0.85
test_bool_typeFunction · 0.85
test_crgb_typeFunction · 0.85
test_cpp_string_typeFunction · 0.85
test_mixed_typesFunction · 0.85

Tested by

no test coverage detected