| 24 | #include "fl/stl/strstream.h" |
| 25 | |
| 26 | FL_TEST_FILE(FL_FILEPATH) { |
| 27 | |
| 28 | using namespace fl; |
| 29 | |
| 30 | FL_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); |
nothing calls this directly
no test coverage detected