aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/skjson/src/SkJSONTest.cpp
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-06-14 12:50:43 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-14 18:13:19 +0000
commitfc792b8718cc30e9da62c9559b23c1baac3166bb (patch)
treebdef20bc660ce8c13d47b72fe1c31a7031ad5746 /modules/skjson/src/SkJSONTest.cpp
parent00f4df90229456d6cf68cdadc40d54bc3afe64f9 (diff)
[skjson] Size-constrained input API
Pass an explicit input size instead of requiring a C string. Thanks to mtklein's clever trick, this has no measurable perf impact. Change-Id: I64f210a9f653a78b05ab6b58fa34479504aa35ff Reviewed-on: https://skia-review.googlesource.com/134940 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'modules/skjson/src/SkJSONTest.cpp')
-rw-r--r--modules/skjson/src/SkJSONTest.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/skjson/src/SkJSONTest.cpp b/modules/skjson/src/SkJSONTest.cpp
index 6d4338cbbb..91ae497cf0 100644
--- a/modules/skjson/src/SkJSONTest.cpp
+++ b/modules/skjson/src/SkJSONTest.cpp
@@ -22,8 +22,14 @@ DEF_TEST(SkJSON_Parse, reporter) {
{ "" , nullptr },
{ "[" , nullptr },
{ "]" , nullptr },
+ { "[[]" , nullptr },
+ { "[]]" , nullptr },
+ { "[]f" , nullptr },
{ "{" , nullptr },
{ "}" , nullptr },
+ { "{{}" , nullptr },
+ { "{}}" , nullptr },
+ { "{}f" , nullptr },
{ "{]" , nullptr },
{ "[}" , nullptr },
{ "1" , nullptr },
@@ -51,7 +57,9 @@ DEF_TEST(SkJSON_Parse, reporter) {
{ "{ \"k\" : null \"k\" : 1 }", nullptr },
+ { "[]" , "[]" },
{ " \n\r\t [ \n\r\t ] \n\r\t " , "[]" },
+ { "[[]]" , "[[]]" },
{ "[ null ]" , "[null]" },
{ "[ true ]" , "[true]" },
{ "[ false ]" , "[false]" },
@@ -66,6 +74,7 @@ DEF_TEST(SkJSON_Parse, reporter) {
{ "[ \"123456789\" ]" , "[\"123456789\"]" },
{ "[ null , true, false,0,12.8 ]", "[null,true,false,0,12.8]" },
+ { "{}" , "{}" },
{ " \n\r\t { \n\r\t } \n\r\t " , "{}" },
{ "{ \"k\" : null }" , "{\"k\":null}" },
{ "{ \"k1\" : null, \"k2 \":0 }", "{\"k1\":null,\"k2 \":0}" },
@@ -89,7 +98,7 @@ DEF_TEST(SkJSON_Parse, reporter) {
};
for (const auto& tst : g_tests) {
- DOM dom(tst.in);
+ DOM dom(tst.in, strlen(tst.in));
const auto success = !dom.root().is<NullValue>();
REPORTER_ASSERT(reporter, success == (tst.out != nullptr));
if (!success) continue;
@@ -153,7 +162,7 @@ DEF_TEST(SkJSON_DOM_visit, reporter) {
\"k8\": { \"kk1\": 2, \"kk2\": false, \"kk1\": \"baz\" } \n\
}";
- DOM dom(json);
+ DOM dom(json, strlen(json));
const auto& jroot = dom.root().as<ObjectValue>();
REPORTER_ASSERT(reporter, jroot.is<ObjectValue>());