23 static constexpr struct {
47 {
"[nulll]" ,
nullptr },
48 {
"[false2]",
nullptr },
49 {
"[true:]" ,
nullptr },
51 {
"[1 2]" ,
nullptr },
52 {
"[1,,2]" ,
nullptr },
53 {
"[1,2,]" ,
nullptr },
54 {
"[,1,2]" ,
nullptr },
56 {
"[ \"foo" ,
nullptr },
57 {
"[ \"fo\0o\" ]" ,
nullptr },
59 {
"{\"\":{}" ,
nullptr },
60 {
"{ null }" ,
nullptr },
61 {
"{ \"k\" : }" ,
nullptr },
62 {
"{ : null }" ,
nullptr },
63 {
"{ \"k\" : : null }" ,
nullptr },
64 {
"{ \"k\" : null , }" ,
nullptr },
65 {
"{ \"k\" : null \"k\" : 1 }",
nullptr },
67 {R
"zzz(["\)zzz" , nullptr},
68 {R
"zzz(["\])zzz" , nullptr},
69 {R
"zzz(["\"])zzz" , nullptr},
70 {R
"zzz(["\z"])zzz" , nullptr},
71 {R
"zzz(["\u"])zzz" , nullptr},
72 {R
"zzz(["\u0"])zzz" , nullptr},
73 {R
"zzz(["\u00"])zzz" , nullptr},
74 {R
"zzz(["\u000"])zzz", nullptr},
77 {
" \n\r\t [ \n\r\t ] \n\r\t " ,
"[]" },
79 {
"[ null ]" ,
"[null]" },
80 {
"[ true ]" ,
"[true]" },
81 {
"[ false ]" ,
"[false]" },
84 {
"[ 1.248 ]" ,
"[1.248]" },
85 {
"[ \"\" ]" ,
"[\"\"]" },
86 {
"[ \"foo{bar}baz\" ]" ,
"[\"foo{bar}baz\"]" },
87 {
"[ \" f o o \" ]" ,
"[\" f o o \"]" },
88 {
"[ \"123456\" ]" ,
"[\"123456\"]" },
89 {
"[ \"1234567\" ]" ,
"[\"1234567\"]" },
90 {
"[ \"12345678\" ]" ,
"[\"12345678\"]" },
91 {
"[ \"123456789\" ]" ,
"[\"123456789\"]" },
92 {
"[ null , true, false,0,12.8 ]",
"[null,true,false,0,12.8]" },
95 {
" \n\r\t { \n\r\t } \n\r\t " ,
"{}" },
96 {
"{ \"k\" : null }" ,
"{\"k\":null}" },
97 {
"{ \"foo{\" : \"bar}baz\" }" ,
"{\"foo{\":\"bar}baz\"}" },
98 {
"{ \"k1\" : null, \"k2 \":0 }",
"{\"k1\":null,\"k2 \":0}" },
99 {
"{ \"k1\" : null, \"k1\":0 }" ,
"{\"k1\":null,\"k1\":0}" },
101 {
"{ \"k1\" : null, \n\
105 { \"kk1\" : \"foo\" , \n\
106 \"kk2\" : \"bar\" , \n\
114 "{\"k1\":null,\"k2\":0,\"k3\":[true,"
115 "{\"kk1\":\"foo\",\"kk2\":\"bar\",\"kk3\":1.28,\"kk4\":[42]},\"boo\",null]}" },
117 {R
"zzz(["\""])zzz" , "[\"\"\"]"},
118 {R
"zzz(["\\"])zzz" , "[\"\\\"]"},
119 {R
"zzz(["\/"])zzz" , "[\"/\"]" },
120 {R
"zzz(["\b"])zzz" , "[\"\b\"]"},
121 {R
"zzz(["\f"])zzz" , "[\"\f\"]"},
122 {R
"zzz(["\n"])zzz" , "[\"\n\"]"},
123 {R
"zzz(["\r"])zzz" , "[\"\r\"]"},
124 {R
"zzz(["\t"])zzz" , "[\"\t\"]"},
125 {R
"zzz(["\u1234"])zzz", "[\"\u1234\"]"},
127 {R
"zzz(["foo\"bar"])zzz" , "[\"foo\"bar\"]"},
128 {R
"zzz(["foo\\bar"])zzz" , "[\"foo\\bar\"]"},
129 {R
"zzz(["foo\/bar"])zzz" , "[\"foo/bar\"]" },
130 {R
"zzz(["foo\bbar"])zzz" , "[\"foo\bbar\"]"},
131 {R
"zzz(["foo\fbar"])zzz" , "[\"foo\fbar\"]"},
132 {R
"zzz(["foo\nbar"])zzz" , "[\"foo\nbar\"]"},
133 {R
"zzz(["foo\rbar"])zzz" , "[\"foo\rbar\"]"},
134 {R
"zzz(["foo\tbar"])zzz" , "[\"foo\tbar\"]"},
135 {R
"zzz(["foo\u1234bar"])zzz", "[\"foo\u1234bar\"]"},
138 for (
const auto& tst : g_tests) {
139 DOM dom(tst.in, strlen(tst.in));
142 if (!success)
continue;
154template <
typename T,
typename VT>
159 const VT* cast_t = v;
176 const auto& vec = v.
as<
T>();
185 check_vector<StringValue>(
reporter, v,
s ? strlen(
s) : 0, !!
s);
193 static constexpr char json[] =
"{ \n\
200 \"k6b\": \"this string is long\", \n\
201 \"k7\": [ 1, true, \"bar\" ], \n\
202 \"k8\": { \"kk1\": 2, \"kk2\": false, \"kk1\": \"baz\" } \n\
205 DOM dom(json, strlen(json));
211 const auto& v = jroot[
"k1"];
214 check_primitive<bool, BoolValue>(
reporter, v,
false,
false);
215 check_primitive<float, NumberValue>(
reporter, v, 0,
false);
218 check_vector<ArrayValue >(
reporter, v, 0,
false);
219 check_vector<ObjectValue>(
reporter, v, 0,
false);
223 const auto& v = jroot[
"k2"];
226 check_primitive<bool, BoolValue>(
reporter, v,
false,
true);
227 check_primitive<float, NumberValue>(
reporter, v, 0,
false);
230 check_vector<ArrayValue >(
reporter, v, 0,
false);
231 check_vector<ObjectValue>(
reporter, v, 0,
false);
235 const auto& v = jroot[
"k3"];
238 check_primitive<bool, BoolValue>(
reporter, v,
true,
true);
239 check_primitive<float, NumberValue>(
reporter, v, 0,
false);
242 check_vector<ArrayValue >(
reporter, v, 0,
false);
243 check_vector<ObjectValue>(
reporter, v, 0,
false);
247 const auto& v = jroot[
"k4"];
250 check_primitive<bool, BoolValue>(
reporter, v,
false,
false);
251 check_primitive<float, NumberValue>(
reporter, v, 42,
true);
254 check_vector<ArrayValue >(
reporter, v, 0,
false);
255 check_vector<ObjectValue>(
reporter, v, 0,
false);
259 const auto& v = jroot[
"k5"];
262 check_primitive<bool, BoolValue>(
reporter, v,
false,
false);
263 check_primitive<float, NumberValue>(
reporter, v, .75f,
true);
266 check_vector<ArrayValue >(
reporter, v, 0,
false);
267 check_vector<ObjectValue>(
reporter, v, 0,
false);
271 const auto& v = jroot[
"k6"];
274 check_primitive<bool, BoolValue>(
reporter, v,
false,
false);
275 check_primitive<float, NumberValue>(
reporter, v, 0,
false);
278 check_vector<ArrayValue >(
reporter, v, 0,
false);
279 check_vector<ObjectValue>(
reporter, v, 0,
false);
283 const auto& v = jroot[
"k6b"];
286 check_primitive<bool, BoolValue>(
reporter, v,
false,
false);
287 check_primitive<float, NumberValue>(
reporter, v, 0,
false);
290 check_vector<ArrayValue >(
reporter, v, 0,
false);
291 check_vector<ObjectValue>(
reporter, v, 0,
false);
295 const auto& v = jroot[
"k7"];
298 check_primitive<bool, BoolValue>(
reporter, v,
false,
false);
299 check_primitive<float, NumberValue>(
reporter, v, 0,
false);
302 check_vector<ObjectValue>(
reporter, v, 0,
false);
304 check_vector<ArrayValue >(
reporter, v, 3,
true);
311 const auto& v = jroot[
"k8"];
314 check_primitive<bool, BoolValue>(
reporter, v,
false,
false);
315 check_primitive<float, NumberValue>(
reporter, v, 0,
false);
318 check_vector<ArrayValue >(
reporter, v, 0,
false);
320 check_vector<ObjectValue>(
reporter, v, 3,
true);
324 check_primitive<float, NumberValue>(
reporter, m0.fValue, 2,
true);
328 check_primitive<bool, BoolValue>(
reporter, m1.fValue,
false,
true);
356 check_value<NullValue>(
reporter, v0,
"null");
359 check_value<BoolValue>(
reporter, v1,
"true");
362 check_value<BoolValue>(
reporter,
v2,
"false");
365 check_value<NumberValue>(
reporter, v3,
"0");
371 check_value<NumberValue>(
reporter, v5,
"42.75");
374 check_value<StringValue>(
reporter, v6,
"\"\"");
377 check_value<StringValue>(
reporter, v7,
"\" foo \"");
379 const auto v8 =
StringValue(
" foo bar baz ", 13, alloc);
380 check_value<StringValue>(
reporter, v8,
"\" foo bar baz \"");
382 const auto v9 =
ArrayValue(
nullptr, 0, alloc);
383 check_value<ArrayValue>(
reporter, v9,
"[]");
385 const Value values0[] = { v0, v3, v9 };
387 check_value<ArrayValue>(
reporter, v10,
"[null,0,[]]");
390 check_value<ObjectValue>(
reporter, v11,
"{}");
392 const Member members0[] = {
398 check_value<ObjectValue>(
reporter, v12,
"{"
404 const Value values1[] = {
v2, v6, v12 };
406 check_value<ArrayValue>(
reporter, v13,
"["
416 const Member members1[] = {
422 check_value<ObjectValue>(
reporter, v14,
"{"
424 "\"key_01\":\" foo \","
438 static constexpr struct {
446 {
"00000000", 0, 0 },
447 {
"00000001", 1, 0 },
449 {
"0.001", 0.001f, 0 },
450 {
"1.001", 1.001f, 0 },
452 {
"0.000001" , 0.000001f, 0 },
453 {
"1.000001" , 1.000001f, 0 },
454 {
"1000.000001", 1000.000001f, 0 },
456 {
"0.0000000001" , 0.0000000001f, 0 },
457 {
"1.0000000001" , 1.0000000001f, 0 },
458 {
"1000.0000000001", 1000.0000000001f, 0 },
460 {
"20.001111814444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444473",
466 const DOM dom(json.c_str(), json.size());
478 const char* json = R
"({"foo": { "bar": { "baz": 100 }}})";
479 const DOM dom(json, strlen(json));
493 const char* json = R
"({"null": null, "num": 100})";
494 const DOM dom(json, strlen(json));
501 Value& w1 =
root.writable(
"null", alloc);
536 SkString(R
"({"null":42,"num":"foo","new":true,"newobj":{"newprop":-1}})"));
static const TestCase gTests[]
static void check_vector(skiatest::Reporter *reporter, const Value &v, size_t expected_size, bool is_vector)
static void check_string(skiatest::Reporter *reporter, const Value &v, const char *s)
DEF_TEST(JSON_Parse, reporter)
void check_value(skiatest::Reporter *reporter, const Value &v, const char *expected_string)
static void check_primitive(skiatest::Reporter *reporter, const Value &v, T pv, bool is_type)
static SkV4 v4(SkV3 v, SkScalar w)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
#define REPORTER_ASSERT(r, cond,...)
sk_sp< SkData > detachAsData()
Value & writable(const char *key, SkArenaAlloc &) const
const char * begin() const
std::string_view str() const
SkString toString() const
static const char * begin(const StringSlice &s)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::shared_ptr< const fml::Mapping > data