@@ -4494,3 +4494,71 @@ TEST(AlterSchema_lint_2019_09, empty_object_as_true_1) {
44944494
44954495 EXPECT_EQ (document, expected);
44964496}
4497+
4498+ TEST (AlterSchema_lint_2019_09, forbid_empty_enum_1) {
4499+ const sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
4500+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4501+ "title": "Example",
4502+ "description": "Example schema",
4503+ "examples": [1],
4504+ "enum": []
4505+ })JSON" );
4506+
4507+ LINT_WITHOUT_FIX (document, result, traces);
4508+
4509+ EXPECT_FALSE (result.first );
4510+ EXPECT_EQ (traces.size (), 1 );
4511+ EXPECT_LINT_TRACE (traces, 0 , " " , " forbid_empty_enum" ,
4512+ " enum must contain at least one value" , false );
4513+ }
4514+
4515+ TEST (AlterSchema_lint_2019_09, forbid_empty_enum_2) {
4516+ const sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
4517+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4518+ "title": "Example",
4519+ "description": "Example schema",
4520+ "examples": [1],
4521+ "enum": [1, 2]
4522+ })JSON" );
4523+
4524+ LINT_WITHOUT_FIX (document, result, traces);
4525+
4526+ EXPECT_TRUE (result.first );
4527+ EXPECT_EQ (traces.size (), 0 );
4528+ }
4529+
4530+ TEST (AlterSchema_lint_2019_09, forbid_empty_enum_3) {
4531+ const sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
4532+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4533+ "title": "Example",
4534+ "description": "Example schema",
4535+ "examples": [1],
4536+ "type": "string"
4537+ })JSON" );
4538+
4539+ LINT_WITHOUT_FIX (document, result, traces);
4540+
4541+ EXPECT_TRUE (result.first );
4542+ EXPECT_EQ (traces.size (), 0 );
4543+ }
4544+
4545+ TEST (AlterSchema_lint_2019_09, forbid_empty_enum_4) {
4546+ const sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
4547+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4548+ "title": "Example",
4549+ "description": "Example schema",
4550+ "examples": [{}],
4551+ "properties": {
4552+ "foo": {
4553+ "enum": []
4554+ }
4555+ }
4556+ })JSON" );
4557+
4558+ LINT_WITHOUT_FIX (document, result, traces);
4559+
4560+ EXPECT_FALSE (result.first );
4561+ EXPECT_EQ (traces.size (), 1 );
4562+ EXPECT_LINT_TRACE (traces, 0 , " /properties/foo" , " forbid_empty_enum" ,
4563+ " enum must contain at least one value" , false );
4564+ }
0 commit comments