Skip to content

Commit ec6066e

Browse files
committed
test(linter): add edge cases and draft3 coverage for forbid_empty_enum
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
1 parent b5d92d6 commit ec6066e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/alterschema/alterschema_lint_draft3_test.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,37 @@ TEST(AlterSchema_lint_draft3, enum_with_type_4) {
8181
EXPECT_EQ(document, expected);
8282
}
8383

84+
TEST(AlterSchema_lint_draft3, forbid_empty_enum_1) {
85+
sourcemeta::core::JSON document = sourcemeta::core::parse_json(R"JSON({
86+
"$schema": "http://json-schema.org/draft-03/schema#",
87+
"title": "Example",
88+
"description": "Example schema",
89+
"properties": {
90+
"foo": {
91+
"enum": []
92+
}
93+
}
94+
})JSON");
95+
const sourcemeta::core::JSON expected = sourcemeta::core::parse_json(R"JSON({
96+
"$schema": "http://json-schema.org/draft-03/schema#",
97+
"title": "Example",
98+
"description": "Example schema",
99+
"properties": {
100+
"foo": false
101+
}
102+
})JSON");
103+
104+
LINT_AND_FIX(document, result, traces);
105+
106+
EXPECT_TRUE(result.first);
107+
EXPECT_EQ(traces.size(), 1);
108+
EXPECT_LINT_TRACE(traces, 0, "/properties/foo", "forbid_empty_enum",
109+
"An empty `enum` validates nothing and is equivalent to "
110+
"`false`",
111+
true);
112+
EXPECT_EQ(document, expected);
113+
}
114+
84115
TEST(AlterSchema_lint_draft3, non_applicable_enum_validation_keywords_1) {
85116
sourcemeta::core::JSON document = sourcemeta::core::parse_json(R"JSON({
86117
"$schema": "http://json-schema.org/draft-03/schema#",

0 commit comments

Comments
 (0)