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

Function FL_TEST_FILE

tests/fl/stl/json.cpp:26–2658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24#include "fl/stl/strstream.h"
25
26FL_TEST_FILE(FL_FILEPATH) {
27
28using namespace fl;
29
30FL_TEST_CASE("Test simple JSON parsing") {
31 // Milestone 2: Verify empty object/array parsing
32 FL_SUBCASE("parse2() A/B: Empty object") {
33 const char* json_str = "{}";
34 json result1 = json::parse(json_str);
35 json result2 = json::parse(json_str);
36
37 FL_CHECK(result1.is_object() == result2.is_object());
38 FL_CHECK(result1.size() == result2.size());
39 }
40
41 FL_SUBCASE("parse2() A/B: Empty array") {
42 const char* json_str = "[]";
43 json result1 = json::parse(json_str);
44 json result2 = json::parse(json_str);
45
46 FL_CHECK(result1.is_array() == result2.is_array());
47 FL_CHECK(result1.size() == result2.size());
48 }
49
50 // Milestone 3: STRING tokenization
51 FL_SUBCASE("parse2() A/B: Simple string") {
52 const char* json_str = "\"hello\"";
53 json result1 = json::parse(json_str);
54 json result2 = json::parse(json_str);
55
56 FL_CHECK(result1.is_string() == result2.is_string());
57 FL_CHECK(result1.as<fl::string>() == result2.as<fl::string>());
58 }
59
60 FL_SUBCASE("parse2() A/B: Escaped string") {
61 const char* json_str = R"("He said \"hello\"")";
62 json result1 = json::parse(json_str);
63 json result2 = json::parse(json_str);
64
65 FL_CHECK(result1.is_string() == result2.is_string());
66 auto str1 = result1.as<fl::string>();
67 auto str2 = result2.as<fl::string>();
68 FL_CHECK(str1 == str2);
69 }
70
71 // Milestone 4: NUMBER tokenization
72 FL_SUBCASE("parse2() A/B: Integer") {
73 const char* json_str = "42";
74 json result1 = json::parse(json_str);
75 json result2 = json::parse(json_str);
76
77 FL_CHECK(result1.is_number() == result2.is_number());
78 FL_CHECK(result1.as<i64>() == result2.as<i64>());
79 }
80
81 FL_SUBCASE("parse2() A/B: Float") {
82 const char* json_str = "3.14";
83 json result1 = json::parse(json_str);

Callers

nothing calls this directly

Calls 15

printfFunction · 0.85
back_inserterFunction · 0.85
maxFunction · 0.85
value_orMethod · 0.80
getDiameterMethod · 0.80
serializeMethod · 0.80
arrayClass · 0.50
stringClass · 0.50
absFunction · 0.50
jsonClass · 0.50
to_stringFunction · 0.50
is_objectMethod · 0.45

Tested by

no test coverage detected