Skip to content

Commit 2e964c1

Browse files
committed
[WIP] Fix id_ values unexpectedly taking higher precedence
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent eabdb0f commit 2e964c1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/jsonschema/jsonschema_format_test.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ TEST(JSONSchema_format, example_3) {
6565
})JSON");
6666
}
6767

68+
TEST(JSONSchema_format, example_4) {
69+
const sourcemeta::core::JSON document = sourcemeta::core::parse_json(R"JSON({
70+
"$schema": "https://json-schema.org/draft/2020-12/schema",
71+
"properties": {
72+
"abc": true,
73+
"id_key": false
74+
}
75+
})JSON");
76+
77+
std::ostringstream stream;
78+
sourcemeta::core::prettify(document, stream,
79+
sourcemeta::core::schema_format_compare);
80+
81+
// `id_key` must go _after_ `abc` given alphabetic ordering
82+
EXPECT_EQ(stream.str(), R"JSON({
83+
"$schema": "https://json-schema.org/draft/2020-12/schema",
84+
"properties": {
85+
"abc": true,
86+
"id_key": false
87+
}
88+
})JSON");
89+
}
90+
6891
TEST(JSONSchema_format, compare_known_vs_unknown) {
6992
EXPECT_TRUE(sourcemeta::core::schema_format_compare("$id", "foo"));
7093
EXPECT_FALSE(sourcemeta::core::schema_format_compare("foo", "$id"));

0 commit comments

Comments
 (0)