@@ -4579,6 +4579,11 @@ TEST(AlterSchema_lint_2019_09, forbid_empty_enum_4) {
45794579 }
45804580 }
45814581 })JSON" );
4582+
4583+ LINT_AND_FIX (document, result, traces);
4584+
4585+ EXPECT_TRUE (result.first );
4586+
45824587 const sourcemeta::core::JSON expected = sourcemeta::core::parse_json (R"JSON( {
45834588 "$schema": "https://json-schema.org/draft/2019-09/schema",
45844589 "title": "Example",
@@ -4591,18 +4596,12 @@ TEST(AlterSchema_lint_2019_09, forbid_empty_enum_4) {
45914596 }
45924597 })JSON" );
45934598
4594- LINT_AND_FIX (document, result, traces);
4595-
4596- EXPECT_TRUE (result.first );
45974599 EXPECT_EQ (document, expected);
45984600}
45994601
46004602TEST (AlterSchema_lint_2019_09, forbid_empty_enum_5) {
46014603 sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
46024604 "$schema": "https://json-schema.org/draft/2019-09/schema",
4603- "title": "Example",
4604- "description": "Example schema",
4605- "examples": [{}],
46064605 "$defs": {
46074606 "A": {
46084607 "enum": []
@@ -4613,16 +4612,13 @@ TEST(AlterSchema_lint_2019_09, forbid_empty_enum_5) {
46134612
46144613 LINT_AND_FIX (document, result, traces);
46154614
4616- EXPECT_TRUE (result.first );
4615+ EXPECT_FALSE (result.first );
46174616
46184617 const sourcemeta::core::JSON expected = sourcemeta::core::parse_json (R"JSON( {
46194618 "$schema": "https://json-schema.org/draft/2019-09/schema",
4620- "title": "Example",
4621- "description": "Example schema",
4622- "examples": [{}],
46234619 "$defs": {
46244620 "A": {
4625- "not ": true
4621+ "enum ": []
46264622 }
46274623 },
46284624 "$ref": "#/$defs/A"
@@ -4634,9 +4630,6 @@ TEST(AlterSchema_lint_2019_09, forbid_empty_enum_5) {
46344630TEST (AlterSchema_lint_2019_09, forbid_empty_enum_6) {
46354631 sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
46364632 "$schema": "https://json-schema.org/draft/2019-09/schema",
4637- "title": "Example",
4638- "description": "Example schema",
4639- "examples": [{}],
46404633 "$defs": {
46414634 "A": {
46424635 "enum": [],
@@ -4650,19 +4643,16 @@ TEST(AlterSchema_lint_2019_09, forbid_empty_enum_6) {
46504643
46514644 LINT_AND_FIX (document, result, traces);
46524645
4653- EXPECT_TRUE (result.first );
4646+ EXPECT_FALSE (result.first );
46544647
46554648 const sourcemeta::core::JSON expected = sourcemeta::core::parse_json (R"JSON( {
46564649 "$schema": "https://json-schema.org/draft/2019-09/schema",
4657- "title": "Example",
4658- "description": "Example schema",
4659- "examples": [{}],
46604650 "$defs": {
46614651 "A": {
4652+ "enum": [],
46624653 "$defs": {
46634654 "inner": { "type": "string" }
4664- },
4665- "not": true
4655+ }
46664656 }
46674657 },
46684658 "$ref": "#/$defs/A/$defs/inner"
@@ -4674,9 +4664,6 @@ TEST(AlterSchema_lint_2019_09, forbid_empty_enum_6) {
46744664TEST (AlterSchema_lint_2019_09, forbid_empty_enum_7) {
46754665 sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
46764666 "$schema": "https://json-schema.org/draft/2019-09/schema",
4677- "title": "Example",
4678- "description": "Example schema",
4679- "examples": [{}],
46804667 "$defs": {
46814668 "A": {
46824669 "$id": "https://example.com/schemas/A",
@@ -4688,17 +4675,14 @@ TEST(AlterSchema_lint_2019_09, forbid_empty_enum_7) {
46884675
46894676 LINT_AND_FIX (document, result, traces);
46904677
4691- EXPECT_TRUE (result.first );
4678+ EXPECT_FALSE (result.first );
46924679
46934680 const sourcemeta::core::JSON expected = sourcemeta::core::parse_json (R"JSON( {
46944681 "$schema": "https://json-schema.org/draft/2019-09/schema",
4695- "title": "Example",
4696- "description": "Example schema",
4697- "examples": [{}],
46984682 "$defs": {
46994683 "A": {
47004684 "$id": "https://example.com/schemas/A",
4701- "not ": true
4685+ "enum ": []
47024686 }
47034687 },
47044688 "$ref": "https://example.com/schemas/A"
@@ -4740,3 +4724,53 @@ TEST(AlterSchema_lint_2019_09, forbid_empty_enum_8) {
47404724
47414725 EXPECT_EQ (document, expected);
47424726}
4727+
4728+ TEST (AlterSchema_lint_2019_09, forbid_empty_enum_9) {
4729+ sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
4730+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4731+ "$defs": {
4732+ "A": {
4733+ "enum": [],
4734+ "additionalProperties": { "type": "string" }
4735+ }
4736+ },
4737+ "$ref": "#/$defs/A/additionalProperties"
4738+ })JSON" );
4739+
4740+ LINT_AND_FIX (document, result, traces);
4741+
4742+ EXPECT_FALSE (result.first );
4743+
4744+ const sourcemeta::core::JSON expected = sourcemeta::core::parse_json (R"JSON( {
4745+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4746+ "$defs": {
4747+ "A": {
4748+ "enum": [],
4749+ "additionalProperties": { "type": "string" }
4750+ }
4751+ },
4752+ "$ref": "#/$defs/A/additionalProperties"
4753+ })JSON" );
4754+
4755+ EXPECT_EQ (document, expected);
4756+ }
4757+
4758+ TEST (AlterSchema_lint_2019_09, forbid_empty_enum_10) {
4759+ sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
4760+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4761+ "not": { "type": "string" },
4762+ "enum": []
4763+ })JSON" );
4764+
4765+ LINT_AND_FIX (document, result, traces);
4766+
4767+ EXPECT_FALSE (result.first );
4768+
4769+ const sourcemeta::core::JSON expected = sourcemeta::core::parse_json (R"JSON( {
4770+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4771+ "not": { "type": "string" },
4772+ "enum": []
4773+ })JSON" );
4774+
4775+ EXPECT_EQ (document, expected);
4776+ }
0 commit comments