Commit efc5dc9d authored by Erik Sjölund's avatar Erik Sjölund

Add JSON parser failure tests for whitespace consumption

parent 23f92989
......@@ -294,6 +294,15 @@ KJ_TEST("basic json decoding") {
KJ_EXPECT(root.getObject().size() == 0);
}
{
MallocMessageBuilder message;
auto root = message.initRoot<JsonValue>();
json.decodeRaw("\r\n\t {\r\n\t }\r\n\t ", root);
KJ_EXPECT(root.which() == JsonValue::OBJECT, (uint)root.which());
KJ_EXPECT(root.getObject().size() == 0);
}
{
MallocMessageBuilder message;
auto root = message.initRoot<JsonValue>();
......@@ -428,6 +437,8 @@ KJ_TEST("basic json decoding") {
KJ_EXPECT_THROW_MESSAGE("Invalid hex", json.decodeRaw(R"("\u12zz")", root));
KJ_EXPECT_THROW_MESSAGE("ends prematurely", json.decodeRaw("-", root));
KJ_EXPECT_THROW_MESSAGE("Unexpected input", json.decodeRaw("--", root));
KJ_EXPECT_THROW_MESSAGE("Unexpected input", json.decodeRaw("\f{}", root));
KJ_EXPECT_THROW_MESSAGE("Unexpected input", json.decodeRaw("{\v}", root));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment