Skip to content

Commit 21755a8

Browse files
committed
Add optIdentifiers option
1 parent dbd46e9 commit 21755a8

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

test/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,17 @@ TEST(obj, get_obj_opt)
466466
}
467467
}
468468

469+
TEST(obj, identifiers)
470+
{
471+
ujson::Json json;
472+
auto& obj = json.parse(R"({foo: 1, "bar": 2})", 0, ujson::optIdentifiers).as_obj();
473+
EXPECT_EQ(obj.get_i32("foo"), 1);
474+
EXPECT_EQ(obj.get_i32("bar"), 2);
475+
EXPECT_THROW(json.parse(R"({foo : 1})"), ujson::ErrSyntax);
476+
EXPECT_THROW(json.parse(R"({foo%: 1})", 0, ujson::optIdentifiers), ujson::ErrSyntax);
477+
EXPECT_THROW(json.parse(R"({0foo: 1})", 0, ujson::optIdentifiers), ujson::ErrSyntax);
478+
}
479+
469480
TEST(obj, comments)
470481
{
471482
// Test with enabled comments:

ujson

0 commit comments

Comments
 (0)