22 {
23 static constexpr struct {
24 const char* in;
26 } g_tests[] = {
27 { "" , nullptr },
28 { "[" , nullptr },
29 { "]" , nullptr },
30 { "[[]" , nullptr },
31 { "[]]" , nullptr },
32 { "[]f" , nullptr },
33 { "{" , nullptr },
34 { "}" , nullptr },
35 { "{{}" , nullptr },
36 { "{}}" , nullptr },
37 { "{}f" , nullptr },
38 { "{]" , nullptr },
39 { "[}" , nullptr },
40 { "{\"}" , nullptr },
41 { "[\"]" , nullptr },
42 { "1" , nullptr },
43 { "true" , nullptr },
44 { "false", nullptr },
45 { "null" , nullptr },
46
47 { "[nulll]" , nullptr },
48 { "[false2]", nullptr },
49 { "[true:]" , nullptr },
50
51 { "[1 2]" , nullptr },
52 { "[1,,2]" , nullptr },
53 { "[1,2,]" , nullptr },
54 { "[,1,2]" , nullptr },
55
56 { "[ \"foo" , nullptr },
57 { "[ \"fo\0o\" ]" , nullptr },
58
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 },
66
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},
75
76 { "[]" , "[]" },
77 { " \n\r\t [ \n\r\t ] \n\r\t " , "[]" },
78 { "[[]]" , "[[]]" },
79 { "[ null ]" , "[null]" },
80 { "[ true ]" , "[true]" },
81 { "[ false ]" , "[false]" },
82 { "[ 0 ]" , "[0]" },
83 { "[ 1 ]" , "[1]" },
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]" },
93
94 { "{}" , "{}" },
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}" },
100
101 { "{ \"k1\" : null, \n\
102 \"k2\" : 0, \n\
103 \"k3\" : [ \n\
104 true, \r\n\
105 { \"kk1\" : \"foo\" , \n\
106 \"kk2\" : \"bar\" , \n\
107 \"kk3\" : 1.28 , \n\
108 \"kk4\" : [ 42 ] \n\
109 } , \n\
110 \"boo\" , \n\
111 null \n\
112 ] \n\
113 }",
114 "{\"k1\":null,\"k2\":0,\"k3\":[true,"
115 "{\"kk1\":\"foo\",\"kk2\":\"bar\",\"kk3\":1.28,\"kk4\":[42]},\"boo\",null]}" },
116
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\"]"},
126
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\"]"},
136 };
137
138 for (const auto& tst : g_tests) {
139 DOM dom(tst.in, strlen(tst.in));
142 if (!success) continue;
143
147
150 }
151
152}
sk_sp< SkData > detachAsData()
std::shared_ptr< const fml::Mapping > data