diff --git a/buildSrc/src/main/kotlin/GenerateJsonTestSuiteTask.kt b/buildSrc/src/main/kotlin/GenerateJsonTestSuiteTask.kt index 908de099..81380231 100644 --- a/buildSrc/src/main/kotlin/GenerateJsonTestSuiteTask.kt +++ b/buildSrc/src/main/kotlin/GenerateJsonTestSuiteTask.kt @@ -47,10 +47,9 @@ open class GenerateJsonTestSuiteTask : DefaultTask() { } } - @OutputFiles - fun getGeneratedTestPath(): List { - return listOf(jsonTestSuiteGenerator.generatedJsonSuiteTestPath.toFile(), - jsonTestSuiteGenerator.generatedSchemaSuiteTestPath.toFile()) + @OutputDirectory + fun getGeneratedClassDirectory(): File { + return jsonTestSuiteGenerator.testClassPackageDir.toFile() } @TaskAction @@ -60,7 +59,6 @@ open class GenerateJsonTestSuiteTask : DefaultTask() { @Internal override fun getDescription(): String? { - return "Generates ${jsonTestSuiteGenerator.generatedJsonSuiteTestPath} and " + - "${jsonTestSuiteGenerator.generatedSchemaSuiteTestPath}" + return "Generates the JSON Test files in ${jsonTestSuiteGenerator.testClassPackageDir}" } -} \ No newline at end of file +} diff --git a/buildSrc/src/main/kotlin/org/kson/jsonsuite/JsonTestSuiteGenerator.kt b/buildSrc/src/main/kotlin/org/kson/jsonsuite/JsonTestSuiteGenerator.kt index 974aec41..e2bfc16b 100644 --- a/buildSrc/src/main/kotlin/org/kson/jsonsuite/JsonTestSuiteGenerator.kt +++ b/buildSrc/src/main/kotlin/org/kson/jsonsuite/JsonTestSuiteGenerator.kt @@ -32,11 +32,11 @@ class JsonTestSuiteGenerator( private val classPackage: String ) { val jsonTestSourceFilesDir: Path = jsonSuiteGitCheckout.checkoutDir.toPath().resolve("test_parsing") - private val testClassPackageDir = sourceRootDir.resolve(classPackage.replace('.', '/')) + val testClassPackageDir = sourceRootDir.resolve(classPackage.replace('.', '/')) val generatedJsonSuiteTestPath: Path = testClassPackageDir.resolve("JsonSuiteTest.kt") - val generatedSchemaSuiteTestPath: Path = - testClassPackageDir.resolve("SchemaSuiteTest.kt") + val draft7TestClassName = "SchemaDraft7SuiteTest" + val draft2020_12ClassName = "SchemaDraft2020_12SuiteTest" fun generate() { testClassPackageDir.toFile().mkdirs() @@ -46,10 +46,30 @@ class JsonTestSuiteGenerator( .writeText(generateJsonSuiteTestClass(this.javaClass.name, classPackage, jsonTestDataList)) val schemaTestSourceFilesDir: Path = schemaSuiteGitCheckout.checkoutDir.toPath().resolve("tests") - val schemaTestDataList = SchemaTestDataLoader(schemaTestSourceFilesDir, projectRoot).loadTestData() - generatedSchemaSuiteTestPath.toFile() - .writeText(generateSchemaSuiteTestClasses(this.javaClass.name, classPackage, schemaTestDataList)) + val schemaDraft7TestDataList = SchemaTestDataLoader(schemaTestSourceFilesDir, "draft7", projectRoot).loadTestData() + schemaDraft7TestDataList.forEach { schemaTestFileData -> + val testClassName = draft7TestClassName + "_" + schemaTestFileData.testFileName.replace("-", "_") + val testFileName = testClassPackageDir.resolve("$testClassName.kt") + testFileName.toFile().writeText( + generateSchemaSuiteTestClass( + this.javaClass.name, + classPackage, + testClassName, + schemaTestFileData)) + } + + val schemaDraft2020_12TestDataList = SchemaTestDataLoader(schemaTestSourceFilesDir, "draft2020-12", projectRoot).loadTestData() + schemaDraft2020_12TestDataList.forEach { schemaTestFileData -> + val testClassName = draft2020_12ClassName + "_" + schemaTestFileData.testFileName.replace("-", "_") + val testFileName = testClassPackageDir.resolve("$testClassName.kt") + testFileName.toFile().writeText( + generateSchemaSuiteTestClass( + this.javaClass.name, + classPackage, + testClassName, + schemaTestFileData)) + } } } @@ -108,9 +128,10 @@ private class JsonTestData( private data class SchemaTestGroup(val description: String, val comment: String? = null, val schema: JsonElement, - val tests: List) + val tests: List, + val specification: JsonElement? = null) @Serializable -private data class SchemaTestSpec(val description: String, val data: JsonElement, val valid: Boolean) +private data class SchemaTestSpec(val description: String, val comment: String? = null, val data: JsonElement, val valid: Boolean) /** * The test data we parse out of the test files provided by [JSON-Schema-Test-Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite) @@ -224,11 +245,13 @@ private fun assertParseResult( """ } -private fun generateSchemaSuiteTestClasses( +private fun generateSchemaSuiteTestClass( generatorClassName: String, testClassPackage: String, - tests: List + testClassName: String, + tests: SchemaTestData ): String { + var testNum = 1 return """package $testClassPackage import org.kson.schema.JsonSchemaTest @@ -241,29 +264,31 @@ import kotlin.test.Test * TODO expand the testing here as we implement Json Schema support by * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] */ -@Suppress("UNREACHABLE_CODE") // unreachable code is okay here until we complete the above TODO -class SchemaSuiteTest : JsonSchemaTest { +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class $testClassName : JsonSchemaTest { -${ tests.joinToString("\n") { +${ run { val theTests = ArrayList() - for (schema in it.schemaTestGroups) { + for (schema in tests.schemaTestGroups) { val schemaComment = if (schema.comment != null) "// " + schema.comment else "" for (test in schema.tests) { - // construct a legal and unique name for this test - val schemaTestName = "${formatForTestName(it.testFileName)}_${formatForTestName(schema.description)}_${formatForTestName(test.description)}" + // construct a unique ID for this test + val schemaTestId = "${tests.testFileName}::${schema.description}::${test.description}" val testCode = """ | /** - | * Test generated by [$generatorClassName] based on `${it.filePathFromProjectRoot}`: + | * Test generated by [$generatorClassName] based on `${tests.filePathFromProjectRoot}`: | * "${schema.description} -> ${test.description}" + | * + | * Test ID: "$schemaTestId" | */ | @Test - | fun $schemaTestName() {${ - if (schemaTestSuiteExclusions().contains(schemaTestName)) { + | fun jsonSchemaSuiteTest_${testNum++}() {${ + if (schemaTestSuiteExclusions().contains(schemaTestId)) { """ | | /** - | * TODO implement the schema functionality under test here and remove this exclusion from - | * "$schemaTestName" from + | * TODO implement the schema functionality under test here and remove the exclusion entry + | * "$schemaTestId" from | * [org.kson.jsonsuite.schemaTestSuiteExclusions] | */ | return""".trimMargin() @@ -280,7 +305,7 @@ ${ tests.joinToString("\n") { | ${formatForTest(schema.schema, " ")} | ${"\"\"\""}, | ${test.valid}, - | ${"\"\"\""}${formatForTest(schema.description)} -> ${formatForTest(test.description)}${"\"\"\""}) + | ${"\"\"\""} schemaTestId: "${schemaTestId.replace("$", "\${'$'}")}" ${"\"\"\""}) | } """.trimMargin() theTests.add(testCode) @@ -344,8 +369,8 @@ private class JsonTestDataLoader(private val testDefinitionFilesDir: Path, priva * @param projectRoot the [Path] on disk of the project containing [testDefinitionFilesDir] - used to write out * machine-independent file paths relative to the project root */ -private class SchemaTestDataLoader(private val testDefinitionFilesDir: Path, private val projectRoot: Path) { - private val draftSevenTestSourceFiles = (testDefinitionFilesDir.resolve("draft7").toFile().listFiles() +private class SchemaTestDataLoader(private val testDefinitionFilesDir: Path, draftTestFolderName: String, private val projectRoot: Path) { + private val draftSevenTestSourceFiles = (testDefinitionFilesDir.resolve(draftTestFolderName).toFile().listFiles() ?: throw RuntimeException("Should have ensured these files existed before calling this loader")) fun loadTestData(): List { @@ -378,16 +403,3 @@ private fun formatForTest(jsonElement: JsonElement, indent: String): String { private fun formatForTest(string: String): String { return string.replace("$", "\${'$'}") } - -private fun formatForTestName(string: String): String { - return formatForTest(string) - .replace(Regex("[.,()+\\-:'\\[\\]{}\"$/*=]"), "_") - .split(" ") - .mapIndexed { index, s -> - if (index > 0) { - s.replaceFirstChar { it.uppercase() } - } else { - s.replaceFirstChar { it.lowercase() } - } - }.joinToString("") -} diff --git a/buildSrc/src/main/kotlin/org/kson/jsonsuite/SchemaTestSuiteExclusionsList.kt b/buildSrc/src/main/kotlin/org/kson/jsonsuite/SchemaTestSuiteExclusionsList.kt index 238bc316..c1f14145 100644 --- a/buildSrc/src/main/kotlin/org/kson/jsonsuite/SchemaTestSuiteExclusionsList.kt +++ b/buildSrc/src/main/kotlin/org/kson/jsonsuite/SchemaTestSuiteExclusionsList.kt @@ -13,29 +13,244 @@ fun schemaTestSuiteExclusions() = setOf( * * We test bundled versions of these test in [org.kson.schema.JsonSchemaTestBundledRemotes]. */ - "refRemote_baseURIChange_baseURIChangeRefInvalid", - "refRemote_baseURIChange_baseURIChangeRefValid", - "refRemote_baseURIChange_ChangeFolder_numberIsValid", - "refRemote_baseURIChange_ChangeFolder_stringIsInvalid", - "refRemote_baseURIChange_ChangeFolderInSubschema_numberIsValid", - "refRemote_baseURIChange_ChangeFolderInSubschema_stringIsInvalid", - "refRemote_fragmentWithinRemoteRef_remoteFragmentInvalid", - "refRemote_fragmentWithinRemoteRef_remoteFragmentValid", - "refRemote_location_independentIdentifierInRemoteRef_integerIsValid", - "refRemote_location_independentIdentifierInRemoteRef_stringIsInvalid", - "refRemote_refWithinRemoteRef_refWithinRefInvalid", - "refRemote_refWithinRemoteRef_refWithinRefValid", - "refRemote_remoteRef_remoteRefInvalid", - "refRemote_remoteRef_remoteRefValid", - "refRemote_remoteRefWithRefToDefinitions_invalid", - "refRemote_remoteRefWithRefToDefinitions_valid", - "refRemote_retrievedNestedRefsResolveRelativeToTheirURINot______id_numberIsInvalid", - "refRemote_retrievedNestedRefsResolveRelativeToTheirURINot______id_stringIsValid", - "refRemote_rootRefInRemoteRef_nullIsValid", - "refRemote_rootRefInRemoteRef_objectIsInvalid", - "refRemote_rootRefInRemoteRef_stringIsValid", - "ref_remoteRef_ContainingRefsItself_remoteRefInvalid", - "ref_remoteRef_ContainingRefsItself_remoteRefValid", - "refRemote_______refTo______refFindsLocation_independent______id_non_numberIsInvalid", - "refRemote_______refTo______refFindsLocation_independent______id_numberIsValid", + "refRemote::remote ref::remote ref valid", + "refRemote::remote ref::remote ref invalid", + "refRemote::fragment within remote ref::remote fragment valid", + "refRemote::fragment within remote ref::remote fragment invalid", + "refRemote::ref within remote ref::ref within ref valid", + "refRemote::ref within remote ref::ref within ref invalid", + "refRemote::base URI change::base URI change ref valid", + "refRemote::base URI change::base URI change ref invalid", + "refRemote::base URI change - change folder::number is valid", + "refRemote::base URI change - change folder::string is invalid", + "refRemote::base URI change - change folder in subschema::number is valid", + "refRemote::base URI change - change folder in subschema::string is invalid", + "refRemote::root ref in remote ref::string is valid", + "refRemote::root ref in remote ref::null is valid", + "refRemote::root ref in remote ref::object is invalid", + "refRemote::remote ref with ref to definitions::invalid", + "refRemote::remote ref with ref to definitions::valid", + "refRemote::Location-independent identifier in remote ref::integer is valid", + "refRemote::Location-independent identifier in remote ref::string is invalid", + "refRemote::retrieved nested refs resolve relative to their URI not ${'$'}id::number is invalid", + "refRemote::retrieved nested refs resolve relative to their URI not ${'$'}id::string is valid", + "refRemote::${'$'}ref to ${'$'}ref finds location-independent ${'$'}id::number is valid", + "refRemote::${'$'}ref to ${'$'}ref finds location-independent ${'$'}id::non-number is invalid", + + /** + * These excludes are for tests that are currently failing in the Schema 2020-12 test suite. + * These tests need further investigation and implementation work. + */ + + // anchor tests + "anchor::Location-independent identifier with absolute URI::match", + "anchor::Location-independent identifier with absolute URI::mismatch", + "anchor::Location-independent identifier with base URI change in subschema::match", + "anchor::Location-independent identifier with base URI change in subschema::mismatch", + "anchor::Location-independent identifier::match", + "anchor::Location-independent identifier::mismatch", + "anchor::same ${'$'}anchor with different base uri::${'$'}ref does not resolve to /${'$'}defs/A/allOf/0", + "anchor::same ${'$'}anchor with different base uri::${'$'}ref resolves to /${'$'}defs/A/allOf/1", + + // defs tests + "defs::validate definition against metaschema::invalid definition schema", + "defs::validate definition against metaschema::valid definition schema", + + // dependentRequired tests + "dependentRequired::dependencies with escaped characters::CRLF missing dependent", + "dependentRequired::dependencies with escaped characters::quoted quotes missing dependent", + "dependentRequired::multiple dependents required::missing both dependencies", + "dependentRequired::multiple dependents required::missing dependency", + "dependentRequired::multiple dependents required::missing other dependency", + "dependentRequired::single dependency::missing dependency", + + // dependentSchemas tests + "dependentSchemas::boolean subschemas::object with both properties is invalid", + "dependentSchemas::boolean subschemas::object with property having schema false is invalid", + "dependentSchemas::dependencies with escaped characters::quoted quote", + "dependentSchemas::dependencies with escaped characters::quoted quote invalid under dependent schema", + "dependentSchemas::dependencies with escaped characters::quoted tab invalid under dependent schema", + "dependentSchemas::dependent subschema incompatible with root::matches both", + "dependentSchemas::dependent subschema incompatible with root::matches root", + "dependentSchemas::single dependency::wrong type", + "dependentSchemas::single dependency::wrong type both", + "dependentSchemas::single dependency::wrong type other", + + // dynamicRef tests + "dynamicRef::${'$'}dynamicRef points to a boolean schema::follow ${'$'}dynamicRef to a false schema", + "dynamicRef::${'$'}dynamicRef skips over intermediate resources - direct reference::string property fails", + "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}defs first::correct extended schema", + "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}defs first::incorrect extended schema", + "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}defs first::incorrect parent schema", + "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}ref first::correct extended schema", + "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}ref first::incorrect extended schema", + "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}ref first::incorrect parent schema", + "dynamicRef::${'$'}ref to ${'$'}dynamicRef finds detached ${'$'}dynamicAnchor::non-number is invalid", + "dynamicRef::${'$'}ref to ${'$'}dynamicRef finds detached ${'$'}dynamicAnchor::number is valid", + "dynamicRef::A ${'$'}dynamicRef resolves to the first ${'$'}dynamicAnchor still in scope that is encountered when the schema is evaluated::An array containing non-strings is invalid", + "dynamicRef::A ${'$'}dynamicRef that initially resolves to a schema with a matching ${'$'}dynamicAnchor resolves to the first ${'$'}dynamicAnchor in the dynamic scope::The recursive part is not valid against the root", + "dynamicRef::A ${'$'}dynamicRef to a ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array containing non-strings is invalid", + "dynamicRef::A ${'$'}dynamicRef to an ${'$'}anchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array containing non-strings is invalid", + "dynamicRef::A ${'$'}dynamicRef with intermediate scopes that don't include a matching ${'$'}dynamicAnchor does not affect dynamic scope resolution::An array containing non-strings is invalid", + "dynamicRef::A ${'$'}dynamicRef without anchor in fragment behaves identical to ${'$'}ref::An array of strings is invalid", + "dynamicRef::A ${'$'}ref to a ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array containing non-strings is invalid", + "dynamicRef::A ${'$'}ref to a ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array of strings is valid", + "dynamicRef::after leaving a dynamic scope, it is not used by a ${'$'}dynamicRef::first_scope is not in dynamic scope for the ${'$'}dynamicRef", + "dynamicRef::after leaving a dynamic scope, it is not used by a ${'$'}dynamicRef::string matches /${'$'}defs/thingy, but the ${'$'}dynamicRef does not stop here", + "dynamicRef::multiple dynamic paths to the ${'$'}dynamicRef keyword::number list with string values", + "dynamicRef::multiple dynamic paths to the ${'$'}dynamicRef keyword::string list with number values", + "dynamicRef::strict-tree schema, guards against misspelled properties::instance with correct field", + "dynamicRef::strict-tree schema, guards against misspelled properties::instance with misspelled field", + "dynamicRef::tests for implementation dynamic anchor and reference link::correct extended schema", + "dynamicRef::tests for implementation dynamic anchor and reference link::incorrect extended schema", + "dynamicRef::tests for implementation dynamic anchor and reference link::incorrect parent schema", + + // items tests + "items::items and subitems::fewer items is valid", + "items::items and subitems::valid items", + "items::items with heterogeneous array::valid instance", + "items::prefixItems validation adjusts the starting index for items::valid items", + "items::prefixItems with no additional items allowed::equal number of items present", + "items::prefixItems with no additional items allowed::fewer number of items present (1)", + "items::prefixItems with no additional items allowed::fewer number of items present (2)", + + // maxContains tests + "maxContains::maxContains with contains, value with a decimal::too many elements match, invalid maxContains", + "maxContains::maxContains with contains::all elements match, invalid maxContains", + "maxContains::maxContains with contains::some elements match, invalid maxContains", + "maxContains::minContains < maxContains::minContains < maxContains < actual", + + // minContains tests + "minContains::maxContains < minContains::invalid maxContains", + "minContains::maxContains < minContains::invalid maxContains and minContains", + "minContains::maxContains < minContains::invalid minContains", + "minContains::maxContains = minContains::all elements match, invalid maxContains", + "minContains::maxContains = minContains::all elements match, invalid minContains", + "minContains::minContains = 0 with maxContains::empty data", + "minContains::minContains = 0 with maxContains::too many", + "minContains::minContains = 0::empty data", + "minContains::minContains = 0::minContains = 0 makes contains always pass", + "minContains::minContains=2 with contains with a decimal value::one element matches, invalid minContains", + "minContains::minContains=2 with contains::all elements match, invalid minContains", + "minContains::minContains=2 with contains::some elements match, invalid minContains", + + // not tests + "not::collect annotations inside a 'not', even if collection is disabled::unevaluated property", + + // prefixItems tests + "prefixItems::a schema given for prefixItems::wrong types", + "prefixItems::prefixItems with boolean schemas::array with two items is invalid", + + // ref tests + "ref::order of evaluation: ${'$'}id and ${'$'}anchor and ${'$'}ref::data is invalid against first definition", + "ref::order of evaluation: ${'$'}id and ${'$'}anchor and ${'$'}ref::data is valid against first definition", + "ref::ref applies alongside sibling keywords::ref valid, maxItems invalid", + "ref::ref creates new scope when adjacent to keywords::referenced subschema doesn't see annotations from properties", + "ref::refs with relative uris and defs::invalid on inner field", + "ref::refs with relative uris and defs::invalid on outer field", + "ref::relative pointer ref to array::mismatch array", + "ref::relative refs with absolute uris and defs::invalid on inner field", + "ref::relative refs with absolute uris and defs::invalid on outer field", + "ref::remote ref, containing refs itself::remote ref invalid", + "ref::remote ref, containing refs itself::remote ref valid", + "ref::URN base URI with URN and anchor ref::a non-string is invalid", + "ref::URN base URI with URN and anchor ref::a string is valid", + "ref::URN ref with nested pointer ref::a non-string is invalid", + + // refRemote tests (additional) + "refRemote::${'$'}ref to ${'$'}ref finds detached ${'$'}anchor::non-number is invalid", + "refRemote::${'$'}ref to ${'$'}ref finds detached ${'$'}anchor::number is valid", + "refRemote::anchor within remote ref::remote anchor invalid", + "refRemote::anchor within remote ref::remote anchor valid", + "refRemote::remote HTTP ref with different ${'$'}id::number is invalid", + "refRemote::remote HTTP ref with different ${'$'}id::string is valid", + "refRemote::remote HTTP ref with different URN ${'$'}id::number is invalid", + "refRemote::remote HTTP ref with different URN ${'$'}id::string is valid", + "refRemote::remote HTTP ref with nested absolute ref::number is invalid", + "refRemote::remote HTTP ref with nested absolute ref::string is valid", + "refRemote::remote ref with ref to defs::invalid", + "refRemote::remote ref with ref to defs::valid", + + // unevaluatedItems tests + "unevaluatedItems::item is evaluated in an uncle schema to unevaluatedItems::uncle keyword evaluation is not significant", + "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only a's and c's are invalid", + "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only b's and c's are invalid", + "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only b's are invalid", + "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only c's are invalid", + "unevaluatedItems::unevaluatedItems as schema::with invalid unevaluated items", + "unevaluatedItems::unevaluatedItems before ${'$'}ref::with unevaluated items", + "unevaluatedItems::unevaluatedItems can see annotations from if without then and else::invalid in case if is evaluated", + "unevaluatedItems::unevaluatedItems can't see inside cousins::always fails", + "unevaluatedItems::unevaluatedItems depends on adjacent contains::contains passes, second item is not evaluated", + "unevaluatedItems::unevaluatedItems depends on multiple nested contains::7 not evaluated, fails unevaluatedItems", + "unevaluatedItems::unevaluatedItems false::with unevaluated items", + "unevaluatedItems::unevaluatedItems with ${'$'}dynamicRef::with unevaluated items", + "unevaluatedItems::unevaluatedItems with ${'$'}ref::with unevaluated items", + "unevaluatedItems::unevaluatedItems with anyOf::when one schema matches and has unevaluated items", + "unevaluatedItems::unevaluatedItems with anyOf::when two schemas match and has unevaluated items", + "unevaluatedItems::unevaluatedItems with boolean schemas::with unevaluated items", + "unevaluatedItems::unevaluatedItems with if/then/else::when if doesn't match and it has unevaluated items", + "unevaluatedItems::unevaluatedItems with if/then/else::when if matches and it has unevaluated items", + "unevaluatedItems::unevaluatedItems with nested items::with invalid additional item", + "unevaluatedItems::unevaluatedItems with nested tuple::with unevaluated items", + "unevaluatedItems::unevaluatedItems with not::with unevaluated items", + "unevaluatedItems::unevaluatedItems with oneOf::with no unevaluated items", + "unevaluatedItems::unevaluatedItems with tuple::with unevaluated items", + + // unevaluatedProperties tests + "unevaluatedProperties::cousin unevaluatedProperties, true and false, false with properties::with nested unevaluated properties", + "unevaluatedProperties::cousin unevaluatedProperties, true and false, true with properties::with nested unevaluated properties", + "unevaluatedProperties::cousin unevaluatedProperties, true and false, true with properties::with no nested unevaluated properties", + "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties doesn't consider dependentSchemas", + "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties doesn't see bar when foo2 is absent", + "unevaluatedProperties::dynamic evalation inside nested refs::xx + foo is invalid", + "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::base case: both properties present", + "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::in place applicator siblings, foo is missing", + "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::base case: both properties present", + "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::in place applicator siblings, bar is missing", + "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties inside::with nested unevaluated properties", + "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties outside::with nested unevaluated properties", + "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties outside::with no nested unevaluated properties", + "unevaluatedProperties::property is evaluated in an uncle schema to unevaluatedProperties::uncle keyword evaluation is not significant", + "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 1st level is invalid", + "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 2nd level is invalid", + "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 3rd level is invalid", + "unevaluatedProperties::unevaluatedProperties before ${'$'}ref::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties can see annotations from if without then and else::invalid in case if is evaluated", + "unevaluatedProperties::unevaluatedProperties can't see inside cousins (reverse order)::always fails", + "unevaluatedProperties::unevaluatedProperties can't see inside cousins::always fails", + "unevaluatedProperties::unevaluatedProperties false::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties not affected by propertyNames::string property is invalid", + "unevaluatedProperties::unevaluatedProperties schema::with invalid unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with ${'$'}dynamicRef::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with ${'$'}ref::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with adjacent patternProperties::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with adjacent properties::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with anyOf::when one matches and has unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with anyOf::when two match and has unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with boolean schemas::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with dependentSchemas::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is false and has no unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is false and has unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is true and has unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is false and has unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is true and has no unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is true and has unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is false and has unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is true and has unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with nested patternProperties::with additional properties", + "unevaluatedProperties::unevaluatedProperties with nested properties::with additional properties", + "unevaluatedProperties::unevaluatedProperties with not::with unevaluated properties", + "unevaluatedProperties::unevaluatedProperties with oneOf::with unevaluated properties", + + // uniqueItems tests + "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, true] from items array is valid", + "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, false] from items array is valid", + "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, false] from items array is valid", + "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, true] from items array is valid", + "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, false] from items array is valid", + "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, true] from items array is valid", + + // vocabulary tests + "vocabulary::schema that uses custom metaschema with with no validation vocabulary::no validation: invalid number, but it still validates" ) diff --git a/buildSrc/src/test/kotlin/GenerateJsonTestSuiteTaskTest.kt b/buildSrc/src/test/kotlin/GenerateJsonTestSuiteTaskTest.kt index 9c86bfb6..803b5e3e 100644 --- a/buildSrc/src/test/kotlin/GenerateJsonTestSuiteTaskTest.kt +++ b/buildSrc/src/test/kotlin/GenerateJsonTestSuiteTaskTest.kt @@ -1,14 +1,13 @@ import org.gradle.testfixtures.ProjectBuilder import kotlin.test.Test -import kotlin.test.assertEquals import kotlin.test.assertTrue import org.kson.jsonsuite.JsonTestSuiteGenerator import org.kson.jsonsuite.JsonTestSuiteGeneratorTest /** * Note: most of the meat of [GenerateJsonTestSuiteTask]'s implementation lives in - * [JsonTestSuiteGenerator]. See [JsonTestSuiteGeneratorTest.testPlaceholder] for - * more notes on the testing of these classes + * [JsonTestSuiteGenerator], so the bulk of the tests for this task like in + * [JsonTestSuiteGeneratorTest] */ class GenerateJsonTestSuiteTaskTest { /** @@ -21,16 +20,10 @@ class GenerateJsonTestSuiteTaskTest { val jsonGenTask = project.getTasksByName("generateJsonTestSuite", false) .iterator().next() assertTrue(jsonGenTask is GenerateJsonTestSuiteTask) - assertEquals(2, jsonGenTask.getGeneratedTestPath().size, "Should have both our test file paths") assertTrue( - jsonGenTask.getGeneratedTestPath()[0].startsWith(project.projectDir), - "Should set the output test file path relative to the project directory" - ) - - assertTrue( - jsonGenTask.getGeneratedTestPath()[1].startsWith(project.projectDir), + jsonGenTask.getGeneratedClassDirectory().startsWith(project.projectDir), "Should set the output test file path relative to the project directory" ) } -} \ No newline at end of file +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_additionalProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_additionalProperties.kt new file mode 100644 index 00000000..2d3b7114 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_additionalProperties.kt @@ -0,0 +1,715 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_additionalProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> no additional properties is valid" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::no additional properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::no additional properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> an additional property is invalid" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::an additional property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": "boom" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::an additional property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> ignores arrays" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> ignores strings" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "foobarbaz" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> ignores other non-objects" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> patternProperties are not additional properties" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::patternProperties are not additional properties" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "vroom": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::patternProperties are not additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "non-ASCII pattern with additionalProperties -> matching the pattern is valid" + * + * Test ID: "additionalProperties::non-ASCII pattern with additionalProperties::matching the pattern is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "ármányos": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "^á": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::non-ASCII pattern with additionalProperties::matching the pattern is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "non-ASCII pattern with additionalProperties -> not matching the pattern is invalid" + * + * Test ID: "additionalProperties::non-ASCII pattern with additionalProperties::not matching the pattern is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "élmény": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "^á": { + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "additionalProperties::non-ASCII pattern with additionalProperties::not matching the pattern is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties with schema -> no additional properties is valid" + * + * Test ID: "additionalProperties::additionalProperties with schema::no additional properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "additionalProperties": { + "type": "boolean" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties with schema::no additional properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties with schema -> an additional valid property is valid" + * + * Test ID: "additionalProperties::additionalProperties with schema::an additional valid property is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "additionalProperties": { + "type": "boolean" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties with schema::an additional valid property is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties with schema -> an additional invalid property is invalid" + * + * Test ID: "additionalProperties::additionalProperties with schema::an additional invalid property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": 12 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "additionalProperties": { + "type": "boolean" + } + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties with schema::an additional invalid property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties can exist by itself -> an additional valid property is valid" + * + * Test ID: "additionalProperties::additionalProperties can exist by itself::an additional valid property is valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": { + "type": "boolean" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties can exist by itself::an additional valid property is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties can exist by itself -> an additional invalid property is invalid" + * + * Test ID: "additionalProperties::additionalProperties can exist by itself::an additional invalid property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": { + "type": "boolean" + } + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties can exist by itself::an additional invalid property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties are allowed by default -> additional properties are allowed" + * + * Test ID: "additionalProperties::additionalProperties are allowed by default::additional properties are allowed" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties are allowed by default::additional properties are allowed" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties does not look in applicators -> properties defined in allOf are not examined" + * + * Test ID: "additionalProperties::additionalProperties does not look in applicators::properties defined in allOf are not examined" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "properties": { + "foo": { + } + } + } + ], + "additionalProperties": { + "type": "boolean" + } + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties does not look in applicators::properties defined in allOf are not examined" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties with null valued instance properties -> allows null values" + * + * Test ID: "additionalProperties::additionalProperties with null valued instance properties::allows null values" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "foo": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties with null valued instance properties::allows null values" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties with propertyNames -> Valid against both keywords" + * + * Test ID: "additionalProperties::additionalProperties with propertyNames::Valid against both keywords" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "apple": 4 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 5 + }, + "additionalProperties": { + "type": "number" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties with propertyNames::Valid against both keywords" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "additionalProperties with propertyNames -> Valid against propertyNames, but not additionalProperties" + * + * Test ID: "additionalProperties::additionalProperties with propertyNames::Valid against propertyNames, but not additionalProperties" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "fig": 2, + "pear": "available" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 5 + }, + "additionalProperties": { + "type": "number" + } + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties with propertyNames::Valid against propertyNames, but not additionalProperties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "dependentSchemas with additionalProperties -> additionalProperties doesn't consider dependentSchemas" + * + * Test ID: "additionalProperties::dependentSchemas with additionalProperties::additionalProperties doesn't consider dependentSchemas" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo": "" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo2": { + } + }, + "dependentSchemas": { + "foo": { + }, + "foo2": { + "properties": { + "bar": { + } + } + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "additionalProperties::dependentSchemas with additionalProperties::additionalProperties doesn't consider dependentSchemas" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "dependentSchemas with additionalProperties -> additionalProperties can't see bar" + * + * Test ID: "additionalProperties::dependentSchemas with additionalProperties::additionalProperties can't see bar" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "bar": "" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo2": { + } + }, + "dependentSchemas": { + "foo": { + }, + "foo2": { + "properties": { + "bar": { + } + } + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "additionalProperties::dependentSchemas with additionalProperties::additionalProperties can't see bar" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json`: + * "dependentSchemas with additionalProperties -> additionalProperties can't see bar even when foo2 is present" + * + * Test ID: "additionalProperties::dependentSchemas with additionalProperties::additionalProperties can't see bar even when foo2 is present" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foo2": "", + "bar": "" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo2": { + } + }, + "dependentSchemas": { + "foo": { + }, + "foo2": { + "properties": { + "bar": { + } + } + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "additionalProperties::dependentSchemas with additionalProperties::additionalProperties can't see bar even when foo2 is present" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_allOf.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_allOf.kt new file mode 100644 index 00000000..a2d54f97 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_allOf.kt @@ -0,0 +1,1142 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_allOf : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf -> allOf" + * + * Test ID: "allOf::allOf::allOf" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz", + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf::allOf" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf -> mismatch second" + * + * Test ID: "allOf::allOf::mismatch second" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf::mismatch second" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf -> mismatch first" + * + * Test ID: "allOf::allOf::mismatch first" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf::mismatch first" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf -> wrong type" + * + * Test ID: "allOf::allOf::wrong type" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz", + "bar": "quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf::wrong type" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with base schema -> valid" + * + * Test ID: "allOf::allOf with base schema::valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "bar": 2, + "baz": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with base schema::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with base schema -> mismatch base schema" + * + * Test ID: "allOf::allOf with base schema::mismatch base schema" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "baz": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with base schema::mismatch base schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with base schema -> mismatch first allOf" + * + * Test ID: "allOf::allOf with base schema::mismatch first allOf" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2, + "baz": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with base schema::mismatch first allOf" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with base schema -> mismatch second allOf" + * + * Test ID: "allOf::allOf with base schema::mismatch second allOf" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with base schema::mismatch second allOf" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with base schema -> mismatch both" + * + * Test ID: "allOf::allOf with base schema::mismatch both" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with base schema::mismatch both" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf simple types -> valid" + * + * Test ID: "allOf::allOf simple types::valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 25 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "maximum": 30 + }, + { + "minimum": 20 + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf simple types::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf simple types -> mismatch one" + * + * Test ID: "allOf::allOf simple types::mismatch one" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + 35 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "maximum": 30 + }, + { + "minimum": 20 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf simple types::mismatch one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with boolean schemas, all true -> any value is valid" + * + * Test ID: "allOf::allOf with boolean schemas, all true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + true, + true + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with boolean schemas, all true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with boolean schemas, some false -> any value is invalid" + * + * Test ID: "allOf::allOf with boolean schemas, some false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + true, + false + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with boolean schemas, some false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with boolean schemas, all false -> any value is invalid" + * + * Test ID: "allOf::allOf with boolean schemas, all false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + false, + false + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with boolean schemas, all false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with one empty schema -> any data is valid" + * + * Test ID: "allOf::allOf with one empty schema::any data is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with one empty schema::any data is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with two empty schemas -> any data is valid" + * + * Test ID: "allOf::allOf with two empty schemas::any data is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + }, + { + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with two empty schemas::any data is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with the first empty schema -> number is valid" + * + * Test ID: "allOf::allOf with the first empty schema::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + }, + { + "type": "number" + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with the first empty schema::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with the first empty schema -> string is invalid" + * + * Test ID: "allOf::allOf with the first empty schema::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + }, + { + "type": "number" + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with the first empty schema::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with the last empty schema -> number is valid" + * + * Test ID: "allOf::allOf with the last empty schema::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with the last empty schema::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf with the last empty schema -> string is invalid" + * + * Test ID: "allOf::allOf with the last empty schema::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with the last empty schema::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "nested allOf, to check validation semantics -> null is valid" + * + * Test ID: "allOf::nested allOf, to check validation semantics::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "allOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + true, + """ schemaTestId: "allOf::nested allOf, to check validation semantics::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "nested allOf, to check validation semantics -> anything non-null is invalid" + * + * Test ID: "allOf::nested allOf, to check validation semantics::anything non-null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "allOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::nested allOf, to check validation semantics::anything non-null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: false, oneOf: false" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: false, oneOf: false" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: false, oneOf: false" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: false, oneOf: true" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: false, oneOf: true" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + 5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: false, oneOf: true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: true, oneOf: false" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: true, oneOf: false" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: true, oneOf: false" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: true, oneOf: true" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: true, oneOf: true" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + 15 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: true, oneOf: true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: false, oneOf: false" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: false, oneOf: false" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + 2 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: false, oneOf: false" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: false, oneOf: true" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: false, oneOf: true" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + 10 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: false, oneOf: true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: true, oneOf: false" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: true, oneOf: false" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + 6 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: true, oneOf: false" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: true, oneOf: true" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: true, oneOf: true" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + 30 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: true, oneOf: true" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_anchor.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_anchor.kt new file mode 100644 index 00000000..765fca5d --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_anchor.kt @@ -0,0 +1,331 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_anchor : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json`: + * "Location-independent identifier -> match" + * + * Test ID: "anchor::Location-independent identifier::match" + */ + @Test + fun jsonSchemaSuiteTest_1() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "anchor::Location-independent identifier::match" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "#foo", + "${'$'}defs": { + "A": { + "${'$'}anchor": "foo", + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "anchor::Location-independent identifier::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json`: + * "Location-independent identifier -> mismatch" + * + * Test ID: "anchor::Location-independent identifier::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_2() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "anchor::Location-independent identifier::mismatch" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "#foo", + "${'$'}defs": { + "A": { + "${'$'}anchor": "foo", + "type": "integer" + } + } + } + """, + false, + """ schemaTestId: "anchor::Location-independent identifier::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json`: + * "Location-independent identifier with absolute URI -> match" + * + * Test ID: "anchor::Location-independent identifier with absolute URI::match" + */ + @Test + fun jsonSchemaSuiteTest_3() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "anchor::Location-independent identifier with absolute URI::match" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/bar#foo", + "${'$'}defs": { + "A": { + "${'$'}id": "http://localhost:1234/draft2020-12/bar", + "${'$'}anchor": "foo", + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "anchor::Location-independent identifier with absolute URI::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json`: + * "Location-independent identifier with absolute URI -> mismatch" + * + * Test ID: "anchor::Location-independent identifier with absolute URI::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_4() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "anchor::Location-independent identifier with absolute URI::mismatch" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/bar#foo", + "${'$'}defs": { + "A": { + "${'$'}id": "http://localhost:1234/draft2020-12/bar", + "${'$'}anchor": "foo", + "type": "integer" + } + } + } + """, + false, + """ schemaTestId: "anchor::Location-independent identifier with absolute URI::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json`: + * "Location-independent identifier with base URI change in subschema -> match" + * + * Test ID: "anchor::Location-independent identifier with base URI change in subschema::match" + */ + @Test + fun jsonSchemaSuiteTest_5() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "anchor::Location-independent identifier with base URI change in subschema::match" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/root", + "${'$'}ref": "http://localhost:1234/draft2020-12/nested.json#foo", + "${'$'}defs": { + "A": { + "${'$'}id": "nested.json", + "${'$'}defs": { + "B": { + "${'$'}anchor": "foo", + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "anchor::Location-independent identifier with base URI change in subschema::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json`: + * "Location-independent identifier with base URI change in subschema -> mismatch" + * + * Test ID: "anchor::Location-independent identifier with base URI change in subschema::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_6() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "anchor::Location-independent identifier with base URI change in subschema::mismatch" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/root", + "${'$'}ref": "http://localhost:1234/draft2020-12/nested.json#foo", + "${'$'}defs": { + "A": { + "${'$'}id": "nested.json", + "${'$'}defs": { + "B": { + "${'$'}anchor": "foo", + "type": "integer" + } + } + } + } + } + """, + false, + """ schemaTestId: "anchor::Location-independent identifier with base URI change in subschema::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json`: + * "same $anchor with different base uri -> $ref resolves to /$defs/A/allOf/1" + * + * Test ID: "anchor::same $anchor with different base uri::$ref resolves to /$defs/A/allOf/1" + */ + @Test + fun jsonSchemaSuiteTest_7() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "anchor::same $anchor with different base uri::$ref resolves to /$defs/A/allOf/1" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/foobar", + "${'$'}defs": { + "A": { + "${'$'}id": "child1", + "allOf": [ + { + "${'$'}id": "child2", + "${'$'}anchor": "my_anchor", + "type": "number" + }, + { + "${'$'}anchor": "my_anchor", + "type": "string" + } + ] + } + }, + "${'$'}ref": "child1#my_anchor" + } + """, + true, + """ schemaTestId: "anchor::same ${'$'}anchor with different base uri::${'$'}ref resolves to /${'$'}defs/A/allOf/1" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json`: + * "same $anchor with different base uri -> $ref does not resolve to /$defs/A/allOf/0" + * + * Test ID: "anchor::same $anchor with different base uri::$ref does not resolve to /$defs/A/allOf/0" + */ + @Test + fun jsonSchemaSuiteTest_8() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "anchor::same $anchor with different base uri::$ref does not resolve to /$defs/A/allOf/0" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/foobar", + "${'$'}defs": { + "A": { + "${'$'}id": "child1", + "allOf": [ + { + "${'$'}id": "child2", + "${'$'}anchor": "my_anchor", + "type": "number" + }, + { + "${'$'}anchor": "my_anchor", + "type": "string" + } + ] + } + }, + "${'$'}ref": "child1#my_anchor" + } + """, + false, + """ schemaTestId: "anchor::same ${'$'}anchor with different base uri::${'$'}ref does not resolve to /${'$'}defs/A/allOf/0" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_anyOf.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_anyOf.kt new file mode 100644 index 00000000..c9a32b79 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_anyOf.kt @@ -0,0 +1,612 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_anyOf : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf -> first anyOf valid" + * + * Test ID: "anyOf::anyOf::first anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf::first anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf -> second anyOf valid" + * + * Test ID: "anyOf::anyOf::second anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 2.5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf::second anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf -> both anyOf valid" + * + * Test ID: "anyOf::anyOf::both anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf::both anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf -> neither anyOf valid" + * + * Test ID: "anyOf::anyOf::neither anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 1.5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf::neither anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf with base schema -> mismatch base schema" + * + * Test ID: "anyOf::anyOf with base schema::mismatch base schema" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "anyOf": [ + { + "maxLength": 2 + }, + { + "minLength": 4 + } + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf with base schema::mismatch base schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf with base schema -> one anyOf valid" + * + * Test ID: "anyOf::anyOf with base schema::one anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "anyOf": [ + { + "maxLength": 2 + }, + { + "minLength": 4 + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with base schema::one anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf with base schema -> both anyOf invalid" + * + * Test ID: "anyOf::anyOf with base schema::both anyOf invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "anyOf": [ + { + "maxLength": 2 + }, + { + "minLength": 4 + } + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf with base schema::both anyOf invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf with boolean schemas, all true -> any value is valid" + * + * Test ID: "anyOf::anyOf with boolean schemas, all true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + true, + true + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with boolean schemas, all true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf with boolean schemas, some true -> any value is valid" + * + * Test ID: "anyOf::anyOf with boolean schemas, some true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + true, + false + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with boolean schemas, some true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf with boolean schemas, all false -> any value is invalid" + * + * Test ID: "anyOf::anyOf with boolean schemas, all false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + false, + false + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf with boolean schemas, all false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf complex types -> first anyOf valid (complex)" + * + * Test ID: "anyOf::anyOf complex types::first anyOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf complex types::first anyOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf complex types -> second anyOf valid (complex)" + * + * Test ID: "anyOf::anyOf complex types::second anyOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf complex types::second anyOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf complex types -> both anyOf valid (complex)" + * + * Test ID: "anyOf::anyOf complex types::both anyOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz", + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf complex types::both anyOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf complex types -> neither anyOf valid (complex)" + * + * Test ID: "anyOf::anyOf complex types::neither anyOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "foo": 2, + "bar": "quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf complex types::neither anyOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf with one empty schema -> string is valid" + * + * Test ID: "anyOf::anyOf with one empty schema::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with one empty schema::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "anyOf with one empty schema -> number is valid" + * + * Test ID: "anyOf::anyOf with one empty schema::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with one empty schema::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "nested anyOf, to check validation semantics -> null is valid" + * + * Test ID: "anyOf::nested anyOf, to check validation semantics::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + true, + """ schemaTestId: "anyOf::nested anyOf, to check validation semantics::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json`: + * "nested anyOf, to check validation semantics -> anything non-null is invalid" + * + * Test ID: "anyOf::nested anyOf, to check validation semantics::anything non-null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + false, + """ schemaTestId: "anyOf::nested anyOf, to check validation semantics::anything non-null is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_boolean_schema.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_boolean_schema.kt new file mode 100644 index 00000000..b2d1d9a9 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_boolean_schema.kt @@ -0,0 +1,387 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_boolean_schema : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> number is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> string is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> boolean true is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::boolean true is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::boolean true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> boolean false is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::boolean false is valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::boolean false is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> null is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> object is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::object is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> empty object is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> array is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::array is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'true' -> empty array is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> number is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> string is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> boolean true is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::boolean true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::boolean true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> boolean false is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::boolean false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::boolean false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> null is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> object is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> empty object is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::empty object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::empty object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> array is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json`: + * "boolean schema 'false' -> empty array is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::empty array is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_const.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_const.kt new file mode 100644 index 00000000..6452868b --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_const.kt @@ -0,0 +1,1260 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_const : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const validation -> same value is valid" + * + * Test ID: "const::const validation::same value is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 2 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 2 + } + """, + true, + """ schemaTestId: "const::const validation::same value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const validation -> another value is invalid" + * + * Test ID: "const::const validation::another value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 2 + } + """, + false, + """ schemaTestId: "const::const validation::another value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const validation -> another type is invalid" + * + * Test ID: "const::const validation::another type is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 2 + } + """, + false, + """ schemaTestId: "const::const validation::another type is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with object -> same object is valid" + * + * Test ID: "const::const with object::same object is valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar", + "baz": "bax" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "foo": "bar", + "baz": "bax" + } + } + """, + true, + """ schemaTestId: "const::const with object::same object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with object -> same object with different property order is valid" + * + * Test ID: "const::const with object::same object with different property order is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "baz": "bax", + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "foo": "bar", + "baz": "bax" + } + } + """, + true, + """ schemaTestId: "const::const with object::same object with different property order is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with object -> another object is invalid" + * + * Test ID: "const::const with object::another object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "foo": "bar", + "baz": "bax" + } + } + """, + false, + """ schemaTestId: "const::const with object::another object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with object -> another type is invalid" + * + * Test ID: "const::const with object::another type is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "foo": "bar", + "baz": "bax" + } + } + """, + false, + """ schemaTestId: "const::const with object::another type is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with array -> same array is valid" + * + * Test ID: "const::const with array::same array is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + { + "foo": "bar" + } + ] + } + """, + true, + """ schemaTestId: "const::const with array::same array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with array -> another array item is invalid" + * + * Test ID: "const::const with array::another array item is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + { + "foo": "bar" + } + ] + } + """, + false, + """ schemaTestId: "const::const with array::another array item is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with array -> array with additional items is invalid" + * + * Test ID: "const::const with array::array with additional items is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + { + "foo": "bar" + } + ] + } + """, + false, + """ schemaTestId: "const::const with array::array with additional items is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with null -> null is valid" + * + * Test ID: "const::const with null::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": null + } + """, + true, + """ schemaTestId: "const::const with null::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with null -> not null is invalid" + * + * Test ID: "const::const with null::not null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": null + } + """, + false, + """ schemaTestId: "const::const with null::not null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with false does not match 0 -> false is valid" + * + * Test ID: "const::const with false does not match 0::false is valid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": false + } + """, + true, + """ schemaTestId: "const::const with false does not match 0::false is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with false does not match 0 -> integer zero is invalid" + * + * Test ID: "const::const with false does not match 0::integer zero is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": false + } + """, + false, + """ schemaTestId: "const::const with false does not match 0::integer zero is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with false does not match 0 -> float zero is invalid" + * + * Test ID: "const::const with false does not match 0::float zero is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 0.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": false + } + """, + false, + """ schemaTestId: "const::const with false does not match 0::float zero is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with true does not match 1 -> true is valid" + * + * Test ID: "const::const with true does not match 1::true is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": true + } + """, + true, + """ schemaTestId: "const::const with true does not match 1::true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with true does not match 1 -> integer one is invalid" + * + * Test ID: "const::const with true does not match 1::integer one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": true + } + """, + false, + """ schemaTestId: "const::const with true does not match 1::integer one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with true does not match 1 -> float one is invalid" + * + * Test ID: "const::const with true does not match 1::float one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": true + } + """, + false, + """ schemaTestId: "const::const with true does not match 1::float one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with [false] does not match [0] -> [false] is valid" + * + * Test ID: "const::const with [false] does not match [0]::[false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + false + ] + } + """, + true, + """ schemaTestId: "const::const with [false] does not match [0]::[false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with [false] does not match [0] -> [0] is invalid" + * + * Test ID: "const::const with [false] does not match [0]::[0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + 0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + false + ] + } + """, + false, + """ schemaTestId: "const::const with [false] does not match [0]::[0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with [false] does not match [0] -> [0.0] is invalid" + * + * Test ID: "const::const with [false] does not match [0]::[0.0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + [ + 0.0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + false + ] + } + """, + false, + """ schemaTestId: "const::const with [false] does not match [0]::[0.0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with [true] does not match [1] -> [true] is valid" + * + * Test ID: "const::const with [true] does not match [1]::[true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + [ + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + true + ] + } + """, + true, + """ schemaTestId: "const::const with [true] does not match [1]::[true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with [true] does not match [1] -> [1] is invalid" + * + * Test ID: "const::const with [true] does not match [1]::[1] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + true + ] + } + """, + false, + """ schemaTestId: "const::const with [true] does not match [1]::[1] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with [true] does not match [1] -> [1.0] is invalid" + * + * Test ID: "const::const with [true] does not match [1]::[1.0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + [ + 1.0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": [ + true + ] + } + """, + false, + """ schemaTestId: "const::const with [true] does not match [1]::[1.0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with {"a": false} does not match {"a": 0} -> {"a": false} is valid" + * + * Test ID: "const::const with {"a": false} does not match {"a": 0}::{"a": false} is valid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + "a": false + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "a": false + } + } + """, + true, + """ schemaTestId: "const::const with {"a": false} does not match {"a": 0}::{"a": false} is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with {"a": false} does not match {"a": 0} -> {"a": 0} is invalid" + * + * Test ID: "const::const with {"a": false} does not match {"a": 0}::{"a": 0} is invalid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + { + "a": 0 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "a": false + } + } + """, + false, + """ schemaTestId: "const::const with {"a": false} does not match {"a": 0}::{"a": 0} is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with {"a": false} does not match {"a": 0} -> {"a": 0.0} is invalid" + * + * Test ID: "const::const with {"a": false} does not match {"a": 0}::{"a": 0.0} is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + { + "a": 0.0 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "a": false + } + } + """, + false, + """ schemaTestId: "const::const with {"a": false} does not match {"a": 0}::{"a": 0.0} is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with {"a": true} does not match {"a": 1} -> {"a": true} is valid" + * + * Test ID: "const::const with {"a": true} does not match {"a": 1}::{"a": true} is valid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + { + "a": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "a": true + } + } + """, + true, + """ schemaTestId: "const::const with {"a": true} does not match {"a": 1}::{"a": true} is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with {"a": true} does not match {"a": 1} -> {"a": 1} is invalid" + * + * Test ID: "const::const with {"a": true} does not match {"a": 1}::{"a": 1} is invalid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + { + "a": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "a": true + } + } + """, + false, + """ schemaTestId: "const::const with {"a": true} does not match {"a": 1}::{"a": 1} is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with {"a": true} does not match {"a": 1} -> {"a": 1.0} is invalid" + * + * Test ID: "const::const with {"a": true} does not match {"a": 1}::{"a": 1.0} is invalid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + { + "a": 1.0 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": { + "a": true + } + } + """, + false, + """ schemaTestId: "const::const with {"a": true} does not match {"a": 1}::{"a": 1.0} is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 0 does not match other zero-like types -> false is invalid" + * + * Test ID: "const::const with 0 does not match other zero-like types::false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 0 + } + """, + false, + """ schemaTestId: "const::const with 0 does not match other zero-like types::false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 0 does not match other zero-like types -> integer zero is valid" + * + * Test ID: "const::const with 0 does not match other zero-like types::integer zero is valid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 0 + } + """, + true, + """ schemaTestId: "const::const with 0 does not match other zero-like types::integer zero is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 0 does not match other zero-like types -> float zero is valid" + * + * Test ID: "const::const with 0 does not match other zero-like types::float zero is valid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + 0.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 0 + } + """, + true, + """ schemaTestId: "const::const with 0 does not match other zero-like types::float zero is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 0 does not match other zero-like types -> empty object is invalid" + * + * Test ID: "const::const with 0 does not match other zero-like types::empty object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 0 + } + """, + false, + """ schemaTestId: "const::const with 0 does not match other zero-like types::empty object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 0 does not match other zero-like types -> empty array is invalid" + * + * Test ID: "const::const with 0 does not match other zero-like types::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 0 + } + """, + false, + """ schemaTestId: "const::const with 0 does not match other zero-like types::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 0 does not match other zero-like types -> empty string is invalid" + * + * Test ID: "const::const with 0 does not match other zero-like types::empty string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 0 + } + """, + false, + """ schemaTestId: "const::const with 0 does not match other zero-like types::empty string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 1 does not match true -> true is invalid" + * + * Test ID: "const::const with 1 does not match true::true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 1 + } + """, + false, + """ schemaTestId: "const::const with 1 does not match true::true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 1 does not match true -> integer one is valid" + * + * Test ID: "const::const with 1 does not match true::integer one is valid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 1 + } + """, + true, + """ schemaTestId: "const::const with 1 does not match true::integer one is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with 1 does not match true -> float one is valid" + * + * Test ID: "const::const with 1 does not match true::float one is valid" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 1 + } + """, + true, + """ schemaTestId: "const::const with 1 does not match true::float one is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with -2.0 matches integer and float types -> integer -2 is valid" + * + * Test ID: "const::const with -2.0 matches integer and float types::integer -2 is valid" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + -2 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": -2.0 + } + """, + true, + """ schemaTestId: "const::const with -2.0 matches integer and float types::integer -2 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with -2.0 matches integer and float types -> integer 2 is invalid" + * + * Test ID: "const::const with -2.0 matches integer and float types::integer 2 is invalid" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + 2 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": -2.0 + } + """, + false, + """ schemaTestId: "const::const with -2.0 matches integer and float types::integer 2 is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with -2.0 matches integer and float types -> float -2.0 is valid" + * + * Test ID: "const::const with -2.0 matches integer and float types::float -2.0 is valid" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + -2.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": -2.0 + } + """, + true, + """ schemaTestId: "const::const with -2.0 matches integer and float types::float -2.0 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with -2.0 matches integer and float types -> float 2.0 is invalid" + * + * Test ID: "const::const with -2.0 matches integer and float types::float 2.0 is invalid" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + 2.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": -2.0 + } + """, + false, + """ schemaTestId: "const::const with -2.0 matches integer and float types::float 2.0 is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "const with -2.0 matches integer and float types -> float -2.00001 is invalid" + * + * Test ID: "const::const with -2.0 matches integer and float types::float -2.00001 is invalid" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + -2.00001 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": -2.0 + } + """, + false, + """ schemaTestId: "const::const with -2.0 matches integer and float types::float -2.00001 is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "float and integers are equal up to 64-bit representation limits -> integer is valid" + * + * Test ID: "const::float and integers are equal up to 64-bit representation limits::integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + 9007199254740992 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 9007199254740992 + } + """, + true, + """ schemaTestId: "const::float and integers are equal up to 64-bit representation limits::integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "float and integers are equal up to 64-bit representation limits -> integer minus one is invalid" + * + * Test ID: "const::float and integers are equal up to 64-bit representation limits::integer minus one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + 9007199254740991 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 9007199254740992 + } + """, + false, + """ schemaTestId: "const::float and integers are equal up to 64-bit representation limits::integer minus one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "float and integers are equal up to 64-bit representation limits -> float is valid" + * + * Test ID: "const::float and integers are equal up to 64-bit representation limits::float is valid" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + 9.007199254740992E15 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 9007199254740992 + } + """, + true, + """ schemaTestId: "const::float and integers are equal up to 64-bit representation limits::float is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "float and integers are equal up to 64-bit representation limits -> float minus one is invalid" + * + * Test ID: "const::float and integers are equal up to 64-bit representation limits::float minus one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + 9.007199254740991E15 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": 9007199254740992 + } + """, + false, + """ schemaTestId: "const::float and integers are equal up to 64-bit representation limits::float minus one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "nul characters in strings -> match string with nul" + * + * Test ID: "const::nul characters in strings::match string with nul" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + "hello\u0000there" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": "hello\u0000there" + } + """, + true, + """ schemaTestId: "const::nul characters in strings::match string with nul" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/const.json`: + * "nul characters in strings -> do not match string lacking nul" + * + * Test ID: "const::nul characters in strings::do not match string lacking nul" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + "hellothere" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "const": "hello\u0000there" + } + """, + false, + """ schemaTestId: "const::nul characters in strings::do not match string lacking nul" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_contains.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_contains.kt new file mode 100644 index 00000000..1f91a1c0 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_contains.kt @@ -0,0 +1,602 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_contains : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword validation -> array with item matching schema (5) is valid" + * + * Test ID: "contains::contains keyword validation::array with item matching schema (5) is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 5 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword validation::array with item matching schema (5) is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword validation -> array with item matching schema (6) is valid" + * + * Test ID: "contains::contains keyword validation::array with item matching schema (6) is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 6 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword validation::array with item matching schema (6) is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword validation -> array with two items matching schema (5, 6) is valid" + * + * Test ID: "contains::contains keyword validation::array with two items matching schema (5, 6) is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 5, + 6 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword validation::array with two items matching schema (5, 6) is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword validation -> array without items matching schema is invalid" + * + * Test ID: "contains::contains keyword validation::array without items matching schema is invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 2, + 3, + 4 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "minimum": 5 + } + } + """, + false, + """ schemaTestId: "contains::contains keyword validation::array without items matching schema is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword validation -> empty array is invalid" + * + * Test ID: "contains::contains keyword validation::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "minimum": 5 + } + } + """, + false, + """ schemaTestId: "contains::contains keyword validation::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword validation -> not array is valid" + * + * Test ID: "contains::contains keyword validation::not array is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword validation::not array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword with const keyword -> array with item 5 is valid" + * + * Test ID: "contains::contains keyword with const keyword::array with item 5 is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 5 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword with const keyword::array with item 5 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword with const keyword -> array with two items 5 is valid" + * + * Test ID: "contains::contains keyword with const keyword::array with two items 5 is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 5, + 5 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword with const keyword::array with two items 5 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword with const keyword -> array without item 5 is invalid" + * + * Test ID: "contains::contains keyword with const keyword::array without item 5 is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3, + 4 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 5 + } + } + """, + false, + """ schemaTestId: "contains::contains keyword with const keyword::array without item 5 is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword with boolean schema true -> any non-empty array is valid" + * + * Test ID: "contains::contains keyword with boolean schema true::any non-empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": true + } + """, + true, + """ schemaTestId: "contains::contains keyword with boolean schema true::any non-empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword with boolean schema true -> empty array is invalid" + * + * Test ID: "contains::contains keyword with boolean schema true::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": true + } + """, + false, + """ schemaTestId: "contains::contains keyword with boolean schema true::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword with boolean schema false -> any non-empty array is invalid" + * + * Test ID: "contains::contains keyword with boolean schema false::any non-empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": false + } + """, + false, + """ schemaTestId: "contains::contains keyword with boolean schema false::any non-empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword with boolean schema false -> empty array is invalid" + * + * Test ID: "contains::contains keyword with boolean schema false::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": false + } + """, + false, + """ schemaTestId: "contains::contains keyword with boolean schema false::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains keyword with boolean schema false -> non-arrays are valid" + * + * Test ID: "contains::contains keyword with boolean schema false::non-arrays are valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + "contains does not apply to strings" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": false + } + """, + true, + """ schemaTestId: "contains::contains keyword with boolean schema false::non-arrays are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "items + contains -> matches items, does not match contains" + * + * Test ID: "contains::items + contains::matches items, does not match contains" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + 2, + 4, + 8 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "multipleOf": 2 + }, + "contains": { + "multipleOf": 3 + } + } + """, + false, + """ schemaTestId: "contains::items + contains::matches items, does not match contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "items + contains -> does not match items, matches contains" + * + * Test ID: "contains::items + contains::does not match items, matches contains" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 6, + 9 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "multipleOf": 2 + }, + "contains": { + "multipleOf": 3 + } + } + """, + false, + """ schemaTestId: "contains::items + contains::does not match items, matches contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "items + contains -> matches both items and contains" + * + * Test ID: "contains::items + contains::matches both items and contains" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + 6, + 12 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "multipleOf": 2 + }, + "contains": { + "multipleOf": 3 + } + } + """, + true, + """ schemaTestId: "contains::items + contains::matches both items and contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "items + contains -> matches neither items nor contains" + * + * Test ID: "contains::items + contains::matches neither items nor contains" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 5 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "multipleOf": 2 + }, + "contains": { + "multipleOf": 3 + } + } + """, + false, + """ schemaTestId: "contains::items + contains::matches neither items nor contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains with false if subschema -> any non-empty array is valid" + * + * Test ID: "contains::contains with false if subschema::any non-empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "if": false, + "else": true + } + } + """, + true, + """ schemaTestId: "contains::contains with false if subschema::any non-empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains with false if subschema -> empty array is invalid" + * + * Test ID: "contains::contains with false if subschema::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "if": false, + "else": true + } + } + """, + false, + """ schemaTestId: "contains::contains with false if subschema::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json`: + * "contains with null instance elements -> allows null items" + * + * Test ID: "contains::contains with null instance elements::allows null items" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "contains::contains with null instance elements::allows null items" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_content.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_content.kt new file mode 100644 index 00000000..d83b0203 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_content.kt @@ -0,0 +1,529 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_content : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of string-encoded content based on media type -> a valid JSON document" + * + * Test ID: "content::validation of string-encoded content based on media type::a valid JSON document" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "{\"foo\": \"bar\"}" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json" + } + """, + true, + """ schemaTestId: "content::validation of string-encoded content based on media type::a valid JSON document" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of string-encoded content based on media type -> an invalid JSON document; validates true" + * + * Test ID: "content::validation of string-encoded content based on media type::an invalid JSON document; validates true" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "{:}" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json" + } + """, + true, + """ schemaTestId: "content::validation of string-encoded content based on media type::an invalid JSON document; validates true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of string-encoded content based on media type -> ignores non-strings" + * + * Test ID: "content::validation of string-encoded content based on media type::ignores non-strings" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 100 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json" + } + """, + true, + """ schemaTestId: "content::validation of string-encoded content based on media type::ignores non-strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary string-encoding -> a valid base64 string" + * + * Test ID: "content::validation of binary string-encoding::a valid base64 string" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "eyJmb28iOiAiYmFyIn0K" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentEncoding": "base64" + } + """, + true, + """ schemaTestId: "content::validation of binary string-encoding::a valid base64 string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary string-encoding -> an invalid base64 string (% is not a valid character); validates true" + * + * Test ID: "content::validation of binary string-encoding::an invalid base64 string (% is not a valid character); validates true" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "eyJmb28iOi%iYmFyIn0K" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentEncoding": "base64" + } + """, + true, + """ schemaTestId: "content::validation of binary string-encoding::an invalid base64 string (% is not a valid character); validates true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary string-encoding -> ignores non-strings" + * + * Test ID: "content::validation of binary string-encoding::ignores non-strings" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 100 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentEncoding": "base64" + } + """, + true, + """ schemaTestId: "content::validation of binary string-encoding::ignores non-strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents -> a valid base64-encoded JSON document" + * + * Test ID: "content::validation of binary-encoded media type documents::a valid base64-encoded JSON document" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "eyJmb28iOiAiYmFyIn0K" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64" + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents::a valid base64-encoded JSON document" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents -> a validly-encoded invalid JSON document; validates true" + * + * Test ID: "content::validation of binary-encoded media type documents::a validly-encoded invalid JSON document; validates true" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + "ezp9Cg==" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64" + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents::a validly-encoded invalid JSON document; validates true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents -> an invalid base64 string that is valid JSON; validates true" + * + * Test ID: "content::validation of binary-encoded media type documents::an invalid base64 string that is valid JSON; validates true" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + "{}" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64" + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents::an invalid base64 string that is valid JSON; validates true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents -> ignores non-strings" + * + * Test ID: "content::validation of binary-encoded media type documents::ignores non-strings" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 100 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64" + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents::ignores non-strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents with schema -> a valid base64-encoded JSON document" + * + * Test ID: "content::validation of binary-encoded media type documents with schema::a valid base64-encoded JSON document" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + "eyJmb28iOiAiYmFyIn0K" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64", + "contentSchema": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents with schema::a valid base64-encoded JSON document" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents with schema -> another valid base64-encoded JSON document" + * + * Test ID: "content::validation of binary-encoded media type documents with schema::another valid base64-encoded JSON document" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64", + "contentSchema": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents with schema::another valid base64-encoded JSON document" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents with schema -> an invalid base64-encoded JSON document; validates true" + * + * Test ID: "content::validation of binary-encoded media type documents with schema::an invalid base64-encoded JSON document; validates true" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + "eyJib28iOiAyMH0=" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64", + "contentSchema": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents with schema::an invalid base64-encoded JSON document; validates true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents with schema -> an empty object as a base64-encoded JSON document; validates true" + * + * Test ID: "content::validation of binary-encoded media type documents with schema::an empty object as a base64-encoded JSON document; validates true" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + "e30=" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64", + "contentSchema": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents with schema::an empty object as a base64-encoded JSON document; validates true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents with schema -> an empty array as a base64-encoded JSON document" + * + * Test ID: "content::validation of binary-encoded media type documents with schema::an empty array as a base64-encoded JSON document" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + "W10=" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64", + "contentSchema": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents with schema::an empty array as a base64-encoded JSON document" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents with schema -> a validly-encoded invalid JSON document; validates true" + * + * Test ID: "content::validation of binary-encoded media type documents with schema::a validly-encoded invalid JSON document; validates true" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + "ezp9Cg==" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64", + "contentSchema": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents with schema::a validly-encoded invalid JSON document; validates true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents with schema -> an invalid base64 string that is valid JSON; validates true" + * + * Test ID: "content::validation of binary-encoded media type documents with schema::an invalid base64 string that is valid JSON; validates true" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + "{}" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64", + "contentSchema": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents with schema::an invalid base64 string that is valid JSON; validates true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/content.json`: + * "validation of binary-encoded media type documents with schema -> ignores non-strings" + * + * Test ID: "content::validation of binary-encoded media type documents with schema::ignores non-strings" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + 100 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contentMediaType": "application/json", + "contentEncoding": "base64", + "contentSchema": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "content::validation of binary-encoded media type documents with schema::ignores non-strings" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_default.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_default.kt new file mode 100644 index 00000000..6dd01828 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_default.kt @@ -0,0 +1,232 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_default : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/default.json`: + * "invalid type for default -> valid when property is specified" + * + * Test ID: "default::invalid type for default::valid when property is specified" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 13 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer", + "default": [ + ] + } + } + } + """, + true, + """ schemaTestId: "default::invalid type for default::valid when property is specified" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/default.json`: + * "invalid type for default -> still valid when the invalid default is used" + * + * Test ID: "default::invalid type for default::still valid when the invalid default is used" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer", + "default": [ + ] + } + } + } + """, + true, + """ schemaTestId: "default::invalid type for default::still valid when the invalid default is used" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/default.json`: + * "invalid string value for default -> valid when property is specified" + * + * Test ID: "default::invalid string value for default::valid when property is specified" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "bar": "good" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "bar": { + "type": "string", + "minLength": 4, + "default": "bad" + } + } + } + """, + true, + """ schemaTestId: "default::invalid string value for default::valid when property is specified" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/default.json`: + * "invalid string value for default -> still valid when the invalid default is used" + * + * Test ID: "default::invalid string value for default::still valid when the invalid default is used" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "bar": { + "type": "string", + "minLength": 4, + "default": "bad" + } + } + } + """, + true, + """ schemaTestId: "default::invalid string value for default::still valid when the invalid default is used" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/default.json`: + * "the default keyword does not do anything if the property is missing -> an explicit property value is checked against maximum (passing)" + * + * Test ID: "default::the default keyword does not do anything if the property is missing::an explicit property value is checked against maximum (passing)" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "alpha": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "alpha": { + "type": "number", + "maximum": 3, + "default": 5 + } + } + } + """, + true, + """ schemaTestId: "default::the default keyword does not do anything if the property is missing::an explicit property value is checked against maximum (passing)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/default.json`: + * "the default keyword does not do anything if the property is missing -> an explicit property value is checked against maximum (failing)" + * + * Test ID: "default::the default keyword does not do anything if the property is missing::an explicit property value is checked against maximum (failing)" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "alpha": 5 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "alpha": { + "type": "number", + "maximum": 3, + "default": 5 + } + } + } + """, + false, + """ schemaTestId: "default::the default keyword does not do anything if the property is missing::an explicit property value is checked against maximum (failing)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/default.json`: + * "the default keyword does not do anything if the property is missing -> missing properties are not filled in with the default" + * + * Test ID: "default::the default keyword does not do anything if the property is missing::missing properties are not filled in with the default" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "alpha": { + "type": "number", + "maximum": 3, + "default": 5 + } + } + } + """, + true, + """ schemaTestId: "default::the default keyword does not do anything if the property is missing::missing properties are not filled in with the default" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_defs.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_defs.kt new file mode 100644 index 00000000..0cefc838 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_defs.kt @@ -0,0 +1,85 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_defs : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/defs.json`: + * "validate definition against metaschema -> valid definition schema" + * + * Test ID: "defs::validate definition against metaschema::valid definition schema" + */ + @Test + fun jsonSchemaSuiteTest_1() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "defs::validate definition against metaschema::valid definition schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "${'$'}defs": { + "foo": { + "type": "integer" + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "https://json-schema.org/draft/2020-12/schema" + } + """, + true, + """ schemaTestId: "defs::validate definition against metaschema::valid definition schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/defs.json`: + * "validate definition against metaschema -> invalid definition schema" + * + * Test ID: "defs::validate definition against metaschema::invalid definition schema" + */ + @Test + fun jsonSchemaSuiteTest_2() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "defs::validate definition against metaschema::invalid definition schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "${'$'}defs": { + "foo": { + "type": 1 + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "https://json-schema.org/draft/2020-12/schema" + } + """, + false, + """ schemaTestId: "defs::validate definition against metaschema::invalid definition schema" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dependentRequired.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dependentRequired.kt new file mode 100644 index 00000000..4358948d --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dependentRequired.kt @@ -0,0 +1,646 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_dependentRequired : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "single dependency -> neither" + * + * Test ID: "dependentRequired::single dependency::neither" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::single dependency::neither" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "single dependency -> nondependant" + * + * Test ID: "dependentRequired::single dependency::nondependant" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::single dependency::nondependant" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "single dependency -> with dependency" + * + * Test ID: "dependentRequired::single dependency::with dependency" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::single dependency::with dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "single dependency -> missing dependency" + * + * Test ID: "dependentRequired::single dependency::missing dependency" + */ + @Test + fun jsonSchemaSuiteTest_4() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentRequired::single dependency::missing dependency" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + "foo" + ] + } + } + """, + false, + """ schemaTestId: "dependentRequired::single dependency::missing dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "single dependency -> ignores arrays" + * + * Test ID: "dependentRequired::single dependency::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::single dependency::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "single dependency -> ignores strings" + * + * Test ID: "dependentRequired::single dependency::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::single dependency::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "single dependency -> ignores other non-objects" + * + * Test ID: "dependentRequired::single dependency::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::single dependency::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "empty dependents -> empty object" + * + * Test ID: "dependentRequired::empty dependents::empty object" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::empty dependents::empty object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "empty dependents -> object with one property" + * + * Test ID: "dependentRequired::empty dependents::object with one property" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::empty dependents::object with one property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "empty dependents -> non-object is valid" + * + * Test ID: "dependentRequired::empty dependents::non-object is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "bar": [ + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::empty dependents::non-object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "multiple dependents required -> neither" + * + * Test ID: "dependentRequired::multiple dependents required::neither" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::multiple dependents required::neither" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "multiple dependents required -> nondependants" + * + * Test ID: "dependentRequired::multiple dependents required::nondependants" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::multiple dependents required::nondependants" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "multiple dependents required -> with dependencies" + * + * Test ID: "dependentRequired::multiple dependents required::with dependencies" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::multiple dependents required::with dependencies" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "multiple dependents required -> missing dependency" + * + * Test ID: "dependentRequired::multiple dependents required::missing dependency" + */ + @Test + fun jsonSchemaSuiteTest_14() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentRequired::multiple dependents required::missing dependency" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "quux": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + false, + """ schemaTestId: "dependentRequired::multiple dependents required::missing dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "multiple dependents required -> missing other dependency" + * + * Test ID: "dependentRequired::multiple dependents required::missing other dependency" + */ + @Test + fun jsonSchemaSuiteTest_15() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentRequired::multiple dependents required::missing other dependency" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": 1, + "quux": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + false, + """ schemaTestId: "dependentRequired::multiple dependents required::missing other dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "multiple dependents required -> missing both dependencies" + * + * Test ID: "dependentRequired::multiple dependents required::missing both dependencies" + */ + @Test + fun jsonSchemaSuiteTest_16() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentRequired::multiple dependents required::missing both dependencies" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "quux": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + false, + """ schemaTestId: "dependentRequired::multiple dependents required::missing both dependencies" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "dependencies with escaped characters -> CRLF" + * + * Test ID: "dependentRequired::dependencies with escaped characters::CRLF" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": 1, + "foo\rbar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::dependencies with escaped characters::CRLF" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "dependencies with escaped characters -> quoted quotes" + * + * Test ID: "dependentRequired::dependencies with escaped characters::quoted quotes" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo'bar": 1, + "foo\"bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + true, + """ schemaTestId: "dependentRequired::dependencies with escaped characters::quoted quotes" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "dependencies with escaped characters -> CRLF missing dependent" + * + * Test ID: "dependentRequired::dependencies with escaped characters::CRLF missing dependent" + */ + @Test + fun jsonSchemaSuiteTest_19() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentRequired::dependencies with escaped characters::CRLF missing dependent" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": 1, + "foo": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + false, + """ schemaTestId: "dependentRequired::dependencies with escaped characters::CRLF missing dependent" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json`: + * "dependencies with escaped characters -> quoted quotes missing dependent" + * + * Test ID: "dependentRequired::dependencies with escaped characters::quoted quotes missing dependent" + */ + @Test + fun jsonSchemaSuiteTest_20() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentRequired::dependencies with escaped characters::quoted quotes missing dependent" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo\"bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentRequired": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + false, + """ schemaTestId: "dependentRequired::dependencies with escaped characters::quoted quotes missing dependent" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dependentSchemas.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dependentSchemas.kt new file mode 100644 index 00000000..3aa70ca2 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dependentSchemas.kt @@ -0,0 +1,766 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_dependentSchemas : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "single dependency -> valid" + * + * Test ID: "dependentSchemas::single dependency::valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "dependentSchemas::single dependency::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "single dependency -> no dependency" + * + * Test ID: "dependentSchemas::single dependency::no dependency" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "dependentSchemas::single dependency::no dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "single dependency -> wrong type" + * + * Test ID: "dependentSchemas::single dependency::wrong type" + */ + @Test + fun jsonSchemaSuiteTest_3() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::single dependency::wrong type" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + false, + """ schemaTestId: "dependentSchemas::single dependency::wrong type" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "single dependency -> wrong type other" + * + * Test ID: "dependentSchemas::single dependency::wrong type other" + */ + @Test + fun jsonSchemaSuiteTest_4() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::single dependency::wrong type other" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 2, + "bar": "quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + false, + """ schemaTestId: "dependentSchemas::single dependency::wrong type other" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "single dependency -> wrong type both" + * + * Test ID: "dependentSchemas::single dependency::wrong type both" + */ + @Test + fun jsonSchemaSuiteTest_5() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::single dependency::wrong type both" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "bar": "quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + false, + """ schemaTestId: "dependentSchemas::single dependency::wrong type both" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "single dependency -> ignores arrays" + * + * Test ID: "dependentSchemas::single dependency::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "dependentSchemas::single dependency::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "single dependency -> ignores strings" + * + * Test ID: "dependentSchemas::single dependency::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "dependentSchemas::single dependency::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "single dependency -> ignores other non-objects" + * + * Test ID: "dependentSchemas::single dependency::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "dependentSchemas::single dependency::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "boolean subschemas -> object with property having schema true is valid" + * + * Test ID: "dependentSchemas::boolean subschemas::object with property having schema true is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "foo": true, + "bar": false + } + } + """, + true, + """ schemaTestId: "dependentSchemas::boolean subschemas::object with property having schema true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "boolean subschemas -> object with property having schema false is invalid" + * + * Test ID: "dependentSchemas::boolean subschemas::object with property having schema false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::boolean subschemas::object with property having schema false is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "foo": true, + "bar": false + } + } + """, + false, + """ schemaTestId: "dependentSchemas::boolean subschemas::object with property having schema false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "boolean subschemas -> object with both properties is invalid" + * + * Test ID: "dependentSchemas::boolean subschemas::object with both properties is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::boolean subschemas::object with both properties is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "foo": true, + "bar": false + } + } + """, + false, + """ schemaTestId: "dependentSchemas::boolean subschemas::object with both properties is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "boolean subschemas -> empty object is valid" + * + * Test ID: "dependentSchemas::boolean subschemas::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "foo": true, + "bar": false + } + } + """, + true, + """ schemaTestId: "dependentSchemas::boolean subschemas::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "dependencies with escaped characters -> quoted tab" + * + * Test ID: "dependentSchemas::dependencies with escaped characters::quoted tab" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo\tbar": 1, + "a": 2, + "b": 3, + "c": 4 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + } + } + } + """, + true, + """ schemaTestId: "dependentSchemas::dependencies with escaped characters::quoted tab" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "dependencies with escaped characters -> quoted quote" + * + * Test ID: "dependentSchemas::dependencies with escaped characters::quoted quote" + */ + @Test + fun jsonSchemaSuiteTest_14() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::dependencies with escaped characters::quoted quote" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo'bar": { + "foo\"bar": 1 + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + } + } + } + """, + false, + """ schemaTestId: "dependentSchemas::dependencies with escaped characters::quoted quote" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "dependencies with escaped characters -> quoted tab invalid under dependent schema" + * + * Test ID: "dependentSchemas::dependencies with escaped characters::quoted tab invalid under dependent schema" + */ + @Test + fun jsonSchemaSuiteTest_15() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::dependencies with escaped characters::quoted tab invalid under dependent schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo\tbar": 1, + "a": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + } + } + } + """, + false, + """ schemaTestId: "dependentSchemas::dependencies with escaped characters::quoted tab invalid under dependent schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "dependencies with escaped characters -> quoted quote invalid under dependent schema" + * + * Test ID: "dependentSchemas::dependencies with escaped characters::quoted quote invalid under dependent schema" + */ + @Test + fun jsonSchemaSuiteTest_16() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::dependencies with escaped characters::quoted quote invalid under dependent schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo'bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "dependentSchemas": { + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + } + } + } + """, + false, + """ schemaTestId: "dependentSchemas::dependencies with escaped characters::quoted quote invalid under dependent schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "dependent subschema incompatible with root -> matches root" + * + * Test ID: "dependentSchemas::dependent subschema incompatible with root::matches root" + */ + @Test + fun jsonSchemaSuiteTest_17() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::dependent subschema incompatible with root::matches root" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + } + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": { + } + }, + "additionalProperties": false + } + } + } + """, + false, + """ schemaTestId: "dependentSchemas::dependent subschema incompatible with root::matches root" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "dependent subschema incompatible with root -> matches dependency" + * + * Test ID: "dependentSchemas::dependent subschema incompatible with root::matches dependency" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + } + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": { + } + }, + "additionalProperties": false + } + } + } + """, + true, + """ schemaTestId: "dependentSchemas::dependent subschema incompatible with root::matches dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "dependent subschema incompatible with root -> matches both" + * + * Test ID: "dependentSchemas::dependent subschema incompatible with root::matches both" + */ + @Test + fun jsonSchemaSuiteTest_19() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dependentSchemas::dependent subschema incompatible with root::matches both" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + } + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": { + } + }, + "additionalProperties": false + } + } + } + """, + false, + """ schemaTestId: "dependentSchemas::dependent subschema incompatible with root::matches both" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json`: + * "dependent subschema incompatible with root -> no dependency" + * + * Test ID: "dependentSchemas::dependent subschema incompatible with root::no dependency" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "baz": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + } + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": { + } + }, + "additionalProperties": false + } + } + } + """, + true, + """ schemaTestId: "dependentSchemas::dependent subschema incompatible with root::no dependency" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dynamicRef.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dynamicRef.kt new file mode 100644 index 00000000..887c5422 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_dynamicRef.kt @@ -0,0 +1,2202 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_dynamicRef : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor -> An array of strings is valid" + * + * Test ID: "dynamicRef::A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor::An array of strings is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamicRef-dynamicAnchor-same-schema/root", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef to a ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array of strings is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor -> An array containing non-strings is invalid" + * + * Test ID: "dynamicRef::A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor::An array containing non-strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor::An array containing non-strings is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamicRef-dynamicAnchor-same-schema/root", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef to a ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array containing non-strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef to an $anchor in the same schema resource behaves like a normal $ref to an $anchor -> An array of strings is valid" + * + * Test ID: "dynamicRef::A $dynamicRef to an $anchor in the same schema resource behaves like a normal $ref to an $anchor::An array of strings is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamicRef-anchor-same-schema/root", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "foo": { + "${'$'}anchor": "items", + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef to an ${'$'}anchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array of strings is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef to an $anchor in the same schema resource behaves like a normal $ref to an $anchor -> An array containing non-strings is invalid" + * + * Test ID: "dynamicRef::A $dynamicRef to an $anchor in the same schema resource behaves like a normal $ref to an $anchor::An array containing non-strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::A $dynamicRef to an $anchor in the same schema resource behaves like a normal $ref to an $anchor::An array containing non-strings is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamicRef-anchor-same-schema/root", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "foo": { + "${'$'}anchor": "items", + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef to an ${'$'}anchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array containing non-strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor -> An array of strings is valid" + * + * Test ID: "dynamicRef::A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor::An array of strings is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor::An array of strings is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/ref-dynamicAnchor-same-schema/root", + "type": "array", + "items": { + "${'$'}ref": "#items" + }, + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}ref to a ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array of strings is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor -> An array containing non-strings is invalid" + * + * Test ID: "dynamicRef::A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor::An array containing non-strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor::An array containing non-strings is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/ref-dynamicAnchor-same-schema/root", + "type": "array", + "items": { + "${'$'}ref": "#items" + }, + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::A ${'$'}ref to a ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to an ${'$'}anchor::An array containing non-strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef resolves to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated -> An array of strings is valid" + * + * Test ID: "dynamicRef::A $dynamicRef resolves to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated::An array of strings is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/typical-dynamic-resolution/root", + "${'$'}ref": "list", + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "items" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef resolves to the first ${'$'}dynamicAnchor still in scope that is encountered when the schema is evaluated::An array of strings is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef resolves to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated -> An array containing non-strings is invalid" + * + * Test ID: "dynamicRef::A $dynamicRef resolves to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated::An array containing non-strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::A $dynamicRef resolves to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated::An array containing non-strings is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/typical-dynamic-resolution/root", + "${'$'}ref": "list", + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "items" + } + } + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef resolves to the first ${'$'}dynamicAnchor still in scope that is encountered when the schema is evaluated::An array containing non-strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef without anchor in fragment behaves identical to $ref -> An array of strings is invalid" + * + * Test ID: "dynamicRef::A $dynamicRef without anchor in fragment behaves identical to $ref::An array of strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::A $dynamicRef without anchor in fragment behaves identical to $ref::An array of strings is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamicRef-without-anchor/root", + "${'$'}ref": "list", + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#/${'$'}defs/items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "items", + "type": "number" + } + } + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef without anchor in fragment behaves identical to ${'$'}ref::An array of strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef without anchor in fragment behaves identical to $ref -> An array of numbers is valid" + * + * Test ID: "dynamicRef::A $dynamicRef without anchor in fragment behaves identical to $ref::An array of numbers is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + 24, + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamicRef-without-anchor/root", + "${'$'}ref": "list", + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#/${'$'}defs/items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "items", + "type": "number" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef without anchor in fragment behaves identical to ${'$'}ref::An array of numbers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef with intermediate scopes that don't include a matching $dynamicAnchor does not affect dynamic scope resolution -> An array of strings is valid" + * + * Test ID: "dynamicRef::A $dynamicRef with intermediate scopes that don't include a matching $dynamicAnchor does not affect dynamic scope resolution::An array of strings is valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-resolution-with-intermediate-scopes/root", + "${'$'}ref": "intermediate-scope", + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + }, + "intermediate-scope": { + "${'$'}id": "intermediate-scope", + "${'$'}ref": "list" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "items" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef with intermediate scopes that don't include a matching ${'$'}dynamicAnchor does not affect dynamic scope resolution::An array of strings is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef with intermediate scopes that don't include a matching $dynamicAnchor does not affect dynamic scope resolution -> An array containing non-strings is invalid" + * + * Test ID: "dynamicRef::A $dynamicRef with intermediate scopes that don't include a matching $dynamicAnchor does not affect dynamic scope resolution::An array containing non-strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::A $dynamicRef with intermediate scopes that don't include a matching $dynamicAnchor does not affect dynamic scope resolution::An array containing non-strings is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-resolution-with-intermediate-scopes/root", + "${'$'}ref": "intermediate-scope", + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + }, + "intermediate-scope": { + "${'$'}id": "intermediate-scope", + "${'$'}ref": "list" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "items" + } + } + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef with intermediate scopes that don't include a matching ${'$'}dynamicAnchor does not affect dynamic scope resolution::An array containing non-strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "An $anchor with the same name as a $dynamicAnchor is not used for dynamic scope resolution -> Any array is valid" + * + * Test ID: "dynamicRef::An $anchor with the same name as a $dynamicAnchor is not used for dynamic scope resolution::Any array is valid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-resolution-ignores-anchors/root", + "${'$'}ref": "list", + "${'$'}defs": { + "foo": { + "${'$'}anchor": "items", + "type": "string" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "items" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::An ${'$'}anchor with the same name as a ${'$'}dynamicAnchor is not used for dynamic scope resolution::Any array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef without a matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor -> Any array is valid" + * + * Test ID: "dynamicRef::A $dynamicRef without a matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor::Any array is valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-resolution-without-bookend/root", + "${'$'}ref": "list", + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to give the reference somewhere to resolve to when it behaves like ${'$'}ref", + "${'$'}anchor": "items" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef without a matching ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to ${'$'}anchor::Any array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef with a non-matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor -> Any array is valid" + * + * Test ID: "dynamicRef::A $dynamicRef with a non-matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor::Any array is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/unmatched-dynamic-anchor/root", + "${'$'}ref": "list", + "${'$'}defs": { + "foo": { + "${'$'}dynamicAnchor": "items", + "type": "string" + }, + "list": { + "${'$'}id": "list", + "type": "array", + "items": { + "${'$'}dynamicRef": "#items" + }, + "${'$'}defs": { + "items": { + "${'$'}comment": "This is only needed to give the reference somewhere to resolve to when it behaves like ${'$'}ref", + "${'$'}anchor": "items", + "${'$'}dynamicAnchor": "foo" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef with a non-matching ${'$'}dynamicAnchor in the same schema resource behaves like a normal ${'$'}ref to ${'$'}anchor::Any array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef that initially resolves to a schema with a matching $dynamicAnchor resolves to the first $dynamicAnchor in the dynamic scope -> The recursive part is valid against the root" + * + * Test ID: "dynamicRef::A $dynamicRef that initially resolves to a schema with a matching $dynamicAnchor resolves to the first $dynamicAnchor in the dynamic scope::The recursive part is valid against the root" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "foo": "pass", + "bar": { + "baz": { + "foo": "pass" + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/relative-dynamic-reference/root", + "${'$'}dynamicAnchor": "meta", + "type": "object", + "properties": { + "foo": { + "const": "pass" + } + }, + "${'$'}ref": "extended", + "${'$'}defs": { + "extended": { + "${'$'}id": "extended", + "${'$'}dynamicAnchor": "meta", + "type": "object", + "properties": { + "bar": { + "${'$'}ref": "bar" + } + } + }, + "bar": { + "${'$'}id": "bar", + "type": "object", + "properties": { + "baz": { + "${'$'}dynamicRef": "extended#meta" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef that initially resolves to a schema with a matching ${'$'}dynamicAnchor resolves to the first ${'$'}dynamicAnchor in the dynamic scope::The recursive part is valid against the root" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef that initially resolves to a schema with a matching $dynamicAnchor resolves to the first $dynamicAnchor in the dynamic scope -> The recursive part is not valid against the root" + * + * Test ID: "dynamicRef::A $dynamicRef that initially resolves to a schema with a matching $dynamicAnchor resolves to the first $dynamicAnchor in the dynamic scope::The recursive part is not valid against the root" + */ + @Test + fun jsonSchemaSuiteTest_17() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::A $dynamicRef that initially resolves to a schema with a matching $dynamicAnchor resolves to the first $dynamicAnchor in the dynamic scope::The recursive part is not valid against the root" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "pass", + "bar": { + "baz": { + "foo": "fail" + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/relative-dynamic-reference/root", + "${'$'}dynamicAnchor": "meta", + "type": "object", + "properties": { + "foo": { + "const": "pass" + } + }, + "${'$'}ref": "extended", + "${'$'}defs": { + "extended": { + "${'$'}id": "extended", + "${'$'}dynamicAnchor": "meta", + "type": "object", + "properties": { + "bar": { + "${'$'}ref": "bar" + } + } + }, + "bar": { + "${'$'}id": "bar", + "type": "object", + "properties": { + "baz": { + "${'$'}dynamicRef": "extended#meta" + } + } + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef that initially resolves to a schema with a matching ${'$'}dynamicAnchor resolves to the first ${'$'}dynamicAnchor in the dynamic scope::The recursive part is not valid against the root" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "A $dynamicRef that initially resolves to a schema without a matching $dynamicAnchor behaves like a normal $ref to $anchor -> The recursive part doesn't need to validate against the root" + * + * Test ID: "dynamicRef::A $dynamicRef that initially resolves to a schema without a matching $dynamicAnchor behaves like a normal $ref to $anchor::The recursive part doesn't need to validate against the root" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo": "pass", + "bar": { + "baz": { + "foo": "fail" + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/relative-dynamic-reference-without-bookend/root", + "${'$'}dynamicAnchor": "meta", + "type": "object", + "properties": { + "foo": { + "const": "pass" + } + }, + "${'$'}ref": "extended", + "${'$'}defs": { + "extended": { + "${'$'}id": "extended", + "${'$'}anchor": "meta", + "type": "object", + "properties": { + "bar": { + "${'$'}ref": "bar" + } + } + }, + "bar": { + "${'$'}id": "bar", + "type": "object", + "properties": { + "baz": { + "${'$'}dynamicRef": "extended#meta" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::A ${'$'}dynamicRef that initially resolves to a schema without a matching ${'$'}dynamicAnchor behaves like a normal ${'$'}ref to ${'$'}anchor::The recursive part doesn't need to validate against the root" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "multiple dynamic paths to the $dynamicRef keyword -> number list with number values" + * + * Test ID: "dynamicRef::multiple dynamic paths to the $dynamicRef keyword::number list with number values" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "kindOfList": "numbers", + "list": [ + 1.1 + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main", + "if": { + "properties": { + "kindOfList": { + "const": "numbers" + } + }, + "required": [ + "kindOfList" + ] + }, + "then": { + "${'$'}ref": "numberList" + }, + "else": { + "${'$'}ref": "stringList" + }, + "${'$'}defs": { + "genericList": { + "${'$'}id": "genericList", + "properties": { + "list": { + "items": { + "${'$'}dynamicRef": "#itemType" + } + } + }, + "${'$'}defs": { + "defaultItemType": { + "${'$'}comment": "Only needed to satisfy bookending requirement", + "${'$'}dynamicAnchor": "itemType" + } + } + }, + "numberList": { + "${'$'}id": "numberList", + "${'$'}defs": { + "itemType": { + "${'$'}dynamicAnchor": "itemType", + "type": "number" + } + }, + "${'$'}ref": "genericList" + }, + "stringList": { + "${'$'}id": "stringList", + "${'$'}defs": { + "itemType": { + "${'$'}dynamicAnchor": "itemType", + "type": "string" + } + }, + "${'$'}ref": "genericList" + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::multiple dynamic paths to the ${'$'}dynamicRef keyword::number list with number values" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "multiple dynamic paths to the $dynamicRef keyword -> number list with string values" + * + * Test ID: "dynamicRef::multiple dynamic paths to the $dynamicRef keyword::number list with string values" + */ + @Test + fun jsonSchemaSuiteTest_20() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::multiple dynamic paths to the $dynamicRef keyword::number list with string values" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "kindOfList": "numbers", + "list": [ + "foo" + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main", + "if": { + "properties": { + "kindOfList": { + "const": "numbers" + } + }, + "required": [ + "kindOfList" + ] + }, + "then": { + "${'$'}ref": "numberList" + }, + "else": { + "${'$'}ref": "stringList" + }, + "${'$'}defs": { + "genericList": { + "${'$'}id": "genericList", + "properties": { + "list": { + "items": { + "${'$'}dynamicRef": "#itemType" + } + } + }, + "${'$'}defs": { + "defaultItemType": { + "${'$'}comment": "Only needed to satisfy bookending requirement", + "${'$'}dynamicAnchor": "itemType" + } + } + }, + "numberList": { + "${'$'}id": "numberList", + "${'$'}defs": { + "itemType": { + "${'$'}dynamicAnchor": "itemType", + "type": "number" + } + }, + "${'$'}ref": "genericList" + }, + "stringList": { + "${'$'}id": "stringList", + "${'$'}defs": { + "itemType": { + "${'$'}dynamicAnchor": "itemType", + "type": "string" + } + }, + "${'$'}ref": "genericList" + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::multiple dynamic paths to the ${'$'}dynamicRef keyword::number list with string values" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "multiple dynamic paths to the $dynamicRef keyword -> string list with number values" + * + * Test ID: "dynamicRef::multiple dynamic paths to the $dynamicRef keyword::string list with number values" + */ + @Test + fun jsonSchemaSuiteTest_21() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::multiple dynamic paths to the $dynamicRef keyword::string list with number values" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "kindOfList": "strings", + "list": [ + 1.1 + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main", + "if": { + "properties": { + "kindOfList": { + "const": "numbers" + } + }, + "required": [ + "kindOfList" + ] + }, + "then": { + "${'$'}ref": "numberList" + }, + "else": { + "${'$'}ref": "stringList" + }, + "${'$'}defs": { + "genericList": { + "${'$'}id": "genericList", + "properties": { + "list": { + "items": { + "${'$'}dynamicRef": "#itemType" + } + } + }, + "${'$'}defs": { + "defaultItemType": { + "${'$'}comment": "Only needed to satisfy bookending requirement", + "${'$'}dynamicAnchor": "itemType" + } + } + }, + "numberList": { + "${'$'}id": "numberList", + "${'$'}defs": { + "itemType": { + "${'$'}dynamicAnchor": "itemType", + "type": "number" + } + }, + "${'$'}ref": "genericList" + }, + "stringList": { + "${'$'}id": "stringList", + "${'$'}defs": { + "itemType": { + "${'$'}dynamicAnchor": "itemType", + "type": "string" + } + }, + "${'$'}ref": "genericList" + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::multiple dynamic paths to the ${'$'}dynamicRef keyword::string list with number values" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "multiple dynamic paths to the $dynamicRef keyword -> string list with string values" + * + * Test ID: "dynamicRef::multiple dynamic paths to the $dynamicRef keyword::string list with string values" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + { + "kindOfList": "strings", + "list": [ + "foo" + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main", + "if": { + "properties": { + "kindOfList": { + "const": "numbers" + } + }, + "required": [ + "kindOfList" + ] + }, + "then": { + "${'$'}ref": "numberList" + }, + "else": { + "${'$'}ref": "stringList" + }, + "${'$'}defs": { + "genericList": { + "${'$'}id": "genericList", + "properties": { + "list": { + "items": { + "${'$'}dynamicRef": "#itemType" + } + } + }, + "${'$'}defs": { + "defaultItemType": { + "${'$'}comment": "Only needed to satisfy bookending requirement", + "${'$'}dynamicAnchor": "itemType" + } + } + }, + "numberList": { + "${'$'}id": "numberList", + "${'$'}defs": { + "itemType": { + "${'$'}dynamicAnchor": "itemType", + "type": "number" + } + }, + "${'$'}ref": "genericList" + }, + "stringList": { + "${'$'}id": "stringList", + "${'$'}defs": { + "itemType": { + "${'$'}dynamicAnchor": "itemType", + "type": "string" + } + }, + "${'$'}ref": "genericList" + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::multiple dynamic paths to the ${'$'}dynamicRef keyword::string list with string values" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "after leaving a dynamic scope, it is not used by a $dynamicRef -> string matches /$defs/thingy, but the $dynamicRef does not stop here" + * + * Test ID: "dynamicRef::after leaving a dynamic scope, it is not used by a $dynamicRef::string matches /$defs/thingy, but the $dynamicRef does not stop here" + */ + @Test + fun jsonSchemaSuiteTest_23() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::after leaving a dynamic scope, it is not used by a $dynamicRef::string matches /$defs/thingy, but the $dynamicRef does not stop here" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a string" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-leaving-dynamic-scope/main", + "if": { + "${'$'}id": "first_scope", + "${'$'}defs": { + "thingy": { + "${'$'}comment": "this is first_scope#thingy", + "${'$'}dynamicAnchor": "thingy", + "type": "number" + } + } + }, + "then": { + "${'$'}id": "second_scope", + "${'$'}ref": "start", + "${'$'}defs": { + "thingy": { + "${'$'}comment": "this is second_scope#thingy, the final destination of the ${'$'}dynamicRef", + "${'$'}dynamicAnchor": "thingy", + "type": "null" + } + } + }, + "${'$'}defs": { + "start": { + "${'$'}comment": "this is the landing spot from ${'$'}ref", + "${'$'}id": "start", + "${'$'}dynamicRef": "inner_scope#thingy" + }, + "thingy": { + "${'$'}comment": "this is the first stop for the ${'$'}dynamicRef", + "${'$'}id": "inner_scope", + "${'$'}dynamicAnchor": "thingy", + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::after leaving a dynamic scope, it is not used by a ${'$'}dynamicRef::string matches /${'$'}defs/thingy, but the ${'$'}dynamicRef does not stop here" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "after leaving a dynamic scope, it is not used by a $dynamicRef -> first_scope is not in dynamic scope for the $dynamicRef" + * + * Test ID: "dynamicRef::after leaving a dynamic scope, it is not used by a $dynamicRef::first_scope is not in dynamic scope for the $dynamicRef" + */ + @Test + fun jsonSchemaSuiteTest_24() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::after leaving a dynamic scope, it is not used by a $dynamicRef::first_scope is not in dynamic scope for the $dynamicRef" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 42 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-leaving-dynamic-scope/main", + "if": { + "${'$'}id": "first_scope", + "${'$'}defs": { + "thingy": { + "${'$'}comment": "this is first_scope#thingy", + "${'$'}dynamicAnchor": "thingy", + "type": "number" + } + } + }, + "then": { + "${'$'}id": "second_scope", + "${'$'}ref": "start", + "${'$'}defs": { + "thingy": { + "${'$'}comment": "this is second_scope#thingy, the final destination of the ${'$'}dynamicRef", + "${'$'}dynamicAnchor": "thingy", + "type": "null" + } + } + }, + "${'$'}defs": { + "start": { + "${'$'}comment": "this is the landing spot from ${'$'}ref", + "${'$'}id": "start", + "${'$'}dynamicRef": "inner_scope#thingy" + }, + "thingy": { + "${'$'}comment": "this is the first stop for the ${'$'}dynamicRef", + "${'$'}id": "inner_scope", + "${'$'}dynamicAnchor": "thingy", + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::after leaving a dynamic scope, it is not used by a ${'$'}dynamicRef::first_scope is not in dynamic scope for the ${'$'}dynamicRef" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "after leaving a dynamic scope, it is not used by a $dynamicRef -> /then/$defs/thingy is the final stop for the $dynamicRef" + * + * Test ID: "dynamicRef::after leaving a dynamic scope, it is not used by a $dynamicRef::/then/$defs/thingy is the final stop for the $dynamicRef" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-leaving-dynamic-scope/main", + "if": { + "${'$'}id": "first_scope", + "${'$'}defs": { + "thingy": { + "${'$'}comment": "this is first_scope#thingy", + "${'$'}dynamicAnchor": "thingy", + "type": "number" + } + } + }, + "then": { + "${'$'}id": "second_scope", + "${'$'}ref": "start", + "${'$'}defs": { + "thingy": { + "${'$'}comment": "this is second_scope#thingy, the final destination of the ${'$'}dynamicRef", + "${'$'}dynamicAnchor": "thingy", + "type": "null" + } + } + }, + "${'$'}defs": { + "start": { + "${'$'}comment": "this is the landing spot from ${'$'}ref", + "${'$'}id": "start", + "${'$'}dynamicRef": "inner_scope#thingy" + }, + "thingy": { + "${'$'}comment": "this is the first stop for the ${'$'}dynamicRef", + "${'$'}id": "inner_scope", + "${'$'}dynamicAnchor": "thingy", + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::after leaving a dynamic scope, it is not used by a ${'$'}dynamicRef::/then/${'$'}defs/thingy is the final stop for the ${'$'}dynamicRef" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "strict-tree schema, guards against misspelled properties -> instance with misspelled field" + * + * Test ID: "dynamicRef::strict-tree schema, guards against misspelled properties::instance with misspelled field" + */ + @Test + fun jsonSchemaSuiteTest_26() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::strict-tree schema, guards against misspelled properties::instance with misspelled field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "children": [ + { + "daat": 1 + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-tree.json", + "${'$'}dynamicAnchor": "node", + "${'$'}ref": "tree.json", + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "dynamicRef::strict-tree schema, guards against misspelled properties::instance with misspelled field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "strict-tree schema, guards against misspelled properties -> instance with correct field" + * + * Test ID: "dynamicRef::strict-tree schema, guards against misspelled properties::instance with correct field" + */ + @Test + fun jsonSchemaSuiteTest_27() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::strict-tree schema, guards against misspelled properties::instance with correct field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "children": [ + { + "data": 1 + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-tree.json", + "${'$'}dynamicAnchor": "node", + "${'$'}ref": "tree.json", + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "dynamicRef::strict-tree schema, guards against misspelled properties::instance with correct field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "tests for implementation dynamic anchor and reference link -> incorrect parent schema" + * + * Test ID: "dynamicRef::tests for implementation dynamic anchor and reference link::incorrect parent schema" + */ + @Test + fun jsonSchemaSuiteTest_28() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::tests for implementation dynamic anchor and reference link::incorrect parent schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "a": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible.json", + "${'$'}ref": "extendible-dynamic-ref.json", + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::tests for implementation dynamic anchor and reference link::incorrect parent schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "tests for implementation dynamic anchor and reference link -> incorrect extended schema" + * + * Test ID: "dynamicRef::tests for implementation dynamic anchor and reference link::incorrect extended schema" + */ + @Test + fun jsonSchemaSuiteTest_29() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::tests for implementation dynamic anchor and reference link::incorrect extended schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "elements": [ + { + "b": 1 + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible.json", + "${'$'}ref": "extendible-dynamic-ref.json", + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::tests for implementation dynamic anchor and reference link::incorrect extended schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "tests for implementation dynamic anchor and reference link -> correct extended schema" + * + * Test ID: "dynamicRef::tests for implementation dynamic anchor and reference link::correct extended schema" + */ + @Test + fun jsonSchemaSuiteTest_30() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::tests for implementation dynamic anchor and reference link::correct extended schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "elements": [ + { + "a": 1 + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible.json", + "${'$'}ref": "extendible-dynamic-ref.json", + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::tests for implementation dynamic anchor and reference link::correct extended schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$ref and $dynamicAnchor are independent of order - $defs first -> incorrect parent schema" + * + * Test ID: "dynamicRef::$ref and $dynamicAnchor are independent of order - $defs first::incorrect parent schema" + */ + @Test + fun jsonSchemaSuiteTest_31() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$ref and $dynamicAnchor are independent of order - $defs first::incorrect parent schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "a": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible-allof-defs-first.json", + "allOf": [ + { + "${'$'}ref": "extendible-dynamic-ref.json" + }, + { + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + } + ] + } + """, + false, + """ schemaTestId: "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}defs first::incorrect parent schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$ref and $dynamicAnchor are independent of order - $defs first -> incorrect extended schema" + * + * Test ID: "dynamicRef::$ref and $dynamicAnchor are independent of order - $defs first::incorrect extended schema" + */ + @Test + fun jsonSchemaSuiteTest_32() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$ref and $dynamicAnchor are independent of order - $defs first::incorrect extended schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "elements": [ + { + "b": 1 + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible-allof-defs-first.json", + "allOf": [ + { + "${'$'}ref": "extendible-dynamic-ref.json" + }, + { + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + } + ] + } + """, + false, + """ schemaTestId: "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}defs first::incorrect extended schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$ref and $dynamicAnchor are independent of order - $defs first -> correct extended schema" + * + * Test ID: "dynamicRef::$ref and $dynamicAnchor are independent of order - $defs first::correct extended schema" + */ + @Test + fun jsonSchemaSuiteTest_33() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$ref and $dynamicAnchor are independent of order - $defs first::correct extended schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "elements": [ + { + "a": 1 + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible-allof-defs-first.json", + "allOf": [ + { + "${'$'}ref": "extendible-dynamic-ref.json" + }, + { + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + } + ] + } + """, + true, + """ schemaTestId: "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}defs first::correct extended schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$ref and $dynamicAnchor are independent of order - $ref first -> incorrect parent schema" + * + * Test ID: "dynamicRef::$ref and $dynamicAnchor are independent of order - $ref first::incorrect parent schema" + */ + @Test + fun jsonSchemaSuiteTest_34() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$ref and $dynamicAnchor are independent of order - $ref first::incorrect parent schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "a": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible-allof-ref-first.json", + "allOf": [ + { + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + }, + { + "${'$'}ref": "extendible-dynamic-ref.json" + } + ] + } + """, + false, + """ schemaTestId: "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}ref first::incorrect parent schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$ref and $dynamicAnchor are independent of order - $ref first -> incorrect extended schema" + * + * Test ID: "dynamicRef::$ref and $dynamicAnchor are independent of order - $ref first::incorrect extended schema" + */ + @Test + fun jsonSchemaSuiteTest_35() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$ref and $dynamicAnchor are independent of order - $ref first::incorrect extended schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "elements": [ + { + "b": 1 + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible-allof-ref-first.json", + "allOf": [ + { + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + }, + { + "${'$'}ref": "extendible-dynamic-ref.json" + } + ] + } + """, + false, + """ schemaTestId: "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}ref first::incorrect extended schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$ref and $dynamicAnchor are independent of order - $ref first -> correct extended schema" + * + * Test ID: "dynamicRef::$ref and $dynamicAnchor are independent of order - $ref first::correct extended schema" + */ + @Test + fun jsonSchemaSuiteTest_36() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$ref and $dynamicAnchor are independent of order - $ref first::correct extended schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "elements": [ + { + "a": 1 + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/strict-extendible-allof-ref-first.json", + "allOf": [ + { + "${'$'}defs": { + "elements": { + "${'$'}dynamicAnchor": "elements", + "properties": { + "a": true + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + }, + { + "${'$'}ref": "extendible-dynamic-ref.json" + } + ] + } + """, + true, + """ schemaTestId: "dynamicRef::${'$'}ref and ${'$'}dynamicAnchor are independent of order - ${'$'}ref first::correct extended schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$ref to $dynamicRef finds detached $dynamicAnchor -> number is valid" + * + * Test ID: "dynamicRef::$ref to $dynamicRef finds detached $dynamicAnchor::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$ref to $dynamicRef finds detached $dynamicAnchor::number is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}ref": "http://localhost:1234/draft2020-12/detached-dynamicref.json#/${'$'}defs/foo" + } + """, + true, + """ schemaTestId: "dynamicRef::${'$'}ref to ${'$'}dynamicRef finds detached ${'$'}dynamicAnchor::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$ref to $dynamicRef finds detached $dynamicAnchor -> non-number is invalid" + * + * Test ID: "dynamicRef::$ref to $dynamicRef finds detached $dynamicAnchor::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$ref to $dynamicRef finds detached $dynamicAnchor::non-number is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}ref": "http://localhost:1234/draft2020-12/detached-dynamicref.json#/${'$'}defs/foo" + } + """, + false, + """ schemaTestId: "dynamicRef::${'$'}ref to ${'$'}dynamicRef finds detached ${'$'}dynamicAnchor::non-number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$dynamicRef points to a boolean schema -> follow $dynamicRef to a true schema" + * + * Test ID: "dynamicRef::$dynamicRef points to a boolean schema::follow $dynamicRef to a true schema" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + { + "true": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "true": true, + "false": false + }, + "properties": { + "true": { + "${'$'}dynamicRef": "#/${'$'}defs/true" + }, + "false": { + "${'$'}dynamicRef": "#/${'$'}defs/false" + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::${'$'}dynamicRef points to a boolean schema::follow ${'$'}dynamicRef to a true schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$dynamicRef points to a boolean schema -> follow $dynamicRef to a false schema" + * + * Test ID: "dynamicRef::$dynamicRef points to a boolean schema::follow $dynamicRef to a false schema" + */ + @Test + fun jsonSchemaSuiteTest_40() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$dynamicRef points to a boolean schema::follow $dynamicRef to a false schema" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "false": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "true": true, + "false": false + }, + "properties": { + "true": { + "${'$'}dynamicRef": "#/${'$'}defs/true" + }, + "false": { + "${'$'}dynamicRef": "#/${'$'}defs/false" + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::${'$'}dynamicRef points to a boolean schema::follow ${'$'}dynamicRef to a false schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$dynamicRef skips over intermediate resources - direct reference -> integer property passes" + * + * Test ID: "dynamicRef::$dynamicRef skips over intermediate resources - direct reference::integer property passes" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + { + "bar-item": { + "content": 42 + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-skips-intermediate-resource/main", + "type": "object", + "properties": { + "bar-item": { + "${'$'}ref": "item" + } + }, + "${'$'}defs": { + "bar": { + "${'$'}id": "bar", + "type": "array", + "items": { + "${'$'}ref": "item" + }, + "${'$'}defs": { + "item": { + "${'$'}id": "item", + "type": "object", + "properties": { + "content": { + "${'$'}dynamicRef": "#content" + } + }, + "${'$'}defs": { + "defaultContent": { + "${'$'}dynamicAnchor": "content", + "type": "integer" + } + } + }, + "content": { + "${'$'}dynamicAnchor": "content", + "type": "string" + } + } + } + } + } + """, + true, + """ schemaTestId: "dynamicRef::${'$'}dynamicRef skips over intermediate resources - direct reference::integer property passes" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json`: + * "$dynamicRef skips over intermediate resources - direct reference -> string property fails" + * + * Test ID: "dynamicRef::$dynamicRef skips over intermediate resources - direct reference::string property fails" + */ + @Test + fun jsonSchemaSuiteTest_42() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "dynamicRef::$dynamicRef skips over intermediate resources - direct reference::string property fails" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar-item": { + "content": "value" + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://test.json-schema.org/dynamic-ref-skips-intermediate-resource/main", + "type": "object", + "properties": { + "bar-item": { + "${'$'}ref": "item" + } + }, + "${'$'}defs": { + "bar": { + "${'$'}id": "bar", + "type": "array", + "items": { + "${'$'}ref": "item" + }, + "${'$'}defs": { + "item": { + "${'$'}id": "item", + "type": "object", + "properties": { + "content": { + "${'$'}dynamicRef": "#content" + } + }, + "${'$'}defs": { + "defaultContent": { + "${'$'}dynamicAnchor": "content", + "type": "integer" + } + } + }, + "content": { + "${'$'}dynamicAnchor": "content", + "type": "string" + } + } + } + } + } + """, + false, + """ schemaTestId: "dynamicRef::${'$'}dynamicRef skips over intermediate resources - direct reference::string property fails" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_enum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_enum.kt new file mode 100644 index 00000000..1093b7f9 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_enum.kt @@ -0,0 +1,1333 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_enum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "simple enum validation -> one of the enum is valid" + * + * Test ID: "enum::simple enum validation::one of the enum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 1, + 2, + 3 + ] + } + """, + true, + """ schemaTestId: "enum::simple enum validation::one of the enum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "simple enum validation -> something else is invalid" + * + * Test ID: "enum::simple enum validation::something else is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 4 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 1, + 2, + 3 + ] + } + """, + false, + """ schemaTestId: "enum::simple enum validation::something else is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "heterogeneous enum validation -> one of the enum is valid" + * + * Test ID: "enum::heterogeneous enum validation::one of the enum is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + true, + """ schemaTestId: "enum::heterogeneous enum validation::one of the enum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "heterogeneous enum validation -> something else is invalid" + * + * Test ID: "enum::heterogeneous enum validation::something else is invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + false, + """ schemaTestId: "enum::heterogeneous enum validation::something else is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "heterogeneous enum validation -> objects are deep compared" + * + * Test ID: "enum::heterogeneous enum validation::objects are deep compared" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "foo": false + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + false, + """ schemaTestId: "enum::heterogeneous enum validation::objects are deep compared" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "heterogeneous enum validation -> valid object matches" + * + * Test ID: "enum::heterogeneous enum validation::valid object matches" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + true, + """ schemaTestId: "enum::heterogeneous enum validation::valid object matches" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "heterogeneous enum validation -> extra properties in object is invalid" + * + * Test ID: "enum::heterogeneous enum validation::extra properties in object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12, + "boo": 42 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + false, + """ schemaTestId: "enum::heterogeneous enum validation::extra properties in object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "heterogeneous enum-with-null validation -> null is valid" + * + * Test ID: "enum::heterogeneous enum-with-null validation::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 6, + null + ] + } + """, + true, + """ schemaTestId: "enum::heterogeneous enum-with-null validation::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "heterogeneous enum-with-null validation -> number is valid" + * + * Test ID: "enum::heterogeneous enum-with-null validation::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + 6 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 6, + null + ] + } + """, + true, + """ schemaTestId: "enum::heterogeneous enum-with-null validation::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "heterogeneous enum-with-null validation -> something else is invalid" + * + * Test ID: "enum::heterogeneous enum-with-null validation::something else is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + "test" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 6, + null + ] + } + """, + false, + """ schemaTestId: "enum::heterogeneous enum-with-null validation::something else is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enums in properties -> both properties are valid" + * + * Test ID: "enum::enums in properties::both properties are valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + true, + """ schemaTestId: "enum::enums in properties::both properties are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enums in properties -> wrong foo value" + * + * Test ID: "enum::enums in properties::wrong foo value" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foot", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + false, + """ schemaTestId: "enum::enums in properties::wrong foo value" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enums in properties -> wrong bar value" + * + * Test ID: "enum::enums in properties::wrong bar value" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bart" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + false, + """ schemaTestId: "enum::enums in properties::wrong bar value" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enums in properties -> missing optional property is valid" + * + * Test ID: "enum::enums in properties::missing optional property is valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + true, + """ schemaTestId: "enum::enums in properties::missing optional property is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enums in properties -> missing required property is invalid" + * + * Test ID: "enum::enums in properties::missing required property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + false, + """ schemaTestId: "enum::enums in properties::missing required property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enums in properties -> missing all properties is invalid" + * + * Test ID: "enum::enums in properties::missing all properties is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + false, + """ schemaTestId: "enum::enums in properties::missing all properties is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with escaped characters -> member 1 is valid" + * + * Test ID: "enum::enum with escaped characters::member 1 is valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + "foo\nbar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + "foo\nbar", + "foo\rbar" + ] + } + """, + true, + """ schemaTestId: "enum::enum with escaped characters::member 1 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with escaped characters -> member 2 is valid" + * + * Test ID: "enum::enum with escaped characters::member 2 is valid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + "foo\rbar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + "foo\nbar", + "foo\rbar" + ] + } + """, + true, + """ schemaTestId: "enum::enum with escaped characters::member 2 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with escaped characters -> another string is invalid" + * + * Test ID: "enum::enum with escaped characters::another string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + "abc" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + "foo\nbar", + "foo\rbar" + ] + } + """, + false, + """ schemaTestId: "enum::enum with escaped characters::another string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with false does not match 0 -> false is valid" + * + * Test ID: "enum::enum with false does not match 0::false is valid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + false + ] + } + """, + true, + """ schemaTestId: "enum::enum with false does not match 0::false is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with false does not match 0 -> integer zero is invalid" + * + * Test ID: "enum::enum with false does not match 0::integer zero is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + false + ] + } + """, + false, + """ schemaTestId: "enum::enum with false does not match 0::integer zero is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with false does not match 0 -> float zero is invalid" + * + * Test ID: "enum::enum with false does not match 0::float zero is invalid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + 0.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + false + ] + } + """, + false, + """ schemaTestId: "enum::enum with false does not match 0::float zero is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [false] does not match [0] -> [false] is valid" + * + * Test ID: "enum::enum with [false] does not match [0]::[false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + [ + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + false + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [false] does not match [0]::[false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [false] does not match [0] -> [0] is invalid" + * + * Test ID: "enum::enum with [false] does not match [0]::[0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + [ + 0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + false + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [false] does not match [0]::[0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [false] does not match [0] -> [0.0] is invalid" + * + * Test ID: "enum::enum with [false] does not match [0]::[0.0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + 0.0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + false + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [false] does not match [0]::[0.0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with true does not match 1 -> true is valid" + * + * Test ID: "enum::enum with true does not match 1::true is valid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + true + ] + } + """, + true, + """ schemaTestId: "enum::enum with true does not match 1::true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with true does not match 1 -> integer one is invalid" + * + * Test ID: "enum::enum with true does not match 1::integer one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + true + ] + } + """, + false, + """ schemaTestId: "enum::enum with true does not match 1::integer one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with true does not match 1 -> float one is invalid" + * + * Test ID: "enum::enum with true does not match 1::float one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + true + ] + } + """, + false, + """ schemaTestId: "enum::enum with true does not match 1::float one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [true] does not match [1] -> [true] is valid" + * + * Test ID: "enum::enum with [true] does not match [1]::[true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + [ + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + true + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [true] does not match [1]::[true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [true] does not match [1] -> [1] is invalid" + * + * Test ID: "enum::enum with [true] does not match [1]::[1] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + true + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [true] does not match [1]::[1] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [true] does not match [1] -> [1.0] is invalid" + * + * Test ID: "enum::enum with [true] does not match [1]::[1.0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + [ + 1.0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + true + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [true] does not match [1]::[1.0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with 0 does not match false -> false is invalid" + * + * Test ID: "enum::enum with 0 does not match false::false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 0 + ] + } + """, + false, + """ schemaTestId: "enum::enum with 0 does not match false::false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with 0 does not match false -> integer zero is valid" + * + * Test ID: "enum::enum with 0 does not match false::integer zero is valid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 0 + ] + } + """, + true, + """ schemaTestId: "enum::enum with 0 does not match false::integer zero is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with 0 does not match false -> float zero is valid" + * + * Test ID: "enum::enum with 0 does not match false::float zero is valid" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + 0.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 0 + ] + } + """, + true, + """ schemaTestId: "enum::enum with 0 does not match false::float zero is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [0] does not match [false] -> [false] is invalid" + * + * Test ID: "enum::enum with [0] does not match [false]::[false] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + [ + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + 0 + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [0] does not match [false]::[false] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [0] does not match [false] -> [0] is valid" + * + * Test ID: "enum::enum with [0] does not match [false]::[0] is valid" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + [ + 0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + 0 + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [0] does not match [false]::[0] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [0] does not match [false] -> [0.0] is valid" + * + * Test ID: "enum::enum with [0] does not match [false]::[0.0] is valid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + [ + 0.0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + 0 + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [0] does not match [false]::[0.0] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with 1 does not match true -> true is invalid" + * + * Test ID: "enum::enum with 1 does not match true::true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 1 + ] + } + """, + false, + """ schemaTestId: "enum::enum with 1 does not match true::true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with 1 does not match true -> integer one is valid" + * + * Test ID: "enum::enum with 1 does not match true::integer one is valid" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 1 + ] + } + """, + true, + """ schemaTestId: "enum::enum with 1 does not match true::integer one is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with 1 does not match true -> float one is valid" + * + * Test ID: "enum::enum with 1 does not match true::float one is valid" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + 1 + ] + } + """, + true, + """ schemaTestId: "enum::enum with 1 does not match true::float one is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [1] does not match [true] -> [true] is invalid" + * + * Test ID: "enum::enum with [1] does not match [true]::[true] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + [ + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + 1 + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [1] does not match [true]::[true] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [1] does not match [true] -> [1] is valid" + * + * Test ID: "enum::enum with [1] does not match [true]::[1] is valid" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + 1 + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [1] does not match [true]::[1] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "enum with [1] does not match [true] -> [1.0] is valid" + * + * Test ID: "enum::enum with [1] does not match [true]::[1.0] is valid" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + [ + 1.0 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + [ + 1 + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [1] does not match [true]::[1.0] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "nul characters in strings -> match string with nul" + * + * Test ID: "enum::nul characters in strings::match string with nul" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + "hello\u0000there" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + "hello\u0000there" + ] + } + """, + true, + """ schemaTestId: "enum::nul characters in strings::match string with nul" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/enum.json`: + * "nul characters in strings -> do not match string lacking nul" + * + * Test ID: "enum::nul characters in strings::do not match string lacking nul" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + "hellothere" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "enum": [ + "hello\u0000there" + ] + } + """, + false, + """ schemaTestId: "enum::nul characters in strings::do not match string lacking nul" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_exclusiveMaximum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_exclusiveMaximum.kt new file mode 100644 index 00000000..e73f9cd3 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_exclusiveMaximum.kt @@ -0,0 +1,107 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_exclusiveMaximum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMaximum.json`: + * "exclusiveMaximum validation -> below the exclusiveMaximum is valid" + * + * Test ID: "exclusiveMaximum::exclusiveMaximum validation::below the exclusiveMaximum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 2.2 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "exclusiveMaximum": 3.0 + } + """, + true, + """ schemaTestId: "exclusiveMaximum::exclusiveMaximum validation::below the exclusiveMaximum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMaximum.json`: + * "exclusiveMaximum validation -> boundary point is invalid" + * + * Test ID: "exclusiveMaximum::exclusiveMaximum validation::boundary point is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 3.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "exclusiveMaximum": 3.0 + } + """, + false, + """ schemaTestId: "exclusiveMaximum::exclusiveMaximum validation::boundary point is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMaximum.json`: + * "exclusiveMaximum validation -> above the exclusiveMaximum is invalid" + * + * Test ID: "exclusiveMaximum::exclusiveMaximum validation::above the exclusiveMaximum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 3.5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "exclusiveMaximum": 3.0 + } + """, + false, + """ schemaTestId: "exclusiveMaximum::exclusiveMaximum validation::above the exclusiveMaximum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMaximum.json`: + * "exclusiveMaximum validation -> ignores non-numbers" + * + * Test ID: "exclusiveMaximum::exclusiveMaximum validation::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "exclusiveMaximum": 3.0 + } + """, + true, + """ schemaTestId: "exclusiveMaximum::exclusiveMaximum validation::ignores non-numbers" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_exclusiveMinimum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_exclusiveMinimum.kt new file mode 100644 index 00000000..3ccd97f3 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_exclusiveMinimum.kt @@ -0,0 +1,107 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_exclusiveMinimum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMinimum.json`: + * "exclusiveMinimum validation -> above the exclusiveMinimum is valid" + * + * Test ID: "exclusiveMinimum::exclusiveMinimum validation::above the exclusiveMinimum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1.2 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "exclusiveMinimum": 1.1 + } + """, + true, + """ schemaTestId: "exclusiveMinimum::exclusiveMinimum validation::above the exclusiveMinimum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMinimum.json`: + * "exclusiveMinimum validation -> boundary point is invalid" + * + * Test ID: "exclusiveMinimum::exclusiveMinimum validation::boundary point is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "exclusiveMinimum": 1.1 + } + """, + false, + """ schemaTestId: "exclusiveMinimum::exclusiveMinimum validation::boundary point is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMinimum.json`: + * "exclusiveMinimum validation -> below the exclusiveMinimum is invalid" + * + * Test ID: "exclusiveMinimum::exclusiveMinimum validation::below the exclusiveMinimum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 0.6 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "exclusiveMinimum": 1.1 + } + """, + false, + """ schemaTestId: "exclusiveMinimum::exclusiveMinimum validation::below the exclusiveMinimum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMinimum.json`: + * "exclusiveMinimum validation -> ignores non-numbers" + * + * Test ID: "exclusiveMinimum::exclusiveMinimum validation::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "exclusiveMinimum": 1.1 + } + """, + true, + """ schemaTestId: "exclusiveMinimum::exclusiveMinimum validation::ignores non-numbers" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_format.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_format.kt new file mode 100644 index 00000000..e6652a1f --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_format.kt @@ -0,0 +1,3112 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_format : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "email format -> all string formats ignore integers" + * + * Test ID: "format::email format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "email format -> all string formats ignore floats" + * + * Test ID: "format::email format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "email format -> all string formats ignore objects" + * + * Test ID: "format::email format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "email format -> all string formats ignore arrays" + * + * Test ID: "format::email format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "email format -> all string formats ignore booleans" + * + * Test ID: "format::email format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "email format -> all string formats ignore nulls" + * + * Test ID: "format::email format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "email format -> invalid email string is only an annotation by default" + * + * Test ID: "format::email format::invalid email string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "2962" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::invalid email string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-email format -> all string formats ignore integers" + * + * Test ID: "format::idn-email format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-email format -> all string formats ignore floats" + * + * Test ID: "format::idn-email format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-email format -> all string formats ignore objects" + * + * Test ID: "format::idn-email format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-email format -> all string formats ignore arrays" + * + * Test ID: "format::idn-email format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-email format -> all string formats ignore booleans" + * + * Test ID: "format::idn-email format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-email format -> all string formats ignore nulls" + * + * Test ID: "format::idn-email format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-email format -> invalid idn-email string is only an annotation by default" + * + * Test ID: "format::idn-email format::invalid idn-email string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + "2962" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::invalid idn-email string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "regex format -> all string formats ignore integers" + * + * Test ID: "format::regex format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "regex format -> all string formats ignore floats" + * + * Test ID: "format::regex format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "regex format -> all string formats ignore objects" + * + * Test ID: "format::regex format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "regex format -> all string formats ignore arrays" + * + * Test ID: "format::regex format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "regex format -> all string formats ignore booleans" + * + * Test ID: "format::regex format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "regex format -> all string formats ignore nulls" + * + * Test ID: "format::regex format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "regex format -> invalid regex string is only an annotation by default" + * + * Test ID: "format::regex format::invalid regex string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + "^(abc]" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::invalid regex string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv4 format -> all string formats ignore integers" + * + * Test ID: "format::ipv4 format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv4 format -> all string formats ignore floats" + * + * Test ID: "format::ipv4 format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv4 format -> all string formats ignore objects" + * + * Test ID: "format::ipv4 format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv4 format -> all string formats ignore arrays" + * + * Test ID: "format::ipv4 format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv4 format -> all string formats ignore booleans" + * + * Test ID: "format::ipv4 format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv4 format -> all string formats ignore nulls" + * + * Test ID: "format::ipv4 format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv4 format -> invalid ipv4 string is only an annotation by default" + * + * Test ID: "format::ipv4 format::invalid ipv4 string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + "127.0.0.0.1" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::invalid ipv4 string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv6 format -> all string formats ignore integers" + * + * Test ID: "format::ipv6 format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv6 format -> all string formats ignore floats" + * + * Test ID: "format::ipv6 format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv6 format -> all string formats ignore objects" + * + * Test ID: "format::ipv6 format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv6 format -> all string formats ignore arrays" + * + * Test ID: "format::ipv6 format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv6 format -> all string formats ignore booleans" + * + * Test ID: "format::ipv6 format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv6 format -> all string formats ignore nulls" + * + * Test ID: "format::ipv6 format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "ipv6 format -> invalid ipv6 string is only an annotation by default" + * + * Test ID: "format::ipv6 format::invalid ipv6 string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + "12345::" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::invalid ipv6 string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-hostname format -> all string formats ignore integers" + * + * Test ID: "format::idn-hostname format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-hostname format -> all string formats ignore floats" + * + * Test ID: "format::idn-hostname format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-hostname format -> all string formats ignore objects" + * + * Test ID: "format::idn-hostname format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-hostname format -> all string formats ignore arrays" + * + * Test ID: "format::idn-hostname format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-hostname format -> all string formats ignore booleans" + * + * Test ID: "format::idn-hostname format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-hostname format -> all string formats ignore nulls" + * + * Test ID: "format::idn-hostname format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "idn-hostname format -> invalid idn-hostname string is only an annotation by default" + * + * Test ID: "format::idn-hostname format::invalid idn-hostname string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + "〮실례.테스트" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::invalid idn-hostname string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "hostname format -> all string formats ignore integers" + * + * Test ID: "format::hostname format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "hostname format -> all string formats ignore floats" + * + * Test ID: "format::hostname format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "hostname format -> all string formats ignore objects" + * + * Test ID: "format::hostname format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "hostname format -> all string formats ignore arrays" + * + * Test ID: "format::hostname format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "hostname format -> all string formats ignore booleans" + * + * Test ID: "format::hostname format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "hostname format -> all string formats ignore nulls" + * + * Test ID: "format::hostname format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "hostname format -> invalid hostname string is only an annotation by default" + * + * Test ID: "format::hostname format::invalid hostname string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + "-a-host-name-that-starts-with--" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::invalid hostname string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date format -> all string formats ignore integers" + * + * Test ID: "format::date format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date format -> all string formats ignore floats" + * + * Test ID: "format::date format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date format -> all string formats ignore objects" + * + * Test ID: "format::date format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date format -> all string formats ignore arrays" + * + * Test ID: "format::date format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date format -> all string formats ignore booleans" + * + * Test ID: "format::date format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date format -> all string formats ignore nulls" + * + * Test ID: "format::date format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date format -> invalid date string is only an annotation by default" + * + * Test ID: "format::date format::invalid date string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + "06/19/1963" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::invalid date string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date-time format -> all string formats ignore integers" + * + * Test ID: "format::date-time format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_57() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date-time format -> all string formats ignore floats" + * + * Test ID: "format::date-time format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date-time format -> all string formats ignore objects" + * + * Test ID: "format::date-time format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date-time format -> all string formats ignore arrays" + * + * Test ID: "format::date-time format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_60() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date-time format -> all string formats ignore booleans" + * + * Test ID: "format::date-time format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_61() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date-time format -> all string formats ignore nulls" + * + * Test ID: "format::date-time format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "date-time format -> invalid date-time string is only an annotation by default" + * + * Test ID: "format::date-time format::invalid date-time string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_63() { + + assertKsonEnforcesSchema( + """ + "1990-02-31T15:59:60.123-08:00" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::invalid date-time string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "time format -> all string formats ignore integers" + * + * Test ID: "format::time format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_64() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "time format -> all string formats ignore floats" + * + * Test ID: "format::time format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_65() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "time format -> all string formats ignore objects" + * + * Test ID: "format::time format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_66() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "time format -> all string formats ignore arrays" + * + * Test ID: "format::time format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_67() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "time format -> all string formats ignore booleans" + * + * Test ID: "format::time format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_68() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "time format -> all string formats ignore nulls" + * + * Test ID: "format::time format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_69() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "time format -> invalid time string is only an annotation by default" + * + * Test ID: "format::time format::invalid time string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_70() { + + assertKsonEnforcesSchema( + """ + "08:30:06 PST" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::invalid time string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "json-pointer format -> all string formats ignore integers" + * + * Test ID: "format::json-pointer format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_71() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "json-pointer format -> all string formats ignore floats" + * + * Test ID: "format::json-pointer format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_72() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "json-pointer format -> all string formats ignore objects" + * + * Test ID: "format::json-pointer format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_73() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "json-pointer format -> all string formats ignore arrays" + * + * Test ID: "format::json-pointer format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_74() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "json-pointer format -> all string formats ignore booleans" + * + * Test ID: "format::json-pointer format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_75() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "json-pointer format -> all string formats ignore nulls" + * + * Test ID: "format::json-pointer format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_76() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "json-pointer format -> invalid json-pointer string is only an annotation by default" + * + * Test ID: "format::json-pointer format::invalid json-pointer string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_77() { + + assertKsonEnforcesSchema( + """ + "/foo/bar~" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::invalid json-pointer string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "relative-json-pointer format -> all string formats ignore integers" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_78() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "relative-json-pointer format -> all string formats ignore floats" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_79() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "relative-json-pointer format -> all string formats ignore objects" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_80() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "relative-json-pointer format -> all string formats ignore arrays" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_81() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "relative-json-pointer format -> all string formats ignore booleans" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_82() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "relative-json-pointer format -> all string formats ignore nulls" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_83() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "relative-json-pointer format -> invalid relative-json-pointer string is only an annotation by default" + * + * Test ID: "format::relative-json-pointer format::invalid relative-json-pointer string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_84() { + + assertKsonEnforcesSchema( + """ + "/foo/bar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::invalid relative-json-pointer string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri format -> all string formats ignore integers" + * + * Test ID: "format::iri format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_85() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri format -> all string formats ignore floats" + * + * Test ID: "format::iri format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_86() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri format -> all string formats ignore objects" + * + * Test ID: "format::iri format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_87() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri format -> all string formats ignore arrays" + * + * Test ID: "format::iri format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_88() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri format -> all string formats ignore booleans" + * + * Test ID: "format::iri format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_89() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri format -> all string formats ignore nulls" + * + * Test ID: "format::iri format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_90() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri format -> invalid iri string is only an annotation by default" + * + * Test ID: "format::iri format::invalid iri string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_91() { + + assertKsonEnforcesSchema( + """ + "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::invalid iri string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri-reference format -> all string formats ignore integers" + * + * Test ID: "format::iri-reference format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_92() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri-reference format -> all string formats ignore floats" + * + * Test ID: "format::iri-reference format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_93() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri-reference format -> all string formats ignore objects" + * + * Test ID: "format::iri-reference format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_94() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri-reference format -> all string formats ignore arrays" + * + * Test ID: "format::iri-reference format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_95() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri-reference format -> all string formats ignore booleans" + * + * Test ID: "format::iri-reference format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_96() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri-reference format -> all string formats ignore nulls" + * + * Test ID: "format::iri-reference format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_97() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "iri-reference format -> invalid iri-reference string is only an annotation by default" + * + * Test ID: "format::iri-reference format::invalid iri-reference string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_98() { + + assertKsonEnforcesSchema( + """ + "\\\\WINDOWS\\filëßåré" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::invalid iri-reference string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri format -> all string formats ignore integers" + * + * Test ID: "format::uri format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_99() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri format -> all string formats ignore floats" + * + * Test ID: "format::uri format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_100() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri format -> all string formats ignore objects" + * + * Test ID: "format::uri format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_101() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri format -> all string formats ignore arrays" + * + * Test ID: "format::uri format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_102() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri format -> all string formats ignore booleans" + * + * Test ID: "format::uri format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_103() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri format -> all string formats ignore nulls" + * + * Test ID: "format::uri format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_104() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri format -> invalid uri string is only an annotation by default" + * + * Test ID: "format::uri format::invalid uri string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_105() { + + assertKsonEnforcesSchema( + """ + "//foo.bar/?baz=qux#quux" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::invalid uri string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-reference format -> all string formats ignore integers" + * + * Test ID: "format::uri-reference format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_106() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-reference format -> all string formats ignore floats" + * + * Test ID: "format::uri-reference format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_107() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-reference format -> all string formats ignore objects" + * + * Test ID: "format::uri-reference format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_108() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-reference format -> all string formats ignore arrays" + * + * Test ID: "format::uri-reference format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_109() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-reference format -> all string formats ignore booleans" + * + * Test ID: "format::uri-reference format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_110() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-reference format -> all string formats ignore nulls" + * + * Test ID: "format::uri-reference format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_111() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-reference format -> invalid uri-reference string is only an annotation by default" + * + * Test ID: "format::uri-reference format::invalid uri-reference string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_112() { + + assertKsonEnforcesSchema( + """ + "\\\\WINDOWS\\fileshare" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::invalid uri-reference string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-template format -> all string formats ignore integers" + * + * Test ID: "format::uri-template format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_113() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-template format -> all string formats ignore floats" + * + * Test ID: "format::uri-template format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_114() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-template format -> all string formats ignore objects" + * + * Test ID: "format::uri-template format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_115() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-template format -> all string formats ignore arrays" + * + * Test ID: "format::uri-template format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_116() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-template format -> all string formats ignore booleans" + * + * Test ID: "format::uri-template format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_117() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-template format -> all string formats ignore nulls" + * + * Test ID: "format::uri-template format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_118() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uri-template format -> invalid uri-template string is only an annotation by default" + * + * Test ID: "format::uri-template format::invalid uri-template string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_119() { + + assertKsonEnforcesSchema( + """ + "http://example.com/dictionary/{term:1}/{term" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::invalid uri-template string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uuid format -> all string formats ignore integers" + * + * Test ID: "format::uuid format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_120() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uuid" + } + """, + true, + """ schemaTestId: "format::uuid format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uuid format -> all string formats ignore floats" + * + * Test ID: "format::uuid format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_121() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uuid" + } + """, + true, + """ schemaTestId: "format::uuid format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uuid format -> all string formats ignore objects" + * + * Test ID: "format::uuid format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_122() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uuid" + } + """, + true, + """ schemaTestId: "format::uuid format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uuid format -> all string formats ignore arrays" + * + * Test ID: "format::uuid format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_123() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uuid" + } + """, + true, + """ schemaTestId: "format::uuid format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uuid format -> all string formats ignore booleans" + * + * Test ID: "format::uuid format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_124() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uuid" + } + """, + true, + """ schemaTestId: "format::uuid format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uuid format -> all string formats ignore nulls" + * + * Test ID: "format::uuid format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_125() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uuid" + } + """, + true, + """ schemaTestId: "format::uuid format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "uuid format -> invalid uuid string is only an annotation by default" + * + * Test ID: "format::uuid format::invalid uuid string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_126() { + + assertKsonEnforcesSchema( + """ + "2eb8aa08-aa98-11ea-b4aa-73b441d1638" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "uuid" + } + """, + true, + """ schemaTestId: "format::uuid format::invalid uuid string is only an annotation by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "duration format -> all string formats ignore integers" + * + * Test ID: "format::duration format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_127() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "duration" + } + """, + true, + """ schemaTestId: "format::duration format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "duration format -> all string formats ignore floats" + * + * Test ID: "format::duration format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_128() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "duration" + } + """, + true, + """ schemaTestId: "format::duration format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "duration format -> all string formats ignore objects" + * + * Test ID: "format::duration format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_129() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "duration" + } + """, + true, + """ schemaTestId: "format::duration format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "duration format -> all string formats ignore arrays" + * + * Test ID: "format::duration format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_130() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "duration" + } + """, + true, + """ schemaTestId: "format::duration format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "duration format -> all string formats ignore booleans" + * + * Test ID: "format::duration format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_131() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "duration" + } + """, + true, + """ schemaTestId: "format::duration format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "duration format -> all string formats ignore nulls" + * + * Test ID: "format::duration format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_132() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "duration" + } + """, + true, + """ schemaTestId: "format::duration format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/format.json`: + * "duration format -> invalid duration string is only an annotation by default" + * + * Test ID: "format::duration format::invalid duration string is only an annotation by default" + */ + @Test + fun jsonSchemaSuiteTest_133() { + + assertKsonEnforcesSchema( + """ + "PT1D" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "format": "duration" + } + """, + true, + """ schemaTestId: "format::duration format::invalid duration string is only an annotation by default" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_if_then_else.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_if_then_else.kt new file mode 100644 index 00000000..ca75bf09 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_if_then_else.kt @@ -0,0 +1,775 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_if_then_else : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "ignore if without then or else -> valid when valid against lone if" + * + * Test ID: "if-then-else::ignore if without then or else::valid when valid against lone if" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore if without then or else::valid when valid against lone if" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "ignore if without then or else -> valid when invalid against lone if" + * + * Test ID: "if-then-else::ignore if without then or else::valid when invalid against lone if" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "hello" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore if without then or else::valid when invalid against lone if" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "ignore then without if -> valid when valid against lone then" + * + * Test ID: "if-then-else::ignore then without if::valid when valid against lone then" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "then": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore then without if::valid when valid against lone then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "ignore then without if -> valid when invalid against lone then" + * + * Test ID: "if-then-else::ignore then without if::valid when invalid against lone then" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "hello" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "then": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore then without if::valid when invalid against lone then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "ignore else without if -> valid when valid against lone else" + * + * Test ID: "if-then-else::ignore else without if::valid when valid against lone else" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "else": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore else without if::valid when valid against lone else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "ignore else without if -> valid when invalid against lone else" + * + * Test ID: "if-then-else::ignore else without if::valid when invalid against lone else" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "hello" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "else": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore else without if::valid when invalid against lone else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if and then without else -> valid through then" + * + * Test ID: "if-then-else::if and then without else::valid through then" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + -1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + } + } + """, + true, + """ schemaTestId: "if-then-else::if and then without else::valid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if and then without else -> invalid through then" + * + * Test ID: "if-then-else::if and then without else::invalid through then" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + -100 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + } + } + """, + false, + """ schemaTestId: "if-then-else::if and then without else::invalid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if and then without else -> valid when if test fails" + * + * Test ID: "if-then-else::if and then without else::valid when if test fails" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + } + } + """, + true, + """ schemaTestId: "if-then-else::if and then without else::valid when if test fails" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if and else without then -> valid when if test passes" + * + * Test ID: "if-then-else::if and else without then::valid when if test passes" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + -1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "else": { + "multipleOf": 2 + } + } + """, + true, + """ schemaTestId: "if-then-else::if and else without then::valid when if test passes" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if and else without then -> valid through else" + * + * Test ID: "if-then-else::if and else without then::valid through else" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + 4 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "else": { + "multipleOf": 2 + } + } + """, + true, + """ schemaTestId: "if-then-else::if and else without then::valid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if and else without then -> invalid through else" + * + * Test ID: "if-then-else::if and else without then::invalid through else" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "else": { + "multipleOf": 2 + } + } + """, + false, + """ schemaTestId: "if-then-else::if and else without then::invalid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "validate against correct branch, then vs else -> valid through then" + * + * Test ID: "if-then-else::validate against correct branch, then vs else::valid through then" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + -1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + }, + "else": { + "multipleOf": 2 + } + } + """, + true, + """ schemaTestId: "if-then-else::validate against correct branch, then vs else::valid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "validate against correct branch, then vs else -> invalid through then" + * + * Test ID: "if-then-else::validate against correct branch, then vs else::invalid through then" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + -100 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + }, + "else": { + "multipleOf": 2 + } + } + """, + false, + """ schemaTestId: "if-then-else::validate against correct branch, then vs else::invalid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "validate against correct branch, then vs else -> valid through else" + * + * Test ID: "if-then-else::validate against correct branch, then vs else::valid through else" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 4 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + }, + "else": { + "multipleOf": 2 + } + } + """, + true, + """ schemaTestId: "if-then-else::validate against correct branch, then vs else::valid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "validate against correct branch, then vs else -> invalid through else" + * + * Test ID: "if-then-else::validate against correct branch, then vs else::invalid through else" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + }, + "else": { + "multipleOf": 2 + } + } + """, + false, + """ schemaTestId: "if-then-else::validate against correct branch, then vs else::invalid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "non-interference across combined schemas -> valid, but would have been invalid through then" + * + * Test ID: "if-then-else::non-interference across combined schemas::valid, but would have been invalid through then" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + -100 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "if": { + "exclusiveMaximum": 0 + } + }, + { + "then": { + "minimum": -10 + } + }, + { + "else": { + "multipleOf": 2 + } + } + ] + } + """, + true, + """ schemaTestId: "if-then-else::non-interference across combined schemas::valid, but would have been invalid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "non-interference across combined schemas -> valid, but would have been invalid through else" + * + * Test ID: "if-then-else::non-interference across combined schemas::valid, but would have been invalid through else" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "if": { + "exclusiveMaximum": 0 + } + }, + { + "then": { + "minimum": -10 + } + }, + { + "else": { + "multipleOf": 2 + } + } + ] + } + """, + true, + """ schemaTestId: "if-then-else::non-interference across combined schemas::valid, but would have been invalid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if with boolean schema true -> boolean schema true in if always chooses the then path (valid)" + * + * Test ID: "if-then-else::if with boolean schema true::boolean schema true in if always chooses the then path (valid)" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + "then" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": true, + "then": { + "const": "then" + }, + "else": { + "const": "else" + } + } + """, + true, + """ schemaTestId: "if-then-else::if with boolean schema true::boolean schema true in if always chooses the then path (valid)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if with boolean schema true -> boolean schema true in if always chooses the then path (invalid)" + * + * Test ID: "if-then-else::if with boolean schema true::boolean schema true in if always chooses the then path (invalid)" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + "else" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": true, + "then": { + "const": "then" + }, + "else": { + "const": "else" + } + } + """, + false, + """ schemaTestId: "if-then-else::if with boolean schema true::boolean schema true in if always chooses the then path (invalid)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if with boolean schema false -> boolean schema false in if always chooses the else path (invalid)" + * + * Test ID: "if-then-else::if with boolean schema false::boolean schema false in if always chooses the else path (invalid)" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + "then" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": false, + "then": { + "const": "then" + }, + "else": { + "const": "else" + } + } + """, + false, + """ schemaTestId: "if-then-else::if with boolean schema false::boolean schema false in if always chooses the else path (invalid)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if with boolean schema false -> boolean schema false in if always chooses the else path (valid)" + * + * Test ID: "if-then-else::if with boolean schema false::boolean schema false in if always chooses the else path (valid)" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + "else" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": false, + "then": { + "const": "then" + }, + "else": { + "const": "else" + } + } + """, + true, + """ schemaTestId: "if-then-else::if with boolean schema false::boolean schema false in if always chooses the else path (valid)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if appears at the end when serialized (keyword processing sequence) -> yes redirects to then and passes" + * + * Test ID: "if-then-else::if appears at the end when serialized (keyword processing sequence)::yes redirects to then and passes" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + "yes" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "then": { + "const": "yes" + }, + "else": { + "const": "other" + }, + "if": { + "maxLength": 4 + } + } + """, + true, + """ schemaTestId: "if-then-else::if appears at the end when serialized (keyword processing sequence)::yes redirects to then and passes" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if appears at the end when serialized (keyword processing sequence) -> other redirects to else and passes" + * + * Test ID: "if-then-else::if appears at the end when serialized (keyword processing sequence)::other redirects to else and passes" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + "other" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "then": { + "const": "yes" + }, + "else": { + "const": "other" + }, + "if": { + "maxLength": 4 + } + } + """, + true, + """ schemaTestId: "if-then-else::if appears at the end when serialized (keyword processing sequence)::other redirects to else and passes" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if appears at the end when serialized (keyword processing sequence) -> no redirects to then and fails" + * + * Test ID: "if-then-else::if appears at the end when serialized (keyword processing sequence)::no redirects to then and fails" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + "no" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "then": { + "const": "yes" + }, + "else": { + "const": "other" + }, + "if": { + "maxLength": 4 + } + } + """, + false, + """ schemaTestId: "if-then-else::if appears at the end when serialized (keyword processing sequence)::no redirects to then and fails" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json`: + * "if appears at the end when serialized (keyword processing sequence) -> invalid redirects to else and fails" + * + * Test ID: "if-then-else::if appears at the end when serialized (keyword processing sequence)::invalid redirects to else and fails" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + "invalid" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "then": { + "const": "yes" + }, + "else": { + "const": "other" + }, + "if": { + "maxLength": 4 + } + } + """, + false, + """ schemaTestId: "if-then-else::if appears at the end when serialized (keyword processing sequence)::invalid redirects to else and fails" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_infinite_loop_detection.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_infinite_loop_detection.kt new file mode 100644 index 00000000..1acd6feb --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_infinite_loop_detection.kt @@ -0,0 +1,101 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_infinite_loop_detection : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/infinite-loop-detection.json`: + * "evaluating the same schema location against the same data location twice is not a sign of an infinite loop -> passing case" + * + * Test ID: "infinite-loop-detection::evaluating the same schema location against the same data location twice is not a sign of an infinite loop::passing case" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "int": { + "type": "integer" + } + }, + "allOf": [ + { + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/int" + } + } + }, + { + "additionalProperties": { + "${'$'}ref": "#/${'$'}defs/int" + } + } + ] + } + """, + true, + """ schemaTestId: "infinite-loop-detection::evaluating the same schema location against the same data location twice is not a sign of an infinite loop::passing case" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/infinite-loop-detection.json`: + * "evaluating the same schema location against the same data location twice is not a sign of an infinite loop -> failing case" + * + * Test ID: "infinite-loop-detection::evaluating the same schema location against the same data location twice is not a sign of an infinite loop::failing case" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": "a string" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "int": { + "type": "integer" + } + }, + "allOf": [ + { + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/int" + } + } + }, + { + "additionalProperties": { + "${'$'}ref": "#/${'$'}defs/int" + } + } + ] + } + """, + false, + """ schemaTestId: "infinite-loop-detection::evaluating the same schema location against the same data location twice is not a sign of an infinite loop::failing case" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_items.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_items.kt new file mode 100644 index 00000000..2e26cfc6 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_items.kt @@ -0,0 +1,1326 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_items : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "a schema given for items -> valid items" + * + * Test ID: "items::a schema given for items::valid items" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "items::a schema given for items::valid items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "a schema given for items -> wrong type of items" + * + * Test ID: "items::a schema given for items::wrong type of items" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "x" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "items::a schema given for items::wrong type of items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "a schema given for items -> ignores non-arrays" + * + * Test ID: "items::a schema given for items::ignores non-arrays" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "items::a schema given for items::ignores non-arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "a schema given for items -> JavaScript pseudo-array is valid" + * + * Test ID: "items::a schema given for items::JavaScript pseudo-array is valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "0": "invalid", + "length": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "items::a schema given for items::JavaScript pseudo-array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items with boolean schema (true) -> any array is valid" + * + * Test ID: "items::items with boolean schema (true)::any array is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo", + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": true + } + """, + true, + """ schemaTestId: "items::items with boolean schema (true)::any array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items with boolean schema (true) -> empty array is valid" + * + * Test ID: "items::items with boolean schema (true)::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": true + } + """, + true, + """ schemaTestId: "items::items with boolean schema (true)::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items with boolean schema (false) -> any non-empty array is invalid" + * + * Test ID: "items::items with boolean schema (false)::any non-empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo", + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": false + } + """, + false, + """ schemaTestId: "items::items with boolean schema (false)::any non-empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items with boolean schema (false) -> empty array is valid" + * + * Test ID: "items::items with boolean schema (false)::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": false + } + """, + true, + """ schemaTestId: "items::items with boolean schema (false)::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items and subitems -> valid items" + * + * Test ID: "items::items and subitems::valid items" + */ + @Test + fun jsonSchemaSuiteTest_9() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::items and subitems::valid items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "item": { + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/sub-item" + }, + { + "${'$'}ref": "#/${'$'}defs/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + } + ] + } + """, + true, + """ schemaTestId: "items::items and subitems::valid items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items and subitems -> too many items" + * + * Test ID: "items::items and subitems::too many items" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "item": { + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/sub-item" + }, + { + "${'$'}ref": "#/${'$'}defs/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + } + ] + } + """, + false, + """ schemaTestId: "items::items and subitems::too many items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items and subitems -> too many sub-items" + * + * Test ID: "items::items and subitems::too many sub-items" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + [ + { + "foo": null + }, + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "item": { + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/sub-item" + }, + { + "${'$'}ref": "#/${'$'}defs/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + } + ] + } + """, + false, + """ schemaTestId: "items::items and subitems::too many sub-items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items and subitems -> wrong item" + * + * Test ID: "items::items and subitems::wrong item" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": null + }, + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "item": { + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/sub-item" + }, + { + "${'$'}ref": "#/${'$'}defs/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + } + ] + } + """, + false, + """ schemaTestId: "items::items and subitems::wrong item" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items and subitems -> wrong sub-item" + * + * Test ID: "items::items and subitems::wrong sub-item" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + [ + { + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "item": { + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/sub-item" + }, + { + "${'$'}ref": "#/${'$'}defs/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + } + ] + } + """, + false, + """ schemaTestId: "items::items and subitems::wrong sub-item" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items and subitems -> fewer items is valid" + * + * Test ID: "items::items and subitems::fewer items is valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::items and subitems::fewer items is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + [ + { + "foo": null + } + ], + [ + { + "foo": null + } + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "item": { + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/sub-item" + }, + { + "${'$'}ref": "#/${'$'}defs/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "items": false, + "prefixItems": [ + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + }, + { + "${'$'}ref": "#/${'$'}defs/item" + } + ] + } + """, + true, + """ schemaTestId: "items::items and subitems::fewer items is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "nested items -> valid nested array" + * + * Test ID: "items::nested items::valid nested array" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + [ + 1 + ] + ], + [ + [ + 2 + ], + [ + 3 + ] + ] + ], + [ + [ + [ + 4 + ], + [ + 5 + ], + [ + 6 + ] + ] + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "number" + } + } + } + } + } + """, + true, + """ schemaTestId: "items::nested items::valid nested array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "nested items -> nested array with invalid type" + * + * Test ID: "items::nested items::nested array with invalid type" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + [ + "1" + ] + ], + [ + [ + 2 + ], + [ + 3 + ] + ] + ], + [ + [ + [ + 4 + ], + [ + 5 + ], + [ + 6 + ] + ] + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "number" + } + } + } + } + } + """, + false, + """ schemaTestId: "items::nested items::nested array with invalid type" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "nested items -> not deep enough" + * + * Test ID: "items::nested items::not deep enough" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + 1 + ], + [ + 2 + ], + [ + 3 + ] + ], + [ + [ + 4 + ], + [ + 5 + ], + [ + 6 + ] + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "number" + } + } + } + } + } + """, + false, + """ schemaTestId: "items::nested items::not deep enough" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "prefixItems with no additional items allowed -> empty array" + * + * Test ID: "items::prefixItems with no additional items allowed::empty array" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + }, + { + }, + { + } + ], + "items": false + } + """, + true, + """ schemaTestId: "items::prefixItems with no additional items allowed::empty array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "prefixItems with no additional items allowed -> fewer number of items present (1)" + * + * Test ID: "items::prefixItems with no additional items allowed::fewer number of items present (1)" + */ + @Test + fun jsonSchemaSuiteTest_19() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::prefixItems with no additional items allowed::fewer number of items present (1)" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + }, + { + }, + { + } + ], + "items": false + } + """, + true, + """ schemaTestId: "items::prefixItems with no additional items allowed::fewer number of items present (1)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "prefixItems with no additional items allowed -> fewer number of items present (2)" + * + * Test ID: "items::prefixItems with no additional items allowed::fewer number of items present (2)" + */ + @Test + fun jsonSchemaSuiteTest_20() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::prefixItems with no additional items allowed::fewer number of items present (2)" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + }, + { + }, + { + } + ], + "items": false + } + """, + true, + """ schemaTestId: "items::prefixItems with no additional items allowed::fewer number of items present (2)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "prefixItems with no additional items allowed -> equal number of items present" + * + * Test ID: "items::prefixItems with no additional items allowed::equal number of items present" + */ + @Test + fun jsonSchemaSuiteTest_21() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::prefixItems with no additional items allowed::equal number of items present" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + }, + { + }, + { + } + ], + "items": false + } + """, + true, + """ schemaTestId: "items::prefixItems with no additional items allowed::equal number of items present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "prefixItems with no additional items allowed -> additional items are not permitted" + * + * Test ID: "items::prefixItems with no additional items allowed::additional items are not permitted" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3, + 4 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + }, + { + }, + { + } + ], + "items": false + } + """, + false, + """ schemaTestId: "items::prefixItems with no additional items allowed::additional items are not permitted" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items does not look in applicators, valid case -> prefixItems in allOf does not constrain items, invalid case" + * + * Test ID: "items::items does not look in applicators, valid case::prefixItems in allOf does not constrain items, invalid case" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 5 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "prefixItems": [ + { + "minimum": 3 + } + ] + } + ], + "items": { + "minimum": 5 + } + } + """, + false, + """ schemaTestId: "items::items does not look in applicators, valid case::prefixItems in allOf does not constrain items, invalid case" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items does not look in applicators, valid case -> prefixItems in allOf does not constrain items, valid case" + * + * Test ID: "items::items does not look in applicators, valid case::prefixItems in allOf does not constrain items, valid case" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + [ + 5, + 5 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "prefixItems": [ + { + "minimum": 3 + } + ] + } + ], + "items": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "items::items does not look in applicators, valid case::prefixItems in allOf does not constrain items, valid case" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "prefixItems validation adjusts the starting index for items -> valid items" + * + * Test ID: "items::prefixItems validation adjusts the starting index for items::valid items" + */ + @Test + fun jsonSchemaSuiteTest_25() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::prefixItems validation adjusts the starting index for items::valid items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "x", + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "string" + } + ], + "items": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "items::prefixItems validation adjusts the starting index for items::valid items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "prefixItems validation adjusts the starting index for items -> wrong type of second item" + * + * Test ID: "items::prefixItems validation adjusts the starting index for items::wrong type of second item" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + [ + "x", + "y" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "string" + } + ], + "items": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "items::prefixItems validation adjusts the starting index for items::wrong type of second item" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items with heterogeneous array -> heterogeneous invalid instance" + * + * Test ID: "items::items with heterogeneous array::heterogeneous invalid instance" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + 37 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + } + ], + "items": false + } + """, + false, + """ schemaTestId: "items::items with heterogeneous array::heterogeneous invalid instance" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items with heterogeneous array -> valid instance" + * + * Test ID: "items::items with heterogeneous array::valid instance" + */ + @Test + fun jsonSchemaSuiteTest_28() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::items with heterogeneous array::valid instance" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + } + ], + "items": false + } + """, + true, + """ schemaTestId: "items::items with heterogeneous array::valid instance" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/items.json`: + * "items with null instance elements -> allows null elements" + * + * Test ID: "items::items with null instance elements::allows null elements" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "items::items with null instance elements::allows null elements" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxContains.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxContains.kt new file mode 100644 index 00000000..4b94d119 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxContains.kt @@ -0,0 +1,380 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_maxContains : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains without contains is ignored -> one item valid against lone maxContains" + * + * Test ID: "maxContains::maxContains without contains is ignored::one item valid against lone maxContains" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxContains": 1 + } + """, + true, + """ schemaTestId: "maxContains::maxContains without contains is ignored::one item valid against lone maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains without contains is ignored -> two items still valid against lone maxContains" + * + * Test ID: "maxContains::maxContains without contains is ignored::two items still valid against lone maxContains" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxContains": 1 + } + """, + true, + """ schemaTestId: "maxContains::maxContains without contains is ignored::two items still valid against lone maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains with contains -> empty data" + * + * Test ID: "maxContains::maxContains with contains::empty data" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1 + } + """, + false, + """ schemaTestId: "maxContains::maxContains with contains::empty data" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains with contains -> all elements match, valid maxContains" + * + * Test ID: "maxContains::maxContains with contains::all elements match, valid maxContains" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1 + } + """, + true, + """ schemaTestId: "maxContains::maxContains with contains::all elements match, valid maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains with contains -> all elements match, invalid maxContains" + * + * Test ID: "maxContains::maxContains with contains::all elements match, invalid maxContains" + */ + @Test + fun jsonSchemaSuiteTest_5() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "maxContains::maxContains with contains::all elements match, invalid maxContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1 + } + """, + false, + """ schemaTestId: "maxContains::maxContains with contains::all elements match, invalid maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains with contains -> some elements match, valid maxContains" + * + * Test ID: "maxContains::maxContains with contains::some elements match, valid maxContains" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1 + } + """, + true, + """ schemaTestId: "maxContains::maxContains with contains::some elements match, valid maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains with contains -> some elements match, invalid maxContains" + * + * Test ID: "maxContains::maxContains with contains::some elements match, invalid maxContains" + */ + @Test + fun jsonSchemaSuiteTest_7() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "maxContains::maxContains with contains::some elements match, invalid maxContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1 + } + """, + false, + """ schemaTestId: "maxContains::maxContains with contains::some elements match, invalid maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains with contains, value with a decimal -> one element matches, valid maxContains" + * + * Test ID: "maxContains::maxContains with contains, value with a decimal::one element matches, valid maxContains" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1.0 + } + """, + true, + """ schemaTestId: "maxContains::maxContains with contains, value with a decimal::one element matches, valid maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "maxContains with contains, value with a decimal -> too many elements match, invalid maxContains" + * + * Test ID: "maxContains::maxContains with contains, value with a decimal::too many elements match, invalid maxContains" + */ + @Test + fun jsonSchemaSuiteTest_9() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "maxContains::maxContains with contains, value with a decimal::too many elements match, invalid maxContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1.0 + } + """, + false, + """ schemaTestId: "maxContains::maxContains with contains, value with a decimal::too many elements match, invalid maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "minContains < maxContains -> actual < minContains < maxContains" + * + * Test ID: "maxContains::minContains < maxContains::actual < minContains < maxContains" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 1, + "maxContains": 3 + } + """, + false, + """ schemaTestId: "maxContains::minContains < maxContains::actual < minContains < maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "minContains < maxContains -> minContains < actual < maxContains" + * + * Test ID: "maxContains::minContains < maxContains::minContains < actual < maxContains" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 1, + "maxContains": 3 + } + """, + true, + """ schemaTestId: "maxContains::minContains < maxContains::minContains < actual < maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json`: + * "minContains < maxContains -> minContains < maxContains < actual" + * + * Test ID: "maxContains::minContains < maxContains::minContains < maxContains < actual" + */ + @Test + fun jsonSchemaSuiteTest_12() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "maxContains::minContains < maxContains::minContains < maxContains < actual" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 1, + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 1, + "maxContains": 3 + } + """, + false, + """ schemaTestId: "maxContains::minContains < maxContains::minContains < maxContains < actual" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxItems.kt new file mode 100644 index 00000000..e7e75403 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxItems.kt @@ -0,0 +1,168 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_maxItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxItems.json`: + * "maxItems validation -> shorter is valid" + * + * Test ID: "maxItems::maxItems validation::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxItems": 2 + } + """, + true, + """ schemaTestId: "maxItems::maxItems validation::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxItems.json`: + * "maxItems validation -> exact length is valid" + * + * Test ID: "maxItems::maxItems validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxItems": 2 + } + """, + true, + """ schemaTestId: "maxItems::maxItems validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxItems.json`: + * "maxItems validation -> too long is invalid" + * + * Test ID: "maxItems::maxItems validation::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxItems": 2 + } + """, + false, + """ schemaTestId: "maxItems::maxItems validation::too long is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxItems.json`: + * "maxItems validation -> ignores non-arrays" + * + * Test ID: "maxItems::maxItems validation::ignores non-arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxItems": 2 + } + """, + true, + """ schemaTestId: "maxItems::maxItems validation::ignores non-arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxItems.json`: + * "maxItems validation with a decimal -> shorter is valid" + * + * Test ID: "maxItems::maxItems validation with a decimal::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxItems": 2.0 + } + """, + true, + """ schemaTestId: "maxItems::maxItems validation with a decimal::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxItems.json`: + * "maxItems validation with a decimal -> too long is invalid" + * + * Test ID: "maxItems::maxItems validation with a decimal::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxItems": 2.0 + } + """, + false, + """ schemaTestId: "maxItems::maxItems validation with a decimal::too long is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxLength.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxLength.kt new file mode 100644 index 00000000..7a19a6e6 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxLength.kt @@ -0,0 +1,176 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_maxLength : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxLength.json`: + * "maxLength validation -> shorter is valid" + * + * Test ID: "maxLength::maxLength validation::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "f" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxLength": 2 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxLength.json`: + * "maxLength validation -> exact length is valid" + * + * Test ID: "maxLength::maxLength validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "fo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxLength": 2 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxLength.json`: + * "maxLength validation -> too long is invalid" + * + * Test ID: "maxLength::maxLength validation::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxLength": 2 + } + """, + false, + """ schemaTestId: "maxLength::maxLength validation::too long is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxLength.json`: + * "maxLength validation -> ignores non-strings" + * + * Test ID: "maxLength::maxLength validation::ignores non-strings" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 100 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxLength": 2 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation::ignores non-strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxLength.json`: + * "maxLength validation -> two graphemes is long enough" + * + * Test ID: "maxLength::maxLength validation::two graphemes is long enough" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "💩💩" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxLength": 2 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation::two graphemes is long enough" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxLength.json`: + * "maxLength validation with a decimal -> shorter is valid" + * + * Test ID: "maxLength::maxLength validation with a decimal::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "f" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxLength": 2.0 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation with a decimal::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxLength.json`: + * "maxLength validation with a decimal -> too long is invalid" + * + * Test ID: "maxLength::maxLength validation with a decimal::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxLength": 2.0 + } + """, + false, + """ schemaTestId: "maxLength::maxLength validation with a decimal::too long is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxProperties.kt new file mode 100644 index 00000000..66d857c2 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maxProperties.kt @@ -0,0 +1,267 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_maxProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties validation -> shorter is valid" + * + * Test ID: "maxProperties::maxProperties validation::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties validation -> exact length is valid" + * + * Test ID: "maxProperties::maxProperties validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties validation -> too long is invalid" + * + * Test ID: "maxProperties::maxProperties validation::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "baz": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 2 + } + """, + false, + """ schemaTestId: "maxProperties::maxProperties validation::too long is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties validation -> ignores arrays" + * + * Test ID: "maxProperties::maxProperties validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties validation -> ignores strings" + * + * Test ID: "maxProperties::maxProperties validation::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties validation -> ignores other non-objects" + * + * Test ID: "maxProperties::maxProperties validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties validation with a decimal -> shorter is valid" + * + * Test ID: "maxProperties::maxProperties validation with a decimal::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 2.0 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation with a decimal::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties validation with a decimal -> too long is invalid" + * + * Test ID: "maxProperties::maxProperties validation with a decimal::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "baz": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 2.0 + } + """, + false, + """ schemaTestId: "maxProperties::maxProperties validation with a decimal::too long is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties = 0 means the object is empty -> no properties is valid" + * + * Test ID: "maxProperties::maxProperties = 0 means the object is empty::no properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 0 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties = 0 means the object is empty::no properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json`: + * "maxProperties = 0 means the object is empty -> one property is invalid" + * + * Test ID: "maxProperties::maxProperties = 0 means the object is empty::one property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maxProperties": 0 + } + """, + false, + """ schemaTestId: "maxProperties::maxProperties = 0 means the object is empty::one property is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maximum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maximum.kt new file mode 100644 index 00000000..1029708b --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_maximum.kt @@ -0,0 +1,199 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_maximum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maximum.json`: + * "maximum validation -> below the maximum is valid" + * + * Test ID: "maximum::maximum validation::below the maximum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 2.6 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maximum": 3.0 + } + """, + true, + """ schemaTestId: "maximum::maximum validation::below the maximum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maximum.json`: + * "maximum validation -> boundary point is valid" + * + * Test ID: "maximum::maximum validation::boundary point is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 3.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maximum": 3.0 + } + """, + true, + """ schemaTestId: "maximum::maximum validation::boundary point is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maximum.json`: + * "maximum validation -> above the maximum is invalid" + * + * Test ID: "maximum::maximum validation::above the maximum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 3.5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maximum": 3.0 + } + """, + false, + """ schemaTestId: "maximum::maximum validation::above the maximum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maximum.json`: + * "maximum validation -> ignores non-numbers" + * + * Test ID: "maximum::maximum validation::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maximum": 3.0 + } + """, + true, + """ schemaTestId: "maximum::maximum validation::ignores non-numbers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maximum.json`: + * "maximum validation with unsigned integer -> below the maximum is invalid" + * + * Test ID: "maximum::maximum validation with unsigned integer::below the maximum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 299.97 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maximum": 300 + } + """, + true, + """ schemaTestId: "maximum::maximum validation with unsigned integer::below the maximum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maximum.json`: + * "maximum validation with unsigned integer -> boundary point integer is valid" + * + * Test ID: "maximum::maximum validation with unsigned integer::boundary point integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 300 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maximum": 300 + } + """, + true, + """ schemaTestId: "maximum::maximum validation with unsigned integer::boundary point integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maximum.json`: + * "maximum validation with unsigned integer -> boundary point float is valid" + * + * Test ID: "maximum::maximum validation with unsigned integer::boundary point float is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 300.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maximum": 300 + } + """, + true, + """ schemaTestId: "maximum::maximum validation with unsigned integer::boundary point float is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/maximum.json`: + * "maximum validation with unsigned integer -> above the maximum is invalid" + * + * Test ID: "maximum::maximum validation with unsigned integer::above the maximum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + 300.5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "maximum": 300 + } + """, + false, + """ schemaTestId: "maximum::maximum validation with unsigned integer::above the maximum is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minContains.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minContains.kt new file mode 100644 index 00000000..f86c92e7 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minContains.kt @@ -0,0 +1,885 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_minContains : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains without contains is ignored -> one item valid against lone minContains" + * + * Test ID: "minContains::minContains without contains is ignored::one item valid against lone minContains" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minContains": 1 + } + """, + true, + """ schemaTestId: "minContains::minContains without contains is ignored::one item valid against lone minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains without contains is ignored -> zero items still valid against lone minContains" + * + * Test ID: "minContains::minContains without contains is ignored::zero items still valid against lone minContains" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minContains": 1 + } + """, + true, + """ schemaTestId: "minContains::minContains without contains is ignored::zero items still valid against lone minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=1 with contains -> empty data" + * + * Test ID: "minContains::minContains=1 with contains::empty data" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 1 + } + """, + false, + """ schemaTestId: "minContains::minContains=1 with contains::empty data" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=1 with contains -> no elements match" + * + * Test ID: "minContains::minContains=1 with contains::no elements match" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 1 + } + """, + false, + """ schemaTestId: "minContains::minContains=1 with contains::no elements match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=1 with contains -> single element matches, valid minContains" + * + * Test ID: "minContains::minContains=1 with contains::single element matches, valid minContains" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 1 + } + """, + true, + """ schemaTestId: "minContains::minContains=1 with contains::single element matches, valid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=1 with contains -> some elements match, valid minContains" + * + * Test ID: "minContains::minContains=1 with contains::some elements match, valid minContains" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 1 + } + """, + true, + """ schemaTestId: "minContains::minContains=1 with contains::some elements match, valid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=1 with contains -> all elements match, valid minContains" + * + * Test ID: "minContains::minContains=1 with contains::all elements match, valid minContains" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 1 + } + """, + true, + """ schemaTestId: "minContains::minContains=1 with contains::all elements match, valid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=2 with contains -> empty data" + * + * Test ID: "minContains::minContains=2 with contains::empty data" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 2 + } + """, + false, + """ schemaTestId: "minContains::minContains=2 with contains::empty data" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=2 with contains -> all elements match, invalid minContains" + * + * Test ID: "minContains::minContains=2 with contains::all elements match, invalid minContains" + */ + @Test + fun jsonSchemaSuiteTest_9() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::minContains=2 with contains::all elements match, invalid minContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 2 + } + """, + false, + """ schemaTestId: "minContains::minContains=2 with contains::all elements match, invalid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=2 with contains -> some elements match, invalid minContains" + * + * Test ID: "minContains::minContains=2 with contains::some elements match, invalid minContains" + */ + @Test + fun jsonSchemaSuiteTest_10() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::minContains=2 with contains::some elements match, invalid minContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 2 + } + """, + false, + """ schemaTestId: "minContains::minContains=2 with contains::some elements match, invalid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=2 with contains -> all elements match, valid minContains (exactly as needed)" + * + * Test ID: "minContains::minContains=2 with contains::all elements match, valid minContains (exactly as needed)" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 2 + } + """, + true, + """ schemaTestId: "minContains::minContains=2 with contains::all elements match, valid minContains (exactly as needed)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=2 with contains -> all elements match, valid minContains (more than needed)" + * + * Test ID: "minContains::minContains=2 with contains::all elements match, valid minContains (more than needed)" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 2 + } + """, + true, + """ schemaTestId: "minContains::minContains=2 with contains::all elements match, valid minContains (more than needed)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=2 with contains -> some elements match, valid minContains" + * + * Test ID: "minContains::minContains=2 with contains::some elements match, valid minContains" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 2 + } + """, + true, + """ schemaTestId: "minContains::minContains=2 with contains::some elements match, valid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=2 with contains with a decimal value -> one element matches, invalid minContains" + * + * Test ID: "minContains::minContains=2 with contains with a decimal value::one element matches, invalid minContains" + */ + @Test + fun jsonSchemaSuiteTest_14() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::minContains=2 with contains with a decimal value::one element matches, invalid minContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 2.0 + } + """, + false, + """ schemaTestId: "minContains::minContains=2 with contains with a decimal value::one element matches, invalid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains=2 with contains with a decimal value -> both elements match, valid minContains" + * + * Test ID: "minContains::minContains=2 with contains with a decimal value::both elements match, valid minContains" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 2.0 + } + """, + true, + """ schemaTestId: "minContains::minContains=2 with contains with a decimal value::both elements match, valid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "maxContains = minContains -> empty data" + * + * Test ID: "minContains::maxContains = minContains::empty data" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 2, + "minContains": 2 + } + """, + false, + """ schemaTestId: "minContains::maxContains = minContains::empty data" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "maxContains = minContains -> all elements match, invalid minContains" + * + * Test ID: "minContains::maxContains = minContains::all elements match, invalid minContains" + */ + @Test + fun jsonSchemaSuiteTest_17() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::maxContains = minContains::all elements match, invalid minContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 2, + "minContains": 2 + } + """, + false, + """ schemaTestId: "minContains::maxContains = minContains::all elements match, invalid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "maxContains = minContains -> all elements match, invalid maxContains" + * + * Test ID: "minContains::maxContains = minContains::all elements match, invalid maxContains" + */ + @Test + fun jsonSchemaSuiteTest_18() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::maxContains = minContains::all elements match, invalid maxContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 2, + "minContains": 2 + } + """, + false, + """ schemaTestId: "minContains::maxContains = minContains::all elements match, invalid maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "maxContains = minContains -> all elements match, valid maxContains and minContains" + * + * Test ID: "minContains::maxContains = minContains::all elements match, valid maxContains and minContains" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 2, + "minContains": 2 + } + """, + true, + """ schemaTestId: "minContains::maxContains = minContains::all elements match, valid maxContains and minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "maxContains < minContains -> empty data" + * + * Test ID: "minContains::maxContains < minContains::empty data" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1, + "minContains": 3 + } + """, + false, + """ schemaTestId: "minContains::maxContains < minContains::empty data" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "maxContains < minContains -> invalid minContains" + * + * Test ID: "minContains::maxContains < minContains::invalid minContains" + */ + @Test + fun jsonSchemaSuiteTest_21() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::maxContains < minContains::invalid minContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1, + "minContains": 3 + } + """, + false, + """ schemaTestId: "minContains::maxContains < minContains::invalid minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "maxContains < minContains -> invalid maxContains" + * + * Test ID: "minContains::maxContains < minContains::invalid maxContains" + */ + @Test + fun jsonSchemaSuiteTest_22() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::maxContains < minContains::invalid maxContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1, + "minContains": 3 + } + """, + false, + """ schemaTestId: "minContains::maxContains < minContains::invalid maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "maxContains < minContains -> invalid maxContains and minContains" + * + * Test ID: "minContains::maxContains < minContains::invalid maxContains and minContains" + */ + @Test + fun jsonSchemaSuiteTest_23() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::maxContains < minContains::invalid maxContains and minContains" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "maxContains": 1, + "minContains": 3 + } + """, + false, + """ schemaTestId: "minContains::maxContains < minContains::invalid maxContains and minContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains = 0 -> empty data" + * + * Test ID: "minContains::minContains = 0::empty data" + */ + @Test + fun jsonSchemaSuiteTest_24() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::minContains = 0::empty data" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 0 + } + """, + true, + """ schemaTestId: "minContains::minContains = 0::empty data" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains = 0 -> minContains = 0 makes contains always pass" + * + * Test ID: "minContains::minContains = 0::minContains = 0 makes contains always pass" + */ + @Test + fun jsonSchemaSuiteTest_25() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::minContains = 0::minContains = 0 makes contains always pass" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 0 + } + """, + true, + """ schemaTestId: "minContains::minContains = 0::minContains = 0 makes contains always pass" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains = 0 with maxContains -> empty data" + * + * Test ID: "minContains::minContains = 0 with maxContains::empty data" + */ + @Test + fun jsonSchemaSuiteTest_26() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::minContains = 0 with maxContains::empty data" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 0, + "maxContains": 1 + } + """, + true, + """ schemaTestId: "minContains::minContains = 0 with maxContains::empty data" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains = 0 with maxContains -> not more than maxContains" + * + * Test ID: "minContains::minContains = 0 with maxContains::not more than maxContains" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 0, + "maxContains": 1 + } + """, + true, + """ schemaTestId: "minContains::minContains = 0 with maxContains::not more than maxContains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json`: + * "minContains = 0 with maxContains -> too many" + * + * Test ID: "minContains::minContains = 0 with maxContains::too many" + */ + @Test + fun jsonSchemaSuiteTest_28() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "minContains::minContains = 0 with maxContains::too many" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "contains": { + "const": 1 + }, + "minContains": 0, + "maxContains": 1 + } + """, + false, + """ schemaTestId: "minContains::minContains = 0 with maxContains::too many" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minItems.kt new file mode 100644 index 00000000..ea7f64c2 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minItems.kt @@ -0,0 +1,163 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_minItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minItems.json`: + * "minItems validation -> longer is valid" + * + * Test ID: "minItems::minItems validation::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minItems": 1 + } + """, + true, + """ schemaTestId: "minItems::minItems validation::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minItems.json`: + * "minItems validation -> exact length is valid" + * + * Test ID: "minItems::minItems validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minItems": 1 + } + """, + true, + """ schemaTestId: "minItems::minItems validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minItems.json`: + * "minItems validation -> too short is invalid" + * + * Test ID: "minItems::minItems validation::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minItems": 1 + } + """, + false, + """ schemaTestId: "minItems::minItems validation::too short is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minItems.json`: + * "minItems validation -> ignores non-arrays" + * + * Test ID: "minItems::minItems validation::ignores non-arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minItems": 1 + } + """, + true, + """ schemaTestId: "minItems::minItems validation::ignores non-arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minItems.json`: + * "minItems validation with a decimal -> longer is valid" + * + * Test ID: "minItems::minItems validation with a decimal::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minItems": 1.0 + } + """, + true, + """ schemaTestId: "minItems::minItems validation with a decimal::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minItems.json`: + * "minItems validation with a decimal -> too short is invalid" + * + * Test ID: "minItems::minItems validation with a decimal::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minItems": 1.0 + } + """, + false, + """ schemaTestId: "minItems::minItems validation with a decimal::too short is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minLength.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minLength.kt new file mode 100644 index 00000000..2098946e --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minLength.kt @@ -0,0 +1,176 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_minLength : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minLength.json`: + * "minLength validation -> longer is valid" + * + * Test ID: "minLength::minLength validation::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minLength": 2 + } + """, + true, + """ schemaTestId: "minLength::minLength validation::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minLength.json`: + * "minLength validation -> exact length is valid" + * + * Test ID: "minLength::minLength validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "fo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minLength": 2 + } + """, + true, + """ schemaTestId: "minLength::minLength validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minLength.json`: + * "minLength validation -> too short is invalid" + * + * Test ID: "minLength::minLength validation::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "f" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minLength": 2 + } + """, + false, + """ schemaTestId: "minLength::minLength validation::too short is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minLength.json`: + * "minLength validation -> ignores non-strings" + * + * Test ID: "minLength::minLength validation::ignores non-strings" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minLength": 2 + } + """, + true, + """ schemaTestId: "minLength::minLength validation::ignores non-strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minLength.json`: + * "minLength validation -> one grapheme is not long enough" + * + * Test ID: "minLength::minLength validation::one grapheme is not long enough" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "💩" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minLength": 2 + } + """, + false, + """ schemaTestId: "minLength::minLength validation::one grapheme is not long enough" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minLength.json`: + * "minLength validation with a decimal -> longer is valid" + * + * Test ID: "minLength::minLength validation with a decimal::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minLength": 2.0 + } + """, + true, + """ schemaTestId: "minLength::minLength validation with a decimal::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minLength.json`: + * "minLength validation with a decimal -> too short is invalid" + * + * Test ID: "minLength::minLength validation with a decimal::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "f" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minLength": 2.0 + } + """, + false, + """ schemaTestId: "minLength::minLength validation with a decimal::too short is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minProperties.kt new file mode 100644 index 00000000..7f312fa0 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minProperties.kt @@ -0,0 +1,210 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_minProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json`: + * "minProperties validation -> longer is valid" + * + * Test ID: "minProperties::minProperties validation::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json`: + * "minProperties validation -> exact length is valid" + * + * Test ID: "minProperties::minProperties validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json`: + * "minProperties validation -> too short is invalid" + * + * Test ID: "minProperties::minProperties validation::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minProperties": 1 + } + """, + false, + """ schemaTestId: "minProperties::minProperties validation::too short is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json`: + * "minProperties validation -> ignores arrays" + * + * Test ID: "minProperties::minProperties validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json`: + * "minProperties validation -> ignores strings" + * + * Test ID: "minProperties::minProperties validation::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json`: + * "minProperties validation -> ignores other non-objects" + * + * Test ID: "minProperties::minProperties validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json`: + * "minProperties validation with a decimal -> longer is valid" + * + * Test ID: "minProperties::minProperties validation with a decimal::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minProperties": 1.0 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation with a decimal::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json`: + * "minProperties validation with a decimal -> too short is invalid" + * + * Test ID: "minProperties::minProperties validation with a decimal::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minProperties": 1.0 + } + """, + false, + """ schemaTestId: "minProperties::minProperties validation with a decimal::too short is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minimum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minimum.kt new file mode 100644 index 00000000..d7f913e5 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_minimum.kt @@ -0,0 +1,268 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_minimum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation -> above the minimum is valid" + * + * Test ID: "minimum::minimum validation::above the minimum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 2.6 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": 1.1 + } + """, + true, + """ schemaTestId: "minimum::minimum validation::above the minimum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation -> boundary point is valid" + * + * Test ID: "minimum::minimum validation::boundary point is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": 1.1 + } + """, + true, + """ schemaTestId: "minimum::minimum validation::boundary point is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation -> below the minimum is invalid" + * + * Test ID: "minimum::minimum validation::below the minimum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 0.6 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": 1.1 + } + """, + false, + """ schemaTestId: "minimum::minimum validation::below the minimum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation -> ignores non-numbers" + * + * Test ID: "minimum::minimum validation::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": 1.1 + } + """, + true, + """ schemaTestId: "minimum::minimum validation::ignores non-numbers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation with signed integer -> negative above the minimum is valid" + * + * Test ID: "minimum::minimum validation with signed integer::negative above the minimum is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + -1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::negative above the minimum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation with signed integer -> positive above the minimum is valid" + * + * Test ID: "minimum::minimum validation with signed integer::positive above the minimum is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::positive above the minimum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation with signed integer -> boundary point is valid" + * + * Test ID: "minimum::minimum validation with signed integer::boundary point is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + -2 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::boundary point is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation with signed integer -> boundary point with float is valid" + * + * Test ID: "minimum::minimum validation with signed integer::boundary point with float is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + -2.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::boundary point with float is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation with signed integer -> float below the minimum is invalid" + * + * Test ID: "minimum::minimum validation with signed integer::float below the minimum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + -2.0001 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": -2 + } + """, + false, + """ schemaTestId: "minimum::minimum validation with signed integer::float below the minimum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation with signed integer -> int below the minimum is invalid" + * + * Test ID: "minimum::minimum validation with signed integer::int below the minimum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + -3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": -2 + } + """, + false, + """ schemaTestId: "minimum::minimum validation with signed integer::int below the minimum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/minimum.json`: + * "minimum validation with signed integer -> ignores non-numbers" + * + * Test ID: "minimum::minimum validation with signed integer::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::ignores non-numbers" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_multipleOf.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_multipleOf.kt new file mode 100644 index 00000000..5e9ecbfd --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_multipleOf.kt @@ -0,0 +1,247 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_multipleOf : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "by int -> int by int" + * + * Test ID: "multipleOf::by int::int by int" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 10 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "multipleOf": 2 + } + """, + true, + """ schemaTestId: "multipleOf::by int::int by int" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "by int -> int by int fail" + * + * Test ID: "multipleOf::by int::int by int fail" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 7 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "multipleOf": 2 + } + """, + false, + """ schemaTestId: "multipleOf::by int::int by int fail" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "by int -> ignores non-numbers" + * + * Test ID: "multipleOf::by int::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "multipleOf": 2 + } + """, + true, + """ schemaTestId: "multipleOf::by int::ignores non-numbers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "by number -> zero is multiple of anything" + * + * Test ID: "multipleOf::by number::zero is multiple of anything" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "multipleOf": 1.5 + } + """, + true, + """ schemaTestId: "multipleOf::by number::zero is multiple of anything" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "by number -> 4.5 is multiple of 1.5" + * + * Test ID: "multipleOf::by number::4.5 is multiple of 1.5" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 4.5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "multipleOf": 1.5 + } + """, + true, + """ schemaTestId: "multipleOf::by number::4.5 is multiple of 1.5" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "by number -> 35 is not multiple of 1.5" + * + * Test ID: "multipleOf::by number::35 is not multiple of 1.5" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 35 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "multipleOf": 1.5 + } + """, + false, + """ schemaTestId: "multipleOf::by number::35 is not multiple of 1.5" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "by small number -> 0.0075 is multiple of 0.0001" + * + * Test ID: "multipleOf::by small number::0.0075 is multiple of 0.0001" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 0.0075 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "multipleOf": 1.0E-4 + } + """, + true, + """ schemaTestId: "multipleOf::by small number::0.0075 is multiple of 0.0001" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "by small number -> 0.00751 is not multiple of 0.0001" + * + * Test ID: "multipleOf::by small number::0.00751 is not multiple of 0.0001" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + 0.00751 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "multipleOf": 1.0E-4 + } + """, + false, + """ schemaTestId: "multipleOf::by small number::0.00751 is not multiple of 0.0001" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "float division = inf -> always invalid, but naive implementations may raise an overflow error" + * + * Test ID: "multipleOf::float division = inf::always invalid, but naive implementations may raise an overflow error" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + 1.0E308 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer", + "multipleOf": 0.123456789 + } + """, + false, + """ schemaTestId: "multipleOf::float division = inf::always invalid, but naive implementations may raise an overflow error" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/multipleOf.json`: + * "small multiple of large integer -> any integer is a multiple of 1e-8" + * + * Test ID: "multipleOf::small multiple of large integer::any integer is a multiple of 1e-8" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 12391239123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer", + "multipleOf": 1.0E-8 + } + """, + true, + """ schemaTestId: "multipleOf::small multiple of large integer::any integer is a multiple of 1e-8" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_not.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_not.kt new file mode 100644 index 00000000..d2775305 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_not.kt @@ -0,0 +1,1057 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_not : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "not -> allowed" + * + * Test ID: "not::not::allowed" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "not::not::allowed" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "not -> disallowed" + * + * Test ID: "not::not::disallowed" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "not::not::disallowed" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "not multiple types -> valid" + * + * Test ID: "not::not multiple types::valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "type": [ + "integer", + "boolean" + ] + } + } + """, + true, + """ schemaTestId: "not::not multiple types::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "not multiple types -> mismatch" + * + * Test ID: "not::not multiple types::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "type": [ + "integer", + "boolean" + ] + } + } + """, + false, + """ schemaTestId: "not::not multiple types::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "not multiple types -> other mismatch" + * + * Test ID: "not::not multiple types::other mismatch" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "type": [ + "integer", + "boolean" + ] + } + } + """, + false, + """ schemaTestId: "not::not multiple types::other mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "not more complex schema -> match" + * + * Test ID: "not::not more complex schema::match" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "not::not more complex schema::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "not more complex schema -> other match" + * + * Test ID: "not::not more complex schema::other match" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "not::not more complex schema::other match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "not more complex schema -> mismatch" + * + * Test ID: "not::not more complex schema::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + false, + """ schemaTestId: "not::not more complex schema::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbidden property -> property present" + * + * Test ID: "not::forbidden property::property present" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "not": { + } + } + } + } + """, + false, + """ schemaTestId: "not::forbidden property::property present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbidden property -> property absent" + * + * Test ID: "not::forbidden property::property absent" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "bar": 1, + "baz": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "not": { + } + } + } + } + """, + true, + """ schemaTestId: "not::forbidden property::property absent" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> number is invalid" + * + * Test ID: "not::forbid everything with empty schema::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> string is invalid" + * + * Test ID: "not::forbid everything with empty schema::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> boolean true is invalid" + * + * Test ID: "not::forbid everything with empty schema::boolean true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::boolean true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> boolean false is invalid" + * + * Test ID: "not::forbid everything with empty schema::boolean false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::boolean false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> null is invalid" + * + * Test ID: "not::forbid everything with empty schema::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> object is invalid" + * + * Test ID: "not::forbid everything with empty schema::object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> empty object is invalid" + * + * Test ID: "not::forbid everything with empty schema::empty object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::empty object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> array is invalid" + * + * Test ID: "not::forbid everything with empty schema::array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with empty schema -> empty array is invalid" + * + * Test ID: "not::forbid everything with empty schema::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> number is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> string is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> boolean true is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::boolean true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::boolean true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> boolean false is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::boolean false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::boolean false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> null is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> object is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> empty object is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::empty object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::empty object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> array is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "forbid everything with boolean schema true -> empty array is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> number is valid" + * + * Test ID: "not::allow everything with boolean schema false::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> string is valid" + * + * Test ID: "not::allow everything with boolean schema false::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> boolean true is valid" + * + * Test ID: "not::allow everything with boolean schema false::boolean true is valid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::boolean true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> boolean false is valid" + * + * Test ID: "not::allow everything with boolean schema false::boolean false is valid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::boolean false is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> null is valid" + * + * Test ID: "not::allow everything with boolean schema false::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> object is valid" + * + * Test ID: "not::allow everything with boolean schema false::object is valid" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> empty object is valid" + * + * Test ID: "not::allow everything with boolean schema false::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> array is valid" + * + * Test ID: "not::allow everything with boolean schema false::array is valid" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "allow everything with boolean schema false -> empty array is valid" + * + * Test ID: "not::allow everything with boolean schema false::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "double negation -> any value is valid" + * + * Test ID: "not::double negation::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "not": { + } + } + } + """, + true, + """ schemaTestId: "not::double negation::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "collect annotations inside a 'not', even if collection is disabled -> unevaluated property" + * + * Test ID: "not::collect annotations inside a 'not', even if collection is disabled::unevaluated property" + */ + @Test + fun jsonSchemaSuiteTest_39() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "not::collect annotations inside a 'not', even if collection is disabled::unevaluated property" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "${'$'}comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them", + "anyOf": [ + true, + { + "properties": { + "foo": true + } + } + ], + "unevaluatedProperties": false + } + } + """, + true, + """ schemaTestId: "not::collect annotations inside a 'not', even if collection is disabled::unevaluated property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/not.json`: + * "collect annotations inside a 'not', even if collection is disabled -> annotations are still collected inside a 'not'" + * + * Test ID: "not::collect annotations inside a 'not', even if collection is disabled::annotations are still collected inside a 'not'" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "not": { + "${'$'}comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them", + "anyOf": [ + true, + { + "properties": { + "foo": true + } + } + ], + "unevaluatedProperties": false + } + } + """, + false, + """ schemaTestId: "not::collect annotations inside a 'not', even if collection is disabled::annotations are still collected inside a 'not'" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_oneOf.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_oneOf.kt new file mode 100644 index 00000000..6a87ff8e --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_oneOf.kt @@ -0,0 +1,975 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_oneOf : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf -> first oneOf valid" + * + * Test ID: "oneOf::oneOf::first oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf::first oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf -> second oneOf valid" + * + * Test ID: "oneOf::oneOf::second oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 2.5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf::second oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf -> both oneOf valid" + * + * Test ID: "oneOf::oneOf::both oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf::both oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf -> neither oneOf valid" + * + * Test ID: "oneOf::oneOf::neither oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 1.5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf::neither oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with base schema -> mismatch base schema" + * + * Test ID: "oneOf::oneOf with base schema::mismatch base schema" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "oneOf": [ + { + "minLength": 2 + }, + { + "maxLength": 4 + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with base schema::mismatch base schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with base schema -> one oneOf valid" + * + * Test ID: "oneOf::oneOf with base schema::one oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "oneOf": [ + { + "minLength": 2 + }, + { + "maxLength": 4 + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with base schema::one oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with base schema -> both oneOf valid" + * + * Test ID: "oneOf::oneOf with base schema::both oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "oneOf": [ + { + "minLength": 2 + }, + { + "maxLength": 4 + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with base schema::both oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with boolean schemas, all true -> any value is invalid" + * + * Test ID: "oneOf::oneOf with boolean schemas, all true::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + true, + true, + true + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with boolean schemas, all true::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with boolean schemas, one true -> any value is valid" + * + * Test ID: "oneOf::oneOf with boolean schemas, one true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + true, + false, + false + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with boolean schemas, one true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with boolean schemas, more than one true -> any value is invalid" + * + * Test ID: "oneOf::oneOf with boolean schemas, more than one true::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + true, + true, + false + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with boolean schemas, more than one true::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with boolean schemas, all false -> any value is invalid" + * + * Test ID: "oneOf::oneOf with boolean schemas, all false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + false, + false, + false + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with boolean schemas, all false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf complex types -> first oneOf valid (complex)" + * + * Test ID: "oneOf::oneOf complex types::first oneOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf complex types::first oneOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf complex types -> second oneOf valid (complex)" + * + * Test ID: "oneOf::oneOf complex types::second oneOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf complex types::second oneOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf complex types -> both oneOf valid (complex)" + * + * Test ID: "oneOf::oneOf complex types::both oneOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz", + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf complex types::both oneOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf complex types -> neither oneOf valid (complex)" + * + * Test ID: "oneOf::oneOf complex types::neither oneOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "foo": 2, + "bar": "quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf complex types::neither oneOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with empty schema -> one valid - valid" + * + * Test ID: "oneOf::oneOf with empty schema::one valid - valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with empty schema::one valid - valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with empty schema -> both valid - invalid" + * + * Test ID: "oneOf::oneOf with empty schema::both valid - invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with empty schema::both valid - invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with required -> both invalid - invalid" + * + * Test ID: "oneOf::oneOf with required::both invalid - invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "oneOf": [ + { + "required": [ + "foo", + "bar" + ] + }, + { + "required": [ + "foo", + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with required::both invalid - invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with required -> first valid - valid" + * + * Test ID: "oneOf::oneOf with required::first valid - valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "oneOf": [ + { + "required": [ + "foo", + "bar" + ] + }, + { + "required": [ + "foo", + "baz" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with required::first valid - valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with required -> second valid - valid" + * + * Test ID: "oneOf::oneOf with required::second valid - valid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "baz": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "oneOf": [ + { + "required": [ + "foo", + "bar" + ] + }, + { + "required": [ + "foo", + "baz" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with required::second valid - valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with required -> both valid - invalid" + * + * Test ID: "oneOf::oneOf with required::both valid - invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "baz": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "oneOf": [ + { + "required": [ + "foo", + "bar" + ] + }, + { + "required": [ + "foo", + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with required::both valid - invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with missing optional property -> first oneOf valid" + * + * Test ID: "oneOf::oneOf with missing optional property::first oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + { + "bar": 8 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": true + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with missing optional property::first oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with missing optional property -> second oneOf valid" + * + * Test ID: "oneOf::oneOf with missing optional property::second oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": true + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with missing optional property::second oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with missing optional property -> both oneOf valid" + * + * Test ID: "oneOf::oneOf with missing optional property::both oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": 8 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": true + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with missing optional property::both oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "oneOf with missing optional property -> neither oneOf valid" + * + * Test ID: "oneOf::oneOf with missing optional property::neither oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + "baz": "quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": true + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with missing optional property::neither oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "nested oneOf, to check validation semantics -> null is valid" + * + * Test ID: "oneOf::nested oneOf, to check validation semantics::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "oneOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::nested oneOf, to check validation semantics::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json`: + * "nested oneOf, to check validation semantics -> anything non-null is invalid" + * + * Test ID: "oneOf::nested oneOf, to check validation semantics::anything non-null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "oneOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::nested oneOf, to check validation semantics::anything non-null is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_pattern.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_pattern.kt new file mode 100644 index 00000000..ae14c304 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_pattern.kt @@ -0,0 +1,224 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_pattern : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern validation -> a matching pattern is valid" + * + * Test ID: "pattern::pattern validation::a matching pattern is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "aaa" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::a matching pattern is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern validation -> a non-matching pattern is invalid" + * + * Test ID: "pattern::pattern validation::a non-matching pattern is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "abc" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "^a*${'$'}" + } + """, + false, + """ schemaTestId: "pattern::pattern validation::a non-matching pattern is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern validation -> ignores booleans" + * + * Test ID: "pattern::pattern validation::ignores booleans" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern validation -> ignores integers" + * + * Test ID: "pattern::pattern validation::ignores integers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern validation -> ignores floats" + * + * Test ID: "pattern::pattern validation::ignores floats" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern validation -> ignores objects" + * + * Test ID: "pattern::pattern validation::ignores objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern validation -> ignores arrays" + * + * Test ID: "pattern::pattern validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern validation -> ignores null" + * + * Test ID: "pattern::pattern validation::ignores null" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/pattern.json`: + * "pattern is not anchored -> matches a substring" + * + * Test ID: "pattern::pattern is not anchored::matches a substring" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + "xxaayy" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "pattern": "a+" + } + """, + true, + """ schemaTestId: "pattern::pattern is not anchored::matches a substring" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_patternProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_patternProperties.kt new file mode 100644 index 00000000..610e140c --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_patternProperties.kt @@ -0,0 +1,708 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_patternProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties validates properties matching a regex -> a single valid match is valid" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::a single valid match is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::a single valid match is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties validates properties matching a regex -> multiple valid matches is valid" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::multiple valid matches is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "foooooo": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::multiple valid matches is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties validates properties matching a regex -> a single invalid match is invalid" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::a single invalid match is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar", + "fooooo": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::a single invalid match is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties validates properties matching a regex -> multiple invalid matches is invalid" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::multiple invalid matches is invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar", + "foooooo": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::multiple invalid matches is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties validates properties matching a regex -> ignores arrays" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties validates properties matching a regex -> ignores strings" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties validates properties matching a regex -> ignores other non-objects" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> a single valid match is valid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::a single valid match is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "a": 21 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + true, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::a single valid match is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> a simultaneous match is valid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::a simultaneous match is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "aaaa": 18 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + true, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::a simultaneous match is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> multiple matches is valid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::multiple matches is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "a": 21, + "aaaa": 18 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + true, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::multiple matches is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> an invalid due to one is invalid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "a": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + false, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> an invalid due to the other is invalid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to the other is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "aaaa": 31 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + false, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to the other is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> an invalid due to both is invalid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to both is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "aaa": "foo", + "aaaa": 31 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + false, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to both is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "regexes are not anchored by default and are case sensitive -> non recognized members are ignored" + * + * Test ID: "patternProperties::regexes are not anchored by default and are case sensitive::non recognized members are ignored" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "answer 1": "42" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "[0-9]{2,}": { + "type": "boolean" + }, + "X_": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::regexes are not anchored by default and are case sensitive::non recognized members are ignored" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "regexes are not anchored by default and are case sensitive -> recognized members are accounted for" + * + * Test ID: "patternProperties::regexes are not anchored by default and are case sensitive::recognized members are accounted for" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "a31b": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "[0-9]{2,}": { + "type": "boolean" + }, + "X_": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "patternProperties::regexes are not anchored by default and are case sensitive::recognized members are accounted for" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "regexes are not anchored by default and are case sensitive -> regexes are case sensitive" + * + * Test ID: "patternProperties::regexes are not anchored by default and are case sensitive::regexes are case sensitive" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "a_x_3": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "[0-9]{2,}": { + "type": "boolean" + }, + "X_": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::regexes are not anchored by default and are case sensitive::regexes are case sensitive" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "regexes are not anchored by default and are case sensitive -> regexes are case sensitive, 2" + * + * Test ID: "patternProperties::regexes are not anchored by default and are case sensitive::regexes are case sensitive, 2" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "a_X_3": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "[0-9]{2,}": { + "type": "boolean" + }, + "X_": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "patternProperties::regexes are not anchored by default and are case sensitive::regexes are case sensitive, 2" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties with boolean schemas -> object with property matching schema true is valid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::object with property matching schema true is valid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::object with property matching schema true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties with boolean schemas -> object with property matching schema false is invalid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::object with property matching schema false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::object with property matching schema false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties with boolean schemas -> object with both properties is invalid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::object with both properties is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::object with both properties is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties with boolean schemas -> object with a property matching both true and false is invalid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::object with a property matching both true and false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foobar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::object with a property matching both true and false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties with boolean schemas -> empty object is valid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json`: + * "patternProperties with null valued instance properties -> allows null values" + * + * Test ID: "patternProperties::patternProperties with null valued instance properties::allows null values" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + { + "foobar": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "patternProperties": { + "^.*bar${'$'}": { + "type": "null" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties with null valued instance properties::allows null values" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_prefixItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_prefixItems.kt new file mode 100644 index 00000000..6926070f --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_prefixItems.kt @@ -0,0 +1,368 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_prefixItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "a schema given for prefixItems -> correct types" + * + * Test ID: "prefixItems::a schema given for prefixItems::correct types" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "prefixItems::a schema given for prefixItems::correct types" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "a schema given for prefixItems -> wrong types" + * + * Test ID: "prefixItems::a schema given for prefixItems::wrong types" + */ + @Test + fun jsonSchemaSuiteTest_2() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "prefixItems::a schema given for prefixItems::wrong types" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + false, + """ schemaTestId: "prefixItems::a schema given for prefixItems::wrong types" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "a schema given for prefixItems -> incomplete array of items" + * + * Test ID: "prefixItems::a schema given for prefixItems::incomplete array of items" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "prefixItems::a schema given for prefixItems::incomplete array of items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "a schema given for prefixItems -> array with additional items" + * + * Test ID: "prefixItems::a schema given for prefixItems::array with additional items" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo", + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "prefixItems::a schema given for prefixItems::array with additional items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "a schema given for prefixItems -> empty array" + * + * Test ID: "prefixItems::a schema given for prefixItems::empty array" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "prefixItems::a schema given for prefixItems::empty array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "a schema given for prefixItems -> JavaScript pseudo-array is valid" + * + * Test ID: "prefixItems::a schema given for prefixItems::JavaScript pseudo-array is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "0": "invalid", + "1": "valid", + "length": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "prefixItems::a schema given for prefixItems::JavaScript pseudo-array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "prefixItems with boolean schemas -> array with one item is valid" + * + * Test ID: "prefixItems::prefixItems with boolean schemas::array with one item is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + true, + false + ] + } + """, + true, + """ schemaTestId: "prefixItems::prefixItems with boolean schemas::array with one item is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "prefixItems with boolean schemas -> array with two items is invalid" + * + * Test ID: "prefixItems::prefixItems with boolean schemas::array with two items is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "prefixItems::prefixItems with boolean schemas::array with two items is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + true, + false + ] + } + """, + false, + """ schemaTestId: "prefixItems::prefixItems with boolean schemas::array with two items is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "prefixItems with boolean schemas -> empty array is valid" + * + * Test ID: "prefixItems::prefixItems with boolean schemas::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + true, + false + ] + } + """, + true, + """ schemaTestId: "prefixItems::prefixItems with boolean schemas::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "additional items are allowed by default -> only the first item is validated" + * + * Test ID: "prefixItems::additional items are allowed by default::only the first item is validated" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo", + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + } + ] + } + """, + true, + """ schemaTestId: "prefixItems::additional items are allowed by default::only the first item is validated" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json`: + * "prefixItems with null instance elements -> allows null elements" + * + * Test ID: "prefixItems::prefixItems with null instance elements::allows null elements" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "null" + } + ] + } + """, + true, + """ schemaTestId: "prefixItems::prefixItems with null instance elements::allows null elements" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_properties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_properties.kt new file mode 100644 index 00000000..db76c65b --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_properties.kt @@ -0,0 +1,1069 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_properties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "object properties validation -> both properties present and valid is valid" + * + * Test ID: "properties::object properties validation::both properties present and valid is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "properties::object properties validation::both properties present and valid is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "object properties validation -> one property invalid is invalid" + * + * Test ID: "properties::object properties validation::one property invalid is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": { + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "properties::object properties validation::one property invalid is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "object properties validation -> both properties invalid is invalid" + * + * Test ID: "properties::object properties validation::both properties invalid is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + ], + "bar": { + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "properties::object properties validation::both properties invalid is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "object properties validation -> doesn't invalidate other properties" + * + * Test ID: "properties::object properties validation::doesn't invalidate other properties" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "quux": [ + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "properties::object properties validation::doesn't invalidate other properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "object properties validation -> ignores arrays" + * + * Test ID: "properties::object properties validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "properties::object properties validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "object properties validation -> ignores other non-objects" + * + * Test ID: "properties::object properties validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "properties::object properties validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> property validates property" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::property validates property" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + 1, + 2 + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::property validates property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> property invalidates property" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::property invalidates property" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + 1, + 2, + 3, + 4 + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::property invalidates property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> patternProperty invalidates property" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::patternProperty invalidates property" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::patternProperty invalidates property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> patternProperty validates nonproperty" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::patternProperty validates nonproperty" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "fxo": [ + 1, + 2 + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::patternProperty validates nonproperty" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> patternProperty invalidates nonproperty" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::patternProperty invalidates nonproperty" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "fxo": [ + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::patternProperty invalidates nonproperty" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> additionalProperty ignores property" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty ignores property" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "bar": [ + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty ignores property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> additionalProperty validates others" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty validates others" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "quux": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty validates others" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> additionalProperty invalidates others" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty invalidates others" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "quux": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty invalidates others" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties with boolean schema -> no property present is valid" + * + * Test ID: "properties::properties with boolean schema::no property present is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": true, + "bar": false + } + } + """, + true, + """ schemaTestId: "properties::properties with boolean schema::no property present is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties with boolean schema -> only 'true' property present is valid" + * + * Test ID: "properties::properties with boolean schema::only 'true' property present is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": true, + "bar": false + } + } + """, + true, + """ schemaTestId: "properties::properties with boolean schema::only 'true' property present is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties with boolean schema -> only 'false' property present is invalid" + * + * Test ID: "properties::properties with boolean schema::only 'false' property present is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": true, + "bar": false + } + } + """, + false, + """ schemaTestId: "properties::properties with boolean schema::only 'false' property present is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties with boolean schema -> both properties present is invalid" + * + * Test ID: "properties::properties with boolean schema::both properties present is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": true, + "bar": false + } + } + """, + false, + """ schemaTestId: "properties::properties with boolean schema::both properties present is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties with escaped characters -> object with all numbers is valid" + * + * Test ID: "properties::properties with escaped characters::object with all numbers is valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": 1, + "foo\"bar": 1, + "foo\\bar": 1, + "foo\rbar": 1, + "foo\tbar": 1, + "foo\fbar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo\nbar": { + "type": "number" + }, + "foo\"bar": { + "type": "number" + }, + "foo\\bar": { + "type": "number" + }, + "foo\rbar": { + "type": "number" + }, + "foo\tbar": { + "type": "number" + }, + "foo\fbar": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties with escaped characters::object with all numbers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties with escaped characters -> object with strings is invalid" + * + * Test ID: "properties::properties with escaped characters::object with strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": "1", + "foo\"bar": "1", + "foo\\bar": "1", + "foo\rbar": "1", + "foo\tbar": "1", + "foo\fbar": "1" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo\nbar": { + "type": "number" + }, + "foo\"bar": { + "type": "number" + }, + "foo\\bar": { + "type": "number" + }, + "foo\rbar": { + "type": "number" + }, + "foo\tbar": { + "type": "number" + }, + "foo\fbar": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "properties::properties with escaped characters::object with strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties with null valued instance properties -> allows null values" + * + * Test ID: "properties::properties with null valued instance properties::allows null values" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foo": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "null" + } + } + } + """, + true, + """ schemaTestId: "properties::properties with null valued instance properties::allows null values" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties whose names are Javascript object property names -> ignores arrays" + * + * Test ID: "properties::properties whose names are Javascript object property names::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_22() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties whose names are Javascript object property names::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties whose names are Javascript object property names -> ignores other non-objects" + * + * Test ID: "properties::properties whose names are Javascript object property names::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_23() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties whose names are Javascript object property names::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties whose names are Javascript object property names -> none of the properties mentioned" + * + * Test ID: "properties::properties whose names are Javascript object property names::none of the properties mentioned" + */ + @Test + fun jsonSchemaSuiteTest_24() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties whose names are Javascript object property names::none of the properties mentioned" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties whose names are Javascript object property names -> __proto__ not valid" + * + * Test ID: "properties::properties whose names are Javascript object property names::__proto__ not valid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "__proto__": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "properties::properties whose names are Javascript object property names::__proto__ not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties whose names are Javascript object property names -> toString not valid" + * + * Test ID: "properties::properties whose names are Javascript object property names::toString not valid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "toString": { + "length": 37 + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "properties::properties whose names are Javascript object property names::toString not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties whose names are Javascript object property names -> constructor not valid" + * + * Test ID: "properties::properties whose names are Javascript object property names::constructor not valid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "constructor": { + "length": 37 + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "properties::properties whose names are Javascript object property names::constructor not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/properties.json`: + * "properties whose names are Javascript object property names -> all present and valid" + * + * Test ID: "properties::properties whose names are Javascript object property names::all present and valid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "__proto__": 12, + "toString": { + "length": "foo" + }, + "constructor": 37 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties whose names are Javascript object property names::all present and valid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_propertyNames.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_propertyNames.kt new file mode 100644 index 00000000..529cab07 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_propertyNames.kt @@ -0,0 +1,279 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_propertyNames : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames validation -> all property names valid" + * + * Test ID: "propertyNames::propertyNames validation::all property names valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "f": { + }, + "foo": { + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::all property names valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames validation -> some property names invalid" + * + * Test ID: "propertyNames::propertyNames validation::some property names invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + }, + "foobar": { + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 3 + } + } + """, + false, + """ schemaTestId: "propertyNames::propertyNames validation::some property names invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames validation -> object without properties is valid" + * + * Test ID: "propertyNames::propertyNames validation::object without properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::object without properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames validation -> ignores arrays" + * + * Test ID: "propertyNames::propertyNames validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3, + 4 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames validation -> ignores strings" + * + * Test ID: "propertyNames::propertyNames validation::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames validation -> ignores other non-objects" + * + * Test ID: "propertyNames::propertyNames validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames with boolean schema true -> object with any properties is valid" + * + * Test ID: "propertyNames::propertyNames with boolean schema true::object with any properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": true + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames with boolean schema true::object with any properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames with boolean schema true -> empty object is valid" + * + * Test ID: "propertyNames::propertyNames with boolean schema true::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": true + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames with boolean schema true::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames with boolean schema false -> object with any properties is invalid" + * + * Test ID: "propertyNames::propertyNames with boolean schema false::object with any properties is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": false + } + """, + false, + """ schemaTestId: "propertyNames::propertyNames with boolean schema false::object with any properties is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json`: + * "propertyNames with boolean schema false -> empty object is valid" + * + * Test ID: "propertyNames::propertyNames with boolean schema false::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": false + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames with boolean schema false::empty object is valid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_ref.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_ref.kt new file mode 100644 index 00000000..145e8903 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_ref.kt @@ -0,0 +1,2894 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_ref : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "root pointer ref -> match" + * + * Test ID: "ref::root pointer ref::match" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": false + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "${'$'}ref": "#" + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "ref::root pointer ref::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "root pointer ref -> recursive match" + * + * Test ID: "ref::root pointer ref::recursive match" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + "foo": false + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "${'$'}ref": "#" + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "ref::root pointer ref::recursive match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "root pointer ref -> mismatch" + * + * Test ID: "ref::root pointer ref::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "bar": false + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "${'$'}ref": "#" + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "ref::root pointer ref::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "root pointer ref -> recursive mismatch" + * + * Test ID: "ref::root pointer ref::recursive mismatch" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": false + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "${'$'}ref": "#" + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "ref::root pointer ref::recursive mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "relative pointer ref to object -> match" + * + * Test ID: "ref::relative pointer ref to object::match" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "bar": 3 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "${'$'}ref": "#/properties/foo" + } + } + } + """, + true, + """ schemaTestId: "ref::relative pointer ref to object::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "relative pointer ref to object -> mismatch" + * + * Test ID: "ref::relative pointer ref to object::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "bar": true + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "${'$'}ref": "#/properties/foo" + } + } + } + """, + false, + """ schemaTestId: "ref::relative pointer ref to object::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "relative pointer ref to array -> match array" + * + * Test ID: "ref::relative pointer ref to array::match array" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + }, + { + "${'$'}ref": "#/prefixItems/0" + } + ] + } + """, + true, + """ schemaTestId: "ref::relative pointer ref to array::match array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "relative pointer ref to array -> mismatch array" + * + * Test ID: "ref::relative pointer ref to array::mismatch array" + */ + @Test + fun jsonSchemaSuiteTest_8() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::relative pointer ref to array::mismatch array" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "integer" + }, + { + "${'$'}ref": "#/prefixItems/0" + } + ] + } + """, + false, + """ schemaTestId: "ref::relative pointer ref to array::mismatch array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "escaped pointer ref -> slash invalid" + * + * Test ID: "ref::escaped pointer ref::slash invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "slash": "aoeu" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/${'$'}defs/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/${'$'}defs/slash~1field" + }, + "percent": { + "${'$'}ref": "#/${'$'}defs/percent%25field" + } + } + } + """, + false, + """ schemaTestId: "ref::escaped pointer ref::slash invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "escaped pointer ref -> tilde invalid" + * + * Test ID: "ref::escaped pointer ref::tilde invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "tilde": "aoeu" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/${'$'}defs/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/${'$'}defs/slash~1field" + }, + "percent": { + "${'$'}ref": "#/${'$'}defs/percent%25field" + } + } + } + """, + false, + """ schemaTestId: "ref::escaped pointer ref::tilde invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "escaped pointer ref -> percent invalid" + * + * Test ID: "ref::escaped pointer ref::percent invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "percent": "aoeu" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/${'$'}defs/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/${'$'}defs/slash~1field" + }, + "percent": { + "${'$'}ref": "#/${'$'}defs/percent%25field" + } + } + } + """, + false, + """ schemaTestId: "ref::escaped pointer ref::percent invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "escaped pointer ref -> slash valid" + * + * Test ID: "ref::escaped pointer ref::slash valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "slash": 123 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/${'$'}defs/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/${'$'}defs/slash~1field" + }, + "percent": { + "${'$'}ref": "#/${'$'}defs/percent%25field" + } + } + } + """, + true, + """ schemaTestId: "ref::escaped pointer ref::slash valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "escaped pointer ref -> tilde valid" + * + * Test ID: "ref::escaped pointer ref::tilde valid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "tilde": 123 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/${'$'}defs/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/${'$'}defs/slash~1field" + }, + "percent": { + "${'$'}ref": "#/${'$'}defs/percent%25field" + } + } + } + """, + true, + """ schemaTestId: "ref::escaped pointer ref::tilde valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "escaped pointer ref -> percent valid" + * + * Test ID: "ref::escaped pointer ref::percent valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "percent": 123 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/${'$'}defs/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/${'$'}defs/slash~1field" + }, + "percent": { + "${'$'}ref": "#/${'$'}defs/percent%25field" + } + } + } + """, + true, + """ schemaTestId: "ref::escaped pointer ref::percent valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "nested refs -> nested ref valid" + * + * Test ID: "ref::nested refs::nested ref valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 5 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "a": { + "type": "integer" + }, + "b": { + "${'$'}ref": "#/${'$'}defs/a" + }, + "c": { + "${'$'}ref": "#/${'$'}defs/b" + } + }, + "${'$'}ref": "#/${'$'}defs/c" + } + """, + true, + """ schemaTestId: "ref::nested refs::nested ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "nested refs -> nested ref invalid" + * + * Test ID: "ref::nested refs::nested ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "a": { + "type": "integer" + }, + "b": { + "${'$'}ref": "#/${'$'}defs/a" + }, + "c": { + "${'$'}ref": "#/${'$'}defs/b" + } + }, + "${'$'}ref": "#/${'$'}defs/c" + } + """, + false, + """ schemaTestId: "ref::nested refs::nested ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref applies alongside sibling keywords -> ref valid, maxItems valid" + * + * Test ID: "ref::ref applies alongside sibling keywords::ref valid, maxItems valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/reffed", + "maxItems": 2 + } + } + } + """, + true, + """ schemaTestId: "ref::ref applies alongside sibling keywords::ref valid, maxItems valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref applies alongside sibling keywords -> ref valid, maxItems invalid" + * + * Test ID: "ref::ref applies alongside sibling keywords::ref valid, maxItems invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::ref applies alongside sibling keywords::ref valid, maxItems invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": [ + 1, + 2, + 3 + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/reffed", + "maxItems": 2 + } + } + } + """, + false, + """ schemaTestId: "ref::ref applies alongside sibling keywords::ref valid, maxItems invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref applies alongside sibling keywords -> ref invalid" + * + * Test ID: "ref::ref applies alongside sibling keywords::ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo": "string" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/reffed", + "maxItems": 2 + } + } + } + """, + false, + """ schemaTestId: "ref::ref applies alongside sibling keywords::ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "remote ref, containing refs itself -> remote ref valid" + * + * Test ID: "ref::remote ref, containing refs itself::remote ref valid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::remote ref, containing refs itself::remote ref valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "minLength": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "https://json-schema.org/draft/2020-12/schema" + } + """, + true, + """ schemaTestId: "ref::remote ref, containing refs itself::remote ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "remote ref, containing refs itself -> remote ref invalid" + * + * Test ID: "ref::remote ref, containing refs itself::remote ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::remote ref, containing refs itself::remote ref invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "minLength": -1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "https://json-schema.org/draft/2020-12/schema" + } + """, + false, + """ schemaTestId: "ref::remote ref, containing refs itself::remote ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "property named $ref that is not a reference -> property named $ref valid" + * + * Test ID: "ref::property named $ref that is not a reference::property named $ref valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "${'$'}ref": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::property named ${'$'}ref that is not a reference::property named ${'$'}ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "property named $ref that is not a reference -> property named $ref invalid" + * + * Test ID: "ref::property named $ref that is not a reference::property named $ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "${'$'}ref": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::property named ${'$'}ref that is not a reference::property named ${'$'}ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "property named $ref, containing an actual $ref -> property named $ref valid" + * + * Test ID: "ref::property named $ref, containing an actual $ref::property named $ref valid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "${'$'}ref": { + "${'$'}ref": "#/${'$'}defs/is-string" + } + }, + "${'$'}defs": { + "is-string": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::property named ${'$'}ref, containing an actual ${'$'}ref::property named ${'$'}ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "property named $ref, containing an actual $ref -> property named $ref invalid" + * + * Test ID: "ref::property named $ref, containing an actual $ref::property named $ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": 2 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "${'$'}ref": { + "${'$'}ref": "#/${'$'}defs/is-string" + } + }, + "${'$'}defs": { + "is-string": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::property named ${'$'}ref, containing an actual ${'$'}ref::property named ${'$'}ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "$ref to boolean schema true -> any value is valid" + * + * Test ID: "ref::$ref to boolean schema true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "#/${'$'}defs/bool", + "${'$'}defs": { + "bool": true + } + } + """, + true, + """ schemaTestId: "ref::${'$'}ref to boolean schema true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "$ref to boolean schema false -> any value is invalid" + * + * Test ID: "ref::$ref to boolean schema false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "#/${'$'}defs/bool", + "${'$'}defs": { + "bool": false + } + } + """, + false, + """ schemaTestId: "ref::${'$'}ref to boolean schema false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "Recursive references between schemas -> valid tree" + * + * Test ID: "ref::Recursive references between schemas::valid tree" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + { + "meta": "root", + "nodes": [ + { + "value": 1, + "subtree": { + "meta": "child", + "nodes": [ + { + "value": 1.1 + }, + { + "value": 1.2 + } + ] + } + }, + { + "value": 2, + "subtree": { + "meta": "child", + "nodes": [ + { + "value": 2.1 + }, + { + "value": 2.2 + } + ] + } + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/tree", + "description": "tree of nodes", + "type": "object", + "properties": { + "meta": { + "type": "string" + }, + "nodes": { + "type": "array", + "items": { + "${'$'}ref": "node" + } + } + }, + "required": [ + "meta", + "nodes" + ], + "${'$'}defs": { + "node": { + "${'$'}id": "http://localhost:1234/draft2020-12/node", + "description": "node", + "type": "object", + "properties": { + "value": { + "type": "number" + }, + "subtree": { + "${'$'}ref": "tree" + } + }, + "required": [ + "value" + ] + } + } + } + """, + true, + """ schemaTestId: "ref::Recursive references between schemas::valid tree" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "Recursive references between schemas -> invalid tree" + * + * Test ID: "ref::Recursive references between schemas::invalid tree" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + { + "meta": "root", + "nodes": [ + { + "value": 1, + "subtree": { + "meta": "child", + "nodes": [ + { + "value": "string is invalid" + }, + { + "value": 1.2 + } + ] + } + }, + { + "value": 2, + "subtree": { + "meta": "child", + "nodes": [ + { + "value": 2.1 + }, + { + "value": 2.2 + } + ] + } + } + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/tree", + "description": "tree of nodes", + "type": "object", + "properties": { + "meta": { + "type": "string" + }, + "nodes": { + "type": "array", + "items": { + "${'$'}ref": "node" + } + } + }, + "required": [ + "meta", + "nodes" + ], + "${'$'}defs": { + "node": { + "${'$'}id": "http://localhost:1234/draft2020-12/node", + "description": "node", + "type": "object", + "properties": { + "value": { + "type": "number" + }, + "subtree": { + "${'$'}ref": "tree" + } + }, + "required": [ + "value" + ] + } + } + } + """, + false, + """ schemaTestId: "ref::Recursive references between schemas::invalid tree" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "refs with quote -> object with numbers is valid" + * + * Test ID: "ref::refs with quote::object with numbers is valid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + { + "foo\"bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo\"bar": { + "${'$'}ref": "#/${'$'}defs/foo%22bar" + } + }, + "${'$'}defs": { + "foo\"bar": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "ref::refs with quote::object with numbers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "refs with quote -> object with strings is invalid" + * + * Test ID: "ref::refs with quote::object with strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + { + "foo\"bar": "1" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo\"bar": { + "${'$'}ref": "#/${'$'}defs/foo%22bar" + } + }, + "${'$'}defs": { + "foo\"bar": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "ref::refs with quote::object with strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref creates new scope when adjacent to keywords -> referenced subschema doesn't see annotations from properties" + * + * Test ID: "ref::ref creates new scope when adjacent to keywords::referenced subschema doesn't see annotations from properties" + */ + @Test + fun jsonSchemaSuiteTest_32() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::ref creates new scope when adjacent to keywords::referenced subschema doesn't see annotations from properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "prop1": "match" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "A": { + "unevaluatedProperties": false + } + }, + "properties": { + "prop1": { + "type": "string" + } + }, + "${'$'}ref": "#/${'$'}defs/A" + } + """, + false, + """ schemaTestId: "ref::ref creates new scope when adjacent to keywords::referenced subschema doesn't see annotations from properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "naive replacement of $ref with its destination is not correct -> do not evaluate the $ref inside the enum, matching any string" + * + * Test ID: "ref::naive replacement of $ref with its destination is not correct::do not evaluate the $ref inside the enum, matching any string" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + "this is a string" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "a_string": { + "type": "string" + } + }, + "enum": [ + { + "${'$'}ref": "#/${'$'}defs/a_string" + } + ] + } + """, + false, + """ schemaTestId: "ref::naive replacement of ${'$'}ref with its destination is not correct::do not evaluate the ${'$'}ref inside the enum, matching any string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "naive replacement of $ref with its destination is not correct -> do not evaluate the $ref inside the enum, definition exact match" + * + * Test ID: "ref::naive replacement of $ref with its destination is not correct::do not evaluate the $ref inside the enum, definition exact match" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + { + "type": "string" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "a_string": { + "type": "string" + } + }, + "enum": [ + { + "${'$'}ref": "#/${'$'}defs/a_string" + } + ] + } + """, + false, + """ schemaTestId: "ref::naive replacement of ${'$'}ref with its destination is not correct::do not evaluate the ${'$'}ref inside the enum, definition exact match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "naive replacement of $ref with its destination is not correct -> match the enum exactly" + * + * Test ID: "ref::naive replacement of $ref with its destination is not correct::match the enum exactly" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": "#/${'$'}defs/a_string" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "a_string": { + "type": "string" + } + }, + "enum": [ + { + "${'$'}ref": "#/${'$'}defs/a_string" + } + ] + } + """, + true, + """ schemaTestId: "ref::naive replacement of ${'$'}ref with its destination is not correct::match the enum exactly" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "refs with relative uris and defs -> invalid on inner field" + * + * Test ID: "ref::refs with relative uris and defs::invalid on inner field" + */ + @Test + fun jsonSchemaSuiteTest_36() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::refs with relative uris and defs::invalid on inner field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": 1 + }, + "bar": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", + "properties": { + "foo": { + "${'$'}id": "schema-relative-uri-defs2.json", + "${'$'}defs": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "${'$'}ref": "#/${'$'}defs/inner" + } + }, + "${'$'}ref": "schema-relative-uri-defs2.json" + } + """, + false, + """ schemaTestId: "ref::refs with relative uris and defs::invalid on inner field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "refs with relative uris and defs -> invalid on outer field" + * + * Test ID: "ref::refs with relative uris and defs::invalid on outer field" + */ + @Test + fun jsonSchemaSuiteTest_37() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::refs with relative uris and defs::invalid on outer field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "a" + }, + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", + "properties": { + "foo": { + "${'$'}id": "schema-relative-uri-defs2.json", + "${'$'}defs": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "${'$'}ref": "#/${'$'}defs/inner" + } + }, + "${'$'}ref": "schema-relative-uri-defs2.json" + } + """, + false, + """ schemaTestId: "ref::refs with relative uris and defs::invalid on outer field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "refs with relative uris and defs -> valid on both fields" + * + * Test ID: "ref::refs with relative uris and defs::valid on both fields" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "a" + }, + "bar": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", + "properties": { + "foo": { + "${'$'}id": "schema-relative-uri-defs2.json", + "${'$'}defs": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "${'$'}ref": "#/${'$'}defs/inner" + } + }, + "${'$'}ref": "schema-relative-uri-defs2.json" + } + """, + true, + """ schemaTestId: "ref::refs with relative uris and defs::valid on both fields" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "relative refs with absolute uris and defs -> invalid on inner field" + * + * Test ID: "ref::relative refs with absolute uris and defs::invalid on inner field" + */ + @Test + fun jsonSchemaSuiteTest_39() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::relative refs with absolute uris and defs::invalid on inner field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": 1 + }, + "bar": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", + "properties": { + "foo": { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", + "${'$'}defs": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "${'$'}ref": "#/${'$'}defs/inner" + } + }, + "${'$'}ref": "schema-refs-absolute-uris-defs2.json" + } + """, + false, + """ schemaTestId: "ref::relative refs with absolute uris and defs::invalid on inner field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "relative refs with absolute uris and defs -> invalid on outer field" + * + * Test ID: "ref::relative refs with absolute uris and defs::invalid on outer field" + */ + @Test + fun jsonSchemaSuiteTest_40() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::relative refs with absolute uris and defs::invalid on outer field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "a" + }, + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", + "properties": { + "foo": { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", + "${'$'}defs": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "${'$'}ref": "#/${'$'}defs/inner" + } + }, + "${'$'}ref": "schema-refs-absolute-uris-defs2.json" + } + """, + false, + """ schemaTestId: "ref::relative refs with absolute uris and defs::invalid on outer field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "relative refs with absolute uris and defs -> valid on both fields" + * + * Test ID: "ref::relative refs with absolute uris and defs::valid on both fields" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "a" + }, + "bar": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", + "properties": { + "foo": { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", + "${'$'}defs": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "${'$'}ref": "#/${'$'}defs/inner" + } + }, + "${'$'}ref": "schema-refs-absolute-uris-defs2.json" + } + """, + true, + """ schemaTestId: "ref::relative refs with absolute uris and defs::valid on both fields" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "$id must be resolved against nearest parent, not just immediate parent -> number is valid" + * + * Test ID: "ref::$id must be resolved against nearest parent, not just immediate parent::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/a.json", + "${'$'}defs": { + "x": { + "${'$'}id": "http://example.com/b/c.json", + "not": { + "${'$'}defs": { + "y": { + "${'$'}id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "http://example.com/b/d.json" + } + ] + } + """, + true, + """ schemaTestId: "ref::${'$'}id must be resolved against nearest parent, not just immediate parent::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "$id must be resolved against nearest parent, not just immediate parent -> non-number is invalid" + * + * Test ID: "ref::$id must be resolved against nearest parent, not just immediate parent::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/a.json", + "${'$'}defs": { + "x": { + "${'$'}id": "http://example.com/b/c.json", + "not": { + "${'$'}defs": { + "y": { + "${'$'}id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "http://example.com/b/d.json" + } + ] + } + """, + false, + """ schemaTestId: "ref::${'$'}id must be resolved against nearest parent, not just immediate parent::non-number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "order of evaluation: $id and $ref -> data is valid against first definition" + * + * Test ID: "ref::order of evaluation: $id and $ref::data is valid against first definition" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + 5 + """, + """ + { + "${'$'}comment": "${'$'}id must be evaluated before ${'$'}ref to get the proper ${'$'}ref destination", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://example.com/draft2020-12/ref-and-id1/base.json", + "${'$'}ref": "int.json", + "${'$'}defs": { + "bigint": { + "${'$'}comment": "canonical uri: https://example.com/ref-and-id1/int.json", + "${'$'}id": "int.json", + "maximum": 10 + }, + "smallint": { + "${'$'}comment": "canonical uri: https://example.com/ref-and-id1-int.json", + "${'$'}id": "/draft2020-12/ref-and-id1-int.json", + "maximum": 2 + } + } + } + """, + true, + """ schemaTestId: "ref::order of evaluation: ${'$'}id and ${'$'}ref::data is valid against first definition" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "order of evaluation: $id and $ref -> data is invalid against first definition" + * + * Test ID: "ref::order of evaluation: $id and $ref::data is invalid against first definition" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + 50 + """, + """ + { + "${'$'}comment": "${'$'}id must be evaluated before ${'$'}ref to get the proper ${'$'}ref destination", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://example.com/draft2020-12/ref-and-id1/base.json", + "${'$'}ref": "int.json", + "${'$'}defs": { + "bigint": { + "${'$'}comment": "canonical uri: https://example.com/ref-and-id1/int.json", + "${'$'}id": "int.json", + "maximum": 10 + }, + "smallint": { + "${'$'}comment": "canonical uri: https://example.com/ref-and-id1-int.json", + "${'$'}id": "/draft2020-12/ref-and-id1-int.json", + "maximum": 2 + } + } + } + """, + false, + """ schemaTestId: "ref::order of evaluation: ${'$'}id and ${'$'}ref::data is invalid against first definition" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "order of evaluation: $id and $anchor and $ref -> data is valid against first definition" + * + * Test ID: "ref::order of evaluation: $id and $anchor and $ref::data is valid against first definition" + */ + @Test + fun jsonSchemaSuiteTest_46() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::order of evaluation: $id and $anchor and $ref::data is valid against first definition" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 5 + """, + """ + { + "${'$'}comment": "${'$'}id must be evaluated before ${'$'}ref to get the proper ${'$'}ref destination", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://example.com/draft2020-12/ref-and-id2/base.json", + "${'$'}ref": "#bigint", + "${'$'}defs": { + "bigint": { + "${'$'}comment": "canonical uri: /ref-and-id2/base.json#/${'$'}defs/bigint; another valid uri for this location: /ref-and-id2/base.json#bigint", + "${'$'}anchor": "bigint", + "maximum": 10 + }, + "smallint": { + "${'$'}comment": "canonical uri: https://example.com/ref-and-id2#/${'$'}defs/smallint; another valid uri for this location: https://example.com/ref-and-id2/#bigint", + "${'$'}id": "https://example.com/draft2020-12/ref-and-id2/", + "${'$'}anchor": "bigint", + "maximum": 2 + } + } + } + """, + true, + """ schemaTestId: "ref::order of evaluation: ${'$'}id and ${'$'}anchor and ${'$'}ref::data is valid against first definition" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "order of evaluation: $id and $anchor and $ref -> data is invalid against first definition" + * + * Test ID: "ref::order of evaluation: $id and $anchor and $ref::data is invalid against first definition" + */ + @Test + fun jsonSchemaSuiteTest_47() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::order of evaluation: $id and $anchor and $ref::data is invalid against first definition" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 50 + """, + """ + { + "${'$'}comment": "${'$'}id must be evaluated before ${'$'}ref to get the proper ${'$'}ref destination", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://example.com/draft2020-12/ref-and-id2/base.json", + "${'$'}ref": "#bigint", + "${'$'}defs": { + "bigint": { + "${'$'}comment": "canonical uri: /ref-and-id2/base.json#/${'$'}defs/bigint; another valid uri for this location: /ref-and-id2/base.json#bigint", + "${'$'}anchor": "bigint", + "maximum": 10 + }, + "smallint": { + "${'$'}comment": "canonical uri: https://example.com/ref-and-id2#/${'$'}defs/smallint; another valid uri for this location: https://example.com/ref-and-id2/#bigint", + "${'$'}id": "https://example.com/draft2020-12/ref-and-id2/", + "${'$'}anchor": "bigint", + "maximum": 2 + } + } + } + """, + false, + """ schemaTestId: "ref::order of evaluation: ${'$'}id and ${'$'}anchor and ${'$'}ref::data is invalid against first definition" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "simple URN base URI with $ref via the URN -> valid under the URN IDed schema" + * + * Test ID: "ref::simple URN base URI with $ref via the URN::valid under the URN IDed schema" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + { + "foo": 37 + } + """, + """ + { + "${'$'}comment": "URIs do not have to have HTTP(s) schemes", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed", + "minimum": 30, + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed" + } + } + } + """, + true, + """ schemaTestId: "ref::simple URN base URI with ${'$'}ref via the URN::valid under the URN IDed schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "simple URN base URI with $ref via the URN -> invalid under the URN IDed schema" + * + * Test ID: "ref::simple URN base URI with $ref via the URN::invalid under the URN IDed schema" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "URIs do not have to have HTTP(s) schemes", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed", + "minimum": 30, + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed" + } + } + } + """, + false, + """ schemaTestId: "ref::simple URN base URI with ${'$'}ref via the URN::invalid under the URN IDed schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "simple URN base URI with JSON pointer -> a string is valid" + * + * Test ID: "ref::simple URN base URI with JSON pointer::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}comment": "URIs do not have to have HTTP(s) schemes", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::simple URN base URI with JSON pointer::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "simple URN base URI with JSON pointer -> a non-string is invalid" + * + * Test ID: "ref::simple URN base URI with JSON pointer::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "URIs do not have to have HTTP(s) schemes", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::simple URN base URI with JSON pointer::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with NSS -> a string is valid" + * + * Test ID: "ref::URN base URI with NSS::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.2", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:example:1/406/47452/2", + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with NSS::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with NSS -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with NSS::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.2", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:example:1/406/47452/2", + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with NSS::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with r-component -> a string is valid" + * + * Test ID: "ref::URN base URI with r-component::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.3.1", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk", + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with r-component::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with r-component -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with r-component::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.3.1", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk", + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with r-component::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with q-component -> a string is valid" + * + * Test ID: "ref::URN base URI with q-component::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.3.2", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z", + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with q-component::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with q-component -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with q-component::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_57() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.3.2", + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z", + "properties": { + "foo": { + "${'$'}ref": "#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with q-component::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with URN and JSON pointer ref -> a string is valid" + * + * Test ID: "ref::URN base URI with URN and JSON pointer ref::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with URN and JSON pointer ref::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with URN and JSON pointer ref -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with URN and JSON pointer ref::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with URN and JSON pointer ref::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with URN and anchor ref -> a string is valid" + * + * Test ID: "ref::URN base URI with URN and anchor ref::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_60() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::URN base URI with URN and anchor ref::a string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something" + } + }, + "${'$'}defs": { + "bar": { + "${'$'}anchor": "something", + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with URN and anchor ref::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN base URI with URN and anchor ref -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with URN and anchor ref::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_61() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::URN base URI with URN and anchor ref::a non-string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something" + } + }, + "${'$'}defs": { + "bar": { + "${'$'}anchor": "something", + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with URN and anchor ref::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN ref with nested pointer ref -> a string is valid" + * + * Test ID: "ref::URN ref with nested pointer ref::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + "bar" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "${'$'}defs": { + "foo": { + "${'$'}id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "${'$'}defs": { + "bar": { + "type": "string" + } + }, + "${'$'}ref": "#/${'$'}defs/bar" + } + } + } + """, + true, + """ schemaTestId: "ref::URN ref with nested pointer ref::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "URN ref with nested pointer ref -> a non-string is invalid" + * + * Test ID: "ref::URN ref with nested pointer ref::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_63() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::URN ref with nested pointer ref::a non-string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "${'$'}defs": { + "foo": { + "${'$'}id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "${'$'}defs": { + "bar": { + "type": "string" + } + }, + "${'$'}ref": "#/${'$'}defs/bar" + } + } + } + """, + false, + """ schemaTestId: "ref::URN ref with nested pointer ref::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref to if -> a non-integer is invalid due to the $ref" + * + * Test ID: "ref::ref to if::a non-integer is invalid due to the $ref" + */ + @Test + fun jsonSchemaSuiteTest_64() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://example.com/ref/if", + "if": { + "${'$'}id": "http://example.com/ref/if", + "type": "integer" + } + } + """, + false, + """ schemaTestId: "ref::ref to if::a non-integer is invalid due to the ${'$'}ref" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref to if -> an integer is valid" + * + * Test ID: "ref::ref to if::an integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_65() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://example.com/ref/if", + "if": { + "${'$'}id": "http://example.com/ref/if", + "type": "integer" + } + } + """, + true, + """ schemaTestId: "ref::ref to if::an integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref to then -> a non-integer is invalid due to the $ref" + * + * Test ID: "ref::ref to then::a non-integer is invalid due to the $ref" + */ + @Test + fun jsonSchemaSuiteTest_66() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://example.com/ref/then", + "then": { + "${'$'}id": "http://example.com/ref/then", + "type": "integer" + } + } + """, + false, + """ schemaTestId: "ref::ref to then::a non-integer is invalid due to the ${'$'}ref" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref to then -> an integer is valid" + * + * Test ID: "ref::ref to then::an integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_67() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://example.com/ref/then", + "then": { + "${'$'}id": "http://example.com/ref/then", + "type": "integer" + } + } + """, + true, + """ schemaTestId: "ref::ref to then::an integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref to else -> a non-integer is invalid due to the $ref" + * + * Test ID: "ref::ref to else::a non-integer is invalid due to the $ref" + */ + @Test + fun jsonSchemaSuiteTest_68() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://example.com/ref/else", + "else": { + "${'$'}id": "http://example.com/ref/else", + "type": "integer" + } + } + """, + false, + """ schemaTestId: "ref::ref to else::a non-integer is invalid due to the ${'$'}ref" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref to else -> an integer is valid" + * + * Test ID: "ref::ref to else::an integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_69() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://example.com/ref/else", + "else": { + "${'$'}id": "http://example.com/ref/else", + "type": "integer" + } + } + """, + true, + """ schemaTestId: "ref::ref to else::an integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref with absolute-path-reference -> a string is valid" + * + * Test ID: "ref::ref with absolute-path-reference::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_70() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/ref/absref.json", + "${'$'}defs": { + "a": { + "${'$'}id": "http://example.com/ref/absref/foobar.json", + "type": "number" + }, + "b": { + "${'$'}id": "http://example.com/absref/foobar.json", + "type": "string" + } + }, + "${'$'}ref": "/absref/foobar.json" + } + """, + true, + """ schemaTestId: "ref::ref with absolute-path-reference::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "ref with absolute-path-reference -> an integer is invalid" + * + * Test ID: "ref::ref with absolute-path-reference::an integer is invalid" + */ + @Test + fun jsonSchemaSuiteTest_71() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://example.com/ref/absref.json", + "${'$'}defs": { + "a": { + "${'$'}id": "http://example.com/ref/absref/foobar.json", + "type": "number" + }, + "b": { + "${'$'}id": "http://example.com/absref/foobar.json", + "type": "string" + } + }, + "${'$'}ref": "/absref/foobar.json" + } + """, + false, + """ schemaTestId: "ref::ref with absolute-path-reference::an integer is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "$id with file URI still resolves pointers - *nix -> number is valid" + * + * Test ID: "ref::$id with file URI still resolves pointers - *nix::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_72() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "file:///folder/file.json", + "${'$'}defs": { + "foo": { + "type": "number" + } + }, + "${'$'}ref": "#/${'$'}defs/foo" + } + """, + true, + """ schemaTestId: "ref::${'$'}id with file URI still resolves pointers - *nix::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "$id with file URI still resolves pointers - *nix -> non-number is invalid" + * + * Test ID: "ref::$id with file URI still resolves pointers - *nix::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_73() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "file:///folder/file.json", + "${'$'}defs": { + "foo": { + "type": "number" + } + }, + "${'$'}ref": "#/${'$'}defs/foo" + } + """, + false, + """ schemaTestId: "ref::${'$'}id with file URI still resolves pointers - *nix::non-number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "$id with file URI still resolves pointers - windows -> number is valid" + * + * Test ID: "ref::$id with file URI still resolves pointers - windows::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_74() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "file:///c:/folder/file.json", + "${'$'}defs": { + "foo": { + "type": "number" + } + }, + "${'$'}ref": "#/${'$'}defs/foo" + } + """, + true, + """ schemaTestId: "ref::${'$'}id with file URI still resolves pointers - windows::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "$id with file URI still resolves pointers - windows -> non-number is invalid" + * + * Test ID: "ref::$id with file URI still resolves pointers - windows::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_75() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "file:///c:/folder/file.json", + "${'$'}defs": { + "foo": { + "type": "number" + } + }, + "${'$'}ref": "#/${'$'}defs/foo" + } + """, + false, + """ schemaTestId: "ref::${'$'}id with file URI still resolves pointers - windows::non-number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "empty tokens in $ref json-pointer -> number is valid" + * + * Test ID: "ref::empty tokens in $ref json-pointer::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_76() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "": { + "${'$'}defs": { + "": { + "type": "number" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs//${'$'}defs/" + } + ] + } + """, + true, + """ schemaTestId: "ref::empty tokens in ${'$'}ref json-pointer::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json`: + * "empty tokens in $ref json-pointer -> non-number is invalid" + * + * Test ID: "ref::empty tokens in $ref json-pointer::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_77() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "": { + "${'$'}defs": { + "": { + "type": "number" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs//${'$'}defs/" + } + ] + } + """, + false, + """ schemaTestId: "ref::empty tokens in ${'$'}ref json-pointer::non-number is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_refRemote.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_refRemote.kt new file mode 100644 index 00000000..f32349df --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_refRemote.kt @@ -0,0 +1,1068 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_refRemote : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote ref -> remote ref valid" + * + * Test ID: "refRemote::remote ref::remote ref valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote ref::remote ref valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/integer.json" + } + """, + true, + """ schemaTestId: "refRemote::remote ref::remote ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote ref -> remote ref invalid" + * + * Test ID: "refRemote::remote ref::remote ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote ref::remote ref invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/integer.json" + } + """, + false, + """ schemaTestId: "refRemote::remote ref::remote ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "fragment within remote ref -> remote fragment valid" + * + * Test ID: "refRemote::fragment within remote ref::remote fragment valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::fragment within remote ref::remote fragment valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/subSchemas.json#/${'$'}defs/integer" + } + """, + true, + """ schemaTestId: "refRemote::fragment within remote ref::remote fragment valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "fragment within remote ref -> remote fragment invalid" + * + * Test ID: "refRemote::fragment within remote ref::remote fragment invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::fragment within remote ref::remote fragment invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/subSchemas.json#/${'$'}defs/integer" + } + """, + false, + """ schemaTestId: "refRemote::fragment within remote ref::remote fragment invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "anchor within remote ref -> remote anchor valid" + * + * Test ID: "refRemote::anchor within remote ref::remote anchor valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::anchor within remote ref::remote anchor valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/locationIndependentIdentifier.json#foo" + } + """, + true, + """ schemaTestId: "refRemote::anchor within remote ref::remote anchor valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "anchor within remote ref -> remote anchor invalid" + * + * Test ID: "refRemote::anchor within remote ref::remote anchor invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::anchor within remote ref::remote anchor invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/locationIndependentIdentifier.json#foo" + } + """, + false, + """ schemaTestId: "refRemote::anchor within remote ref::remote anchor invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "ref within remote ref -> ref within ref valid" + * + * Test ID: "refRemote::ref within remote ref::ref within ref valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::ref within remote ref::ref within ref valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/subSchemas.json#/${'$'}defs/refToInteger" + } + """, + true, + """ schemaTestId: "refRemote::ref within remote ref::ref within ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "ref within remote ref -> ref within ref invalid" + * + * Test ID: "refRemote::ref within remote ref::ref within ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::ref within remote ref::ref within ref invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/subSchemas.json#/${'$'}defs/refToInteger" + } + """, + false, + """ schemaTestId: "refRemote::ref within remote ref::ref within ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "base URI change -> base URI change ref valid" + * + * Test ID: "refRemote::base URI change::base URI change ref valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change::base URI change ref valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + [ + 1 + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/", + "items": { + "${'$'}id": "baseUriChange/", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + """, + true, + """ schemaTestId: "refRemote::base URI change::base URI change ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "base URI change -> base URI change ref invalid" + * + * Test ID: "refRemote::base URI change::base URI change ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change::base URI change ref invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + [ + "a" + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/", + "items": { + "${'$'}id": "baseUriChange/", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + """, + false, + """ schemaTestId: "refRemote::base URI change::base URI change ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "base URI change - change folder -> number is valid" + * + * Test ID: "refRemote::base URI change - change folder::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change - change folder::number is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "list": [ + 1 + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/scope_change_defs1.json", + "type": "object", + "properties": { + "list": { + "${'$'}ref": "baseUriChangeFolder/" + } + }, + "${'$'}defs": { + "baz": { + "${'$'}id": "baseUriChangeFolder/", + "type": "array", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + } + """, + true, + """ schemaTestId: "refRemote::base URI change - change folder::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "base URI change - change folder -> string is invalid" + * + * Test ID: "refRemote::base URI change - change folder::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change - change folder::string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "list": [ + "a" + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/scope_change_defs1.json", + "type": "object", + "properties": { + "list": { + "${'$'}ref": "baseUriChangeFolder/" + } + }, + "${'$'}defs": { + "baz": { + "${'$'}id": "baseUriChangeFolder/", + "type": "array", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + } + """, + false, + """ schemaTestId: "refRemote::base URI change - change folder::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "base URI change - change folder in subschema -> number is valid" + * + * Test ID: "refRemote::base URI change - change folder in subschema::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change - change folder in subschema::number is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "list": [ + 1 + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/scope_change_defs2.json", + "type": "object", + "properties": { + "list": { + "${'$'}ref": "baseUriChangeFolderInSubschema/#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "baz": { + "${'$'}id": "baseUriChangeFolderInSubschema/", + "${'$'}defs": { + "bar": { + "type": "array", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + } + } + } + """, + true, + """ schemaTestId: "refRemote::base URI change - change folder in subschema::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "base URI change - change folder in subschema -> string is invalid" + * + * Test ID: "refRemote::base URI change - change folder in subschema::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change - change folder in subschema::string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "list": [ + "a" + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/scope_change_defs2.json", + "type": "object", + "properties": { + "list": { + "${'$'}ref": "baseUriChangeFolderInSubschema/#/${'$'}defs/bar" + } + }, + "${'$'}defs": { + "baz": { + "${'$'}id": "baseUriChangeFolderInSubschema/", + "${'$'}defs": { + "bar": { + "type": "array", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + } + } + } + """, + false, + """ schemaTestId: "refRemote::base URI change - change folder in subschema::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "root ref in remote ref -> string is valid" + * + * Test ID: "refRemote::root ref in remote ref::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::root ref in remote ref::string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/object", + "type": "object", + "properties": { + "name": { + "${'$'}ref": "name-defs.json#/${'$'}defs/orNull" + } + } + } + """, + true, + """ schemaTestId: "refRemote::root ref in remote ref::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "root ref in remote ref -> null is valid" + * + * Test ID: "refRemote::root ref in remote ref::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::root ref in remote ref::null is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/object", + "type": "object", + "properties": { + "name": { + "${'$'}ref": "name-defs.json#/${'$'}defs/orNull" + } + } + } + """, + true, + """ schemaTestId: "refRemote::root ref in remote ref::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "root ref in remote ref -> object is invalid" + * + * Test ID: "refRemote::root ref in remote ref::object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::root ref in remote ref::object is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": { + "name": null + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/object", + "type": "object", + "properties": { + "name": { + "${'$'}ref": "name-defs.json#/${'$'}defs/orNull" + } + } + } + """, + false, + """ schemaTestId: "refRemote::root ref in remote ref::object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote ref with ref to defs -> invalid" + * + * Test ID: "refRemote::remote ref with ref to defs::invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote ref with ref to defs::invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/schema-remote-ref-ref-defs1.json", + "${'$'}ref": "ref-and-defs.json" + } + """, + false, + """ schemaTestId: "refRemote::remote ref with ref to defs::invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote ref with ref to defs -> valid" + * + * Test ID: "refRemote::remote ref with ref to defs::valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote ref with ref to defs::valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/schema-remote-ref-ref-defs1.json", + "${'$'}ref": "ref-and-defs.json" + } + """, + true, + """ schemaTestId: "refRemote::remote ref with ref to defs::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "Location-independent identifier in remote ref -> integer is valid" + * + * Test ID: "refRemote::Location-independent identifier in remote ref::integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::Location-independent identifier in remote ref::integer is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/locationIndependentIdentifier.json#/${'$'}defs/refToInteger" + } + """, + true, + """ schemaTestId: "refRemote::Location-independent identifier in remote ref::integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "Location-independent identifier in remote ref -> string is invalid" + * + * Test ID: "refRemote::Location-independent identifier in remote ref::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::Location-independent identifier in remote ref::string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/locationIndependentIdentifier.json#/${'$'}defs/refToInteger" + } + """, + false, + """ schemaTestId: "refRemote::Location-independent identifier in remote ref::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "retrieved nested refs resolve relative to their URI not $id -> number is invalid" + * + * Test ID: "refRemote::retrieved nested refs resolve relative to their URI not $id::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::retrieved nested refs resolve relative to their URI not $id::number is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": { + "foo": 1 + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/some-id", + "properties": { + "name": { + "${'$'}ref": "nested/foo-ref-string.json" + } + } + } + """, + false, + """ schemaTestId: "refRemote::retrieved nested refs resolve relative to their URI not ${'$'}id::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "retrieved nested refs resolve relative to their URI not $id -> string is valid" + * + * Test ID: "refRemote::retrieved nested refs resolve relative to their URI not $id::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::retrieved nested refs resolve relative to their URI not $id::string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": { + "foo": "a" + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "http://localhost:1234/draft2020-12/some-id", + "properties": { + "name": { + "${'$'}ref": "nested/foo-ref-string.json" + } + } + } + """, + true, + """ schemaTestId: "refRemote::retrieved nested refs resolve relative to their URI not ${'$'}id::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote HTTP ref with different $id -> number is invalid" + * + * Test ID: "refRemote::remote HTTP ref with different $id::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote HTTP ref with different $id::number is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/different-id-ref-string.json" + } + """, + false, + """ schemaTestId: "refRemote::remote HTTP ref with different ${'$'}id::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote HTTP ref with different $id -> string is valid" + * + * Test ID: "refRemote::remote HTTP ref with different $id::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote HTTP ref with different $id::string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/different-id-ref-string.json" + } + """, + true, + """ schemaTestId: "refRemote::remote HTTP ref with different ${'$'}id::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote HTTP ref with different URN $id -> number is invalid" + * + * Test ID: "refRemote::remote HTTP ref with different URN $id::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote HTTP ref with different URN $id::number is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/urn-ref-string.json" + } + """, + false, + """ schemaTestId: "refRemote::remote HTTP ref with different URN ${'$'}id::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote HTTP ref with different URN $id -> string is valid" + * + * Test ID: "refRemote::remote HTTP ref with different URN $id::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote HTTP ref with different URN $id::string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/urn-ref-string.json" + } + """, + true, + """ schemaTestId: "refRemote::remote HTTP ref with different URN ${'$'}id::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote HTTP ref with nested absolute ref -> number is invalid" + * + * Test ID: "refRemote::remote HTTP ref with nested absolute ref::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote HTTP ref with nested absolute ref::number is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/nested-absolute-ref-to-string.json" + } + """, + false, + """ schemaTestId: "refRemote::remote HTTP ref with nested absolute ref::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "remote HTTP ref with nested absolute ref -> string is valid" + * + * Test ID: "refRemote::remote HTTP ref with nested absolute ref::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote HTTP ref with nested absolute ref::string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/nested-absolute-ref-to-string.json" + } + """, + true, + """ schemaTestId: "refRemote::remote HTTP ref with nested absolute ref::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "$ref to $ref finds detached $anchor -> number is valid" + * + * Test ID: "refRemote::$ref to $ref finds detached $anchor::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::$ref to $ref finds detached $anchor::number is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/detached-ref.json#/${'$'}defs/foo" + } + """, + true, + """ schemaTestId: "refRemote::${'$'}ref to ${'$'}ref finds detached ${'$'}anchor::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json`: + * "$ref to $ref finds detached $anchor -> non-number is invalid" + * + * Test ID: "refRemote::$ref to $ref finds detached $anchor::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::$ref to $ref finds detached $anchor::non-number is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "http://localhost:1234/draft2020-12/detached-ref.json#/${'$'}defs/foo" + } + """, + false, + """ schemaTestId: "refRemote::${'$'}ref to ${'$'}ref finds detached ${'$'}anchor::non-number is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_required.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_required.kt new file mode 100644 index 00000000..da5123b3 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_required.kt @@ -0,0 +1,508 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_required : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required validation -> present required property is valid" + * + * Test ID: "required::required validation::present required property is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + true, + """ schemaTestId: "required::required validation::present required property is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required validation -> non-present required property is invalid" + * + * Test ID: "required::required validation::non-present required property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + false, + """ schemaTestId: "required::required validation::non-present required property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required validation -> ignores arrays" + * + * Test ID: "required::required validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + true, + """ schemaTestId: "required::required validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required validation -> ignores strings" + * + * Test ID: "required::required validation::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + true, + """ schemaTestId: "required::required validation::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required validation -> ignores other non-objects" + * + * Test ID: "required::required validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + true, + """ schemaTestId: "required::required validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required default validation -> not required by default" + * + * Test ID: "required::required default validation::not required by default" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + } + } + } + """, + true, + """ schemaTestId: "required::required default validation::not required by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required with empty array -> property not required" + * + * Test ID: "required::required with empty array::property not required" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + } + }, + "required": [ + ] + } + """, + true, + """ schemaTestId: "required::required with empty array::property not required" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required with escaped characters -> object with all properties present is valid" + * + * Test ID: "required::required with escaped characters::object with all properties present is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": 1, + "foo\"bar": 1, + "foo\\bar": 1, + "foo\rbar": 1, + "foo\tbar": 1, + "foo\fbar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "foo\nbar", + "foo\"bar", + "foo\\bar", + "foo\rbar", + "foo\tbar", + "foo\fbar" + ] + } + """, + true, + """ schemaTestId: "required::required with escaped characters::object with all properties present is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required with escaped characters -> object with some properties missing is invalid" + * + * Test ID: "required::required with escaped characters::object with some properties missing is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": "1", + "foo\"bar": "1" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "foo\nbar", + "foo\"bar", + "foo\\bar", + "foo\rbar", + "foo\tbar", + "foo\fbar" + ] + } + """, + false, + """ schemaTestId: "required::required with escaped characters::object with some properties missing is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required properties whose names are Javascript object property names -> ignores arrays" + * + * Test ID: "required::required properties whose names are Javascript object property names::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_10() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + true, + """ schemaTestId: "required::required properties whose names are Javascript object property names::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required properties whose names are Javascript object property names -> ignores other non-objects" + * + * Test ID: "required::required properties whose names are Javascript object property names::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_11() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + true, + """ schemaTestId: "required::required properties whose names are Javascript object property names::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required properties whose names are Javascript object property names -> none of the properties mentioned" + * + * Test ID: "required::required properties whose names are Javascript object property names::none of the properties mentioned" + */ + @Test + fun jsonSchemaSuiteTest_12() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + false, + """ schemaTestId: "required::required properties whose names are Javascript object property names::none of the properties mentioned" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required properties whose names are Javascript object property names -> __proto__ present" + * + * Test ID: "required::required properties whose names are Javascript object property names::__proto__ present" + */ + @Test + fun jsonSchemaSuiteTest_13() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "__proto__": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + false, + """ schemaTestId: "required::required properties whose names are Javascript object property names::__proto__ present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required properties whose names are Javascript object property names -> toString present" + * + * Test ID: "required::required properties whose names are Javascript object property names::toString present" + */ + @Test + fun jsonSchemaSuiteTest_14() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "toString": { + "length": 37 + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + false, + """ schemaTestId: "required::required properties whose names are Javascript object property names::toString present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required properties whose names are Javascript object property names -> constructor present" + * + * Test ID: "required::required properties whose names are Javascript object property names::constructor present" + */ + @Test + fun jsonSchemaSuiteTest_15() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "constructor": { + "length": 37 + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + false, + """ schemaTestId: "required::required properties whose names are Javascript object property names::constructor present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/required.json`: + * "required properties whose names are Javascript object property names -> all present" + * + * Test ID: "required::required properties whose names are Javascript object property names::all present" + */ + @Test + fun jsonSchemaSuiteTest_16() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "__proto__": 12, + "toString": { + "length": "foo" + }, + "constructor": 37 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + true, + """ schemaTestId: "required::required properties whose names are Javascript object property names::all present" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_type.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_type.kt new file mode 100644 index 00000000..fabb339d --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_type.kt @@ -0,0 +1,1943 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_type : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> an integer is an integer" + * + * Test ID: "type::integer type matches integers::an integer is an integer" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + true, + """ schemaTestId: "type::integer type matches integers::an integer is an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> a float with zero fractional part is an integer" + * + * Test ID: "type::integer type matches integers::a float with zero fractional part is an integer" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + true, + """ schemaTestId: "type::integer type matches integers::a float with zero fractional part is an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> a float is not an integer" + * + * Test ID: "type::integer type matches integers::a float is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::a float is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> a string is not an integer" + * + * Test ID: "type::integer type matches integers::a string is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::a string is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> a string is still not an integer, even if it looks like one" + * + * Test ID: "type::integer type matches integers::a string is still not an integer, even if it looks like one" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "1" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::a string is still not an integer, even if it looks like one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> an object is not an integer" + * + * Test ID: "type::integer type matches integers::an object is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::an object is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> an array is not an integer" + * + * Test ID: "type::integer type matches integers::an array is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::an array is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> a boolean is not an integer" + * + * Test ID: "type::integer type matches integers::a boolean is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::a boolean is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "integer type matches integers -> null is not an integer" + * + * Test ID: "type::integer type matches integers::null is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::null is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> an integer is a number" + * + * Test ID: "type::number type matches numbers::an integer is a number" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + true, + """ schemaTestId: "type::number type matches numbers::an integer is a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> a float with zero fractional part is a number (and an integer)" + * + * Test ID: "type::number type matches numbers::a float with zero fractional part is a number (and an integer)" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + true, + """ schemaTestId: "type::number type matches numbers::a float with zero fractional part is a number (and an integer)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> a float is a number" + * + * Test ID: "type::number type matches numbers::a float is a number" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + true, + """ schemaTestId: "type::number type matches numbers::a float is a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> a string is not a number" + * + * Test ID: "type::number type matches numbers::a string is not a number" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::a string is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> a string is still not a number, even if it looks like one" + * + * Test ID: "type::number type matches numbers::a string is still not a number, even if it looks like one" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + "1" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::a string is still not a number, even if it looks like one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> an object is not a number" + * + * Test ID: "type::number type matches numbers::an object is not a number" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::an object is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> an array is not a number" + * + * Test ID: "type::number type matches numbers::an array is not a number" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::an array is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> a boolean is not a number" + * + * Test ID: "type::number type matches numbers::a boolean is not a number" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::a boolean is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "number type matches numbers -> null is not a number" + * + * Test ID: "type::number type matches numbers::null is not a number" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::null is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> 1 is not a string" + * + * Test ID: "type::string type matches strings::1 is not a string" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::1 is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> a float is not a string" + * + * Test ID: "type::string type matches strings::a float is not a string" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::a float is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> a string is a string" + * + * Test ID: "type::string type matches strings::a string is a string" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + true, + """ schemaTestId: "type::string type matches strings::a string is a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> a string is still a string, even if it looks like a number" + * + * Test ID: "type::string type matches strings::a string is still a string, even if it looks like a number" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + "1" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + true, + """ schemaTestId: "type::string type matches strings::a string is still a string, even if it looks like a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> an empty string is still a string" + * + * Test ID: "type::string type matches strings::an empty string is still a string" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + true, + """ schemaTestId: "type::string type matches strings::an empty string is still a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> an object is not a string" + * + * Test ID: "type::string type matches strings::an object is not a string" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::an object is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> an array is not a string" + * + * Test ID: "type::string type matches strings::an array is not a string" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::an array is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> a boolean is not a string" + * + * Test ID: "type::string type matches strings::a boolean is not a string" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::a boolean is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "string type matches strings -> null is not a string" + * + * Test ID: "type::string type matches strings::null is not a string" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::null is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "object type matches objects -> an integer is not an object" + * + * Test ID: "type::object type matches objects::an integer is not an object" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::an integer is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "object type matches objects -> a float is not an object" + * + * Test ID: "type::object type matches objects::a float is not an object" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::a float is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "object type matches objects -> a string is not an object" + * + * Test ID: "type::object type matches objects::a string is not an object" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::a string is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "object type matches objects -> an object is an object" + * + * Test ID: "type::object type matches objects::an object is an object" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object" + } + """, + true, + """ schemaTestId: "type::object type matches objects::an object is an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "object type matches objects -> an array is not an object" + * + * Test ID: "type::object type matches objects::an array is not an object" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::an array is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "object type matches objects -> a boolean is not an object" + * + * Test ID: "type::object type matches objects::a boolean is not an object" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::a boolean is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "object type matches objects -> null is not an object" + * + * Test ID: "type::object type matches objects::null is not an object" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::null is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "array type matches arrays -> an integer is not an array" + * + * Test ID: "type::array type matches arrays::an integer is not an array" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::an integer is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "array type matches arrays -> a float is not an array" + * + * Test ID: "type::array type matches arrays::a float is not an array" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::a float is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "array type matches arrays -> a string is not an array" + * + * Test ID: "type::array type matches arrays::a string is not an array" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::a string is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "array type matches arrays -> an object is not an array" + * + * Test ID: "type::array type matches arrays::an object is not an array" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::an object is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "array type matches arrays -> an array is an array" + * + * Test ID: "type::array type matches arrays::an array is an array" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array" + } + """, + true, + """ schemaTestId: "type::array type matches arrays::an array is an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "array type matches arrays -> a boolean is not an array" + * + * Test ID: "type::array type matches arrays::a boolean is not an array" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::a boolean is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "array type matches arrays -> null is not an array" + * + * Test ID: "type::array type matches arrays::null is not an array" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::null is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> an integer is not a boolean" + * + * Test ID: "type::boolean type matches booleans::an integer is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::an integer is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> zero is not a boolean" + * + * Test ID: "type::boolean type matches booleans::zero is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::zero is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> a float is not a boolean" + * + * Test ID: "type::boolean type matches booleans::a float is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::a float is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> a string is not a boolean" + * + * Test ID: "type::boolean type matches booleans::a string is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::a string is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> an empty string is not a boolean" + * + * Test ID: "type::boolean type matches booleans::an empty string is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::an empty string is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> an object is not a boolean" + * + * Test ID: "type::boolean type matches booleans::an object is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::an object is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> an array is not a boolean" + * + * Test ID: "type::boolean type matches booleans::an array is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::an array is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> true is a boolean" + * + * Test ID: "type::boolean type matches booleans::true is a boolean" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + true, + """ schemaTestId: "type::boolean type matches booleans::true is a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> false is a boolean" + * + * Test ID: "type::boolean type matches booleans::false is a boolean" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + true, + """ schemaTestId: "type::boolean type matches booleans::false is a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "boolean type matches booleans -> null is not a boolean" + * + * Test ID: "type::boolean type matches booleans::null is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::null is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> an integer is not null" + * + * Test ID: "type::null type matches only the null object::an integer is not null" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::an integer is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> a float is not null" + * + * Test ID: "type::null type matches only the null object::a float is not null" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::a float is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> zero is not null" + * + * Test ID: "type::null type matches only the null object::zero is not null" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::zero is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> a string is not null" + * + * Test ID: "type::null type matches only the null object::a string is not null" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::a string is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> an empty string is not null" + * + * Test ID: "type::null type matches only the null object::an empty string is not null" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::an empty string is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> an object is not null" + * + * Test ID: "type::null type matches only the null object::an object is not null" + */ + @Test + fun jsonSchemaSuiteTest_57() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::an object is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> an array is not null" + * + * Test ID: "type::null type matches only the null object::an array is not null" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::an array is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> true is not null" + * + * Test ID: "type::null type matches only the null object::true is not null" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::true is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> false is not null" + * + * Test ID: "type::null type matches only the null object::false is not null" + */ + @Test + fun jsonSchemaSuiteTest_60() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::false is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "null type matches only the null object -> null is null" + * + * Test ID: "type::null type matches only the null object::null is null" + */ + @Test + fun jsonSchemaSuiteTest_61() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "null" + } + """, + true, + """ schemaTestId: "type::null type matches only the null object::null is null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "multiple types can be specified in an array -> an integer is valid" + * + * Test ID: "type::multiple types can be specified in an array::an integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "integer", + "string" + ] + } + """, + true, + """ schemaTestId: "type::multiple types can be specified in an array::an integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "multiple types can be specified in an array -> a string is valid" + * + * Test ID: "type::multiple types can be specified in an array::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_63() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "integer", + "string" + ] + } + """, + true, + """ schemaTestId: "type::multiple types can be specified in an array::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "multiple types can be specified in an array -> a float is invalid" + * + * Test ID: "type::multiple types can be specified in an array::a float is invalid" + */ + @Test + fun jsonSchemaSuiteTest_64() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::a float is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "multiple types can be specified in an array -> an object is invalid" + * + * Test ID: "type::multiple types can be specified in an array::an object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_65() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::an object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "multiple types can be specified in an array -> an array is invalid" + * + * Test ID: "type::multiple types can be specified in an array::an array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_66() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::an array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "multiple types can be specified in an array -> a boolean is invalid" + * + * Test ID: "type::multiple types can be specified in an array::a boolean is invalid" + */ + @Test + fun jsonSchemaSuiteTest_67() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::a boolean is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "multiple types can be specified in an array -> null is invalid" + * + * Test ID: "type::multiple types can be specified in an array::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_68() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type as array with one item -> string is valid" + * + * Test ID: "type::type as array with one item::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_69() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "string" + ] + } + """, + true, + """ schemaTestId: "type::type as array with one item::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type as array with one item -> number is invalid" + * + * Test ID: "type::type as array with one item::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_70() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "string" + ] + } + """, + false, + """ schemaTestId: "type::type as array with one item::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array or object -> array is valid" + * + * Test ID: "type::type: array or object::array is valid" + */ + @Test + fun jsonSchemaSuiteTest_71() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object" + ] + } + """, + true, + """ schemaTestId: "type::type: array or object::array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array or object -> object is valid" + * + * Test ID: "type::type: array or object::object is valid" + */ + @Test + fun jsonSchemaSuiteTest_72() { + + assertKsonEnforcesSchema( + """ + { + "foo": 123 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object" + ] + } + """, + true, + """ schemaTestId: "type::type: array or object::object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array or object -> number is invalid" + * + * Test ID: "type::type: array or object::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_73() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object" + ] + } + """, + false, + """ schemaTestId: "type::type: array or object::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array or object -> string is invalid" + * + * Test ID: "type::type: array or object::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_74() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object" + ] + } + """, + false, + """ schemaTestId: "type::type: array or object::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array or object -> null is invalid" + * + * Test ID: "type::type: array or object::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_75() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object" + ] + } + """, + false, + """ schemaTestId: "type::type: array or object::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array, object or null -> array is valid" + * + * Test ID: "type::type: array, object or null::array is valid" + */ + @Test + fun jsonSchemaSuiteTest_76() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object", + "null" + ] + } + """, + true, + """ schemaTestId: "type::type: array, object or null::array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array, object or null -> object is valid" + * + * Test ID: "type::type: array, object or null::object is valid" + */ + @Test + fun jsonSchemaSuiteTest_77() { + + assertKsonEnforcesSchema( + """ + { + "foo": 123 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object", + "null" + ] + } + """, + true, + """ schemaTestId: "type::type: array, object or null::object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array, object or null -> null is valid" + * + * Test ID: "type::type: array, object or null::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_78() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object", + "null" + ] + } + """, + true, + """ schemaTestId: "type::type: array, object or null::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array, object or null -> number is invalid" + * + * Test ID: "type::type: array, object or null::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_79() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object", + "null" + ] + } + """, + false, + """ schemaTestId: "type::type: array, object or null::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/type.json`: + * "type: array, object or null -> string is invalid" + * + * Test ID: "type::type: array, object or null::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_80() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": [ + "array", + "object", + "null" + ] + } + """, + false, + """ schemaTestId: "type::type: array, object or null::string is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_unevaluatedItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_unevaluatedItems.kt new file mode 100644 index 00000000..b9a2706e --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_unevaluatedItems.kt @@ -0,0 +1,2704 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_unevaluatedItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems true -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems true::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": true + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems true::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems true -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems true::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": true + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems true::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems false -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems false::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems false::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems false -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems false::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_4() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems false::with unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems false::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems as schema -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems as schema::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": { + "type": "string" + } + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems as schema::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems as schema -> with valid unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems as schema::with valid unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": { + "type": "string" + } + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems as schema::with valid unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems as schema -> with invalid unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems as schema::with invalid unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_7() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems as schema::with invalid unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": { + "type": "string" + } + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems as schema::with invalid unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with uniform items -> unevaluatedItems doesn't apply" + * + * Test ID: "unevaluatedItems::unevaluatedItems with uniform items::unevaluatedItems doesn't apply" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "type": "string" + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with uniform items::unevaluatedItems doesn't apply" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with tuple -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with tuple::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "string" + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with tuple::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with tuple -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with tuple::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_10() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with tuple::with unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "string" + } + ], + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with tuple::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with items and prefixItems -> unevaluatedItems doesn't apply" + * + * Test ID: "unevaluatedItems::unevaluatedItems with items and prefixItems::unevaluatedItems doesn't apply" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "string" + } + ], + "items": true, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with items and prefixItems::unevaluatedItems doesn't apply" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with items -> valid under items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with items::valid under items" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + [ + 5, + 6, + 7, + 8 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "type": "number" + }, + "unevaluatedItems": { + "type": "string" + } + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with items::valid under items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with items -> invalid under items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with items::invalid under items" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "baz" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "items": { + "type": "number" + }, + "unevaluatedItems": { + "type": "string" + } + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with items::invalid under items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested tuple -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested tuple::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "string" + } + ], + "allOf": [ + { + "prefixItems": [ + true, + { + "type": "number" + } + ] + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested tuple::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested tuple -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested tuple::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_15() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with nested tuple::with unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "string" + } + ], + "allOf": [ + { + "prefixItems": [ + true, + { + "type": "number" + } + ] + } + ], + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested tuple::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested items -> with only (valid) additional items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested items::with only (valid) additional items" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": { + "type": "boolean" + }, + "anyOf": [ + { + "items": { + "type": "string" + } + }, + true + ] + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested items::with only (valid) additional items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested items -> with no additional items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested items::with no additional items" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + "yes", + "no" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": { + "type": "boolean" + }, + "anyOf": [ + { + "items": { + "type": "string" + } + }, + true + ] + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested items::with no additional items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested items -> with invalid additional item" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested items::with invalid additional item" + */ + @Test + fun jsonSchemaSuiteTest_18() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with nested items::with invalid additional item" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "yes", + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": { + "type": "boolean" + }, + "anyOf": [ + { + "items": { + "type": "string" + } + }, + true + ] + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested items::with invalid additional item" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested prefixItems and items -> with no additional items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested prefixItems and items::with no additional items" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "prefixItems": [ + { + "type": "string" + } + ], + "items": true + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested prefixItems and items::with no additional items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested prefixItems and items -> with additional items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested prefixItems and items::with additional items" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "prefixItems": [ + { + "type": "string" + } + ], + "items": true + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested prefixItems and items::with additional items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested unevaluatedItems -> with no additional items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested unevaluatedItems::with no additional items" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "prefixItems": [ + { + "type": "string" + } + ] + }, + { + "unevaluatedItems": true + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested unevaluatedItems::with no additional items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with nested unevaluatedItems -> with additional items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with nested unevaluatedItems::with additional items" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "prefixItems": [ + { + "type": "string" + } + ] + }, + { + "unevaluatedItems": true + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with nested unevaluatedItems::with additional items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with anyOf -> when one schema matches and has no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with anyOf::when one schema matches and has no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "anyOf": [ + { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + { + "prefixItems": [ + true, + true, + { + "const": "baz" + } + ] + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with anyOf::when one schema matches and has no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with anyOf -> when one schema matches and has unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with anyOf::when one schema matches and has unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_24() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with anyOf::when one schema matches and has unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "anyOf": [ + { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + { + "prefixItems": [ + true, + true, + { + "const": "baz" + } + ] + } + ], + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with anyOf::when one schema matches and has unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with anyOf -> when two schemas match and has no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with anyOf::when two schemas match and has no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "baz" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "anyOf": [ + { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + { + "prefixItems": [ + true, + true, + { + "const": "baz" + } + ] + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with anyOf::when two schemas match and has no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with anyOf -> when two schemas match and has unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with anyOf::when two schemas match and has unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_26() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with anyOf::when two schemas match and has unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "baz", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "anyOf": [ + { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + { + "prefixItems": [ + true, + true, + { + "const": "baz" + } + ] + } + ], + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with anyOf::when two schemas match and has unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with oneOf -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with oneOf::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_27() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with oneOf::with no unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "oneOf": [ + { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + { + "prefixItems": [ + true, + { + "const": "baz" + } + ] + } + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with oneOf::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with oneOf -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with oneOf::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "oneOf": [ + { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + { + "prefixItems": [ + true, + { + "const": "baz" + } + ] + } + ], + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with oneOf::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with not -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with not::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_29() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with not::with unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "not": { + "not": { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + } + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with not::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with if/then/else -> when if matches and it has no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with if/then/else::when if matches and it has no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "then" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "if": { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + "then": { + "prefixItems": [ + true, + true, + { + "const": "then" + } + ] + }, + "else": { + "prefixItems": [ + true, + true, + true, + { + "const": "else" + } + ] + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with if/then/else::when if matches and it has no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with if/then/else -> when if matches and it has unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with if/then/else::when if matches and it has unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_31() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with if/then/else::when if matches and it has unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "then", + "else" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "if": { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + "then": { + "prefixItems": [ + true, + true, + { + "const": "then" + } + ] + }, + "else": { + "prefixItems": [ + true, + true, + true, + { + "const": "else" + } + ] + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with if/then/else::when if matches and it has unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with if/then/else -> when if doesn't match and it has no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with if/then/else::when if doesn't match and it has no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42, + 42, + "else" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "if": { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + "then": { + "prefixItems": [ + true, + true, + { + "const": "then" + } + ] + }, + "else": { + "prefixItems": [ + true, + true, + true, + { + "const": "else" + } + ] + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with if/then/else::when if doesn't match and it has no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with if/then/else -> when if doesn't match and it has unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with if/then/else::when if doesn't match and it has unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_33() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with if/then/else::when if doesn't match and it has unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + 42, + 42, + "else", + 42 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "const": "foo" + } + ], + "if": { + "prefixItems": [ + true, + { + "const": "bar" + } + ] + }, + "then": { + "prefixItems": [ + true, + true, + { + "const": "then" + } + ] + }, + "else": { + "prefixItems": [ + true, + true, + true, + { + "const": "else" + } + ] + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with if/then/else::when if doesn't match and it has unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with boolean schemas -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with boolean schemas::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + true + ], + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with boolean schemas::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with boolean schemas -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with boolean schemas::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_35() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with boolean schemas::with unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + true + ], + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with boolean schemas::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with $ref -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with $ref::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "#/${'$'}defs/bar", + "prefixItems": [ + { + "type": "string" + } + ], + "unevaluatedItems": false, + "${'$'}defs": { + "bar": { + "prefixItems": [ + true, + { + "type": "string" + } + ] + } + } + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with ${'$'}ref::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with $ref -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with $ref::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_37() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with $ref::with unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "baz" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}ref": "#/${'$'}defs/bar", + "prefixItems": [ + { + "type": "string" + } + ], + "unevaluatedItems": false, + "${'$'}defs": { + "bar": { + "prefixItems": [ + true, + { + "type": "string" + } + ] + } + } + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with ${'$'}ref::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems before $ref -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems before $ref::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false, + "prefixItems": [ + { + "type": "string" + } + ], + "${'$'}ref": "#/${'$'}defs/bar", + "${'$'}defs": { + "bar": { + "prefixItems": [ + true, + { + "type": "string" + } + ] + } + } + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems before ${'$'}ref::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems before $ref -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems before $ref::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_39() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems before $ref::with unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "baz" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false, + "prefixItems": [ + { + "type": "string" + } + ], + "${'$'}ref": "#/${'$'}defs/bar", + "${'$'}defs": { + "bar": { + "prefixItems": [ + true, + { + "type": "string" + } + ] + } + } + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems before ${'$'}ref::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with $dynamicRef -> with no unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with $dynamicRef::with no unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://example.com/unevaluated-items-with-dynamic-ref/derived", + "${'$'}ref": "./baseSchema", + "${'$'}defs": { + "derived": { + "${'$'}dynamicAnchor": "addons", + "prefixItems": [ + true, + { + "type": "string" + } + ] + }, + "baseSchema": { + "${'$'}id": "./baseSchema", + "${'$'}comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", + "unevaluatedItems": false, + "type": "array", + "prefixItems": [ + { + "type": "string" + } + ], + "${'$'}dynamicRef": "#addons", + "${'$'}defs": { + "defaultAddons": { + "${'$'}comment": "Needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "addons" + } + } + } + } + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with ${'$'}dynamicRef::with no unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with $dynamicRef -> with unevaluated items" + * + * Test ID: "unevaluatedItems::unevaluatedItems with $dynamicRef::with unevaluated items" + */ + @Test + fun jsonSchemaSuiteTest_41() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems with $dynamicRef::with unevaluated items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "baz" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://example.com/unevaluated-items-with-dynamic-ref/derived", + "${'$'}ref": "./baseSchema", + "${'$'}defs": { + "derived": { + "${'$'}dynamicAnchor": "addons", + "prefixItems": [ + true, + { + "type": "string" + } + ] + }, + "baseSchema": { + "${'$'}id": "./baseSchema", + "${'$'}comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", + "unevaluatedItems": false, + "type": "array", + "prefixItems": [ + { + "type": "string" + } + ], + "${'$'}dynamicRef": "#addons", + "${'$'}defs": { + "defaultAddons": { + "${'$'}comment": "Needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "addons" + } + } + } + } + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with ${'$'}dynamicRef::with unevaluated items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems can't see inside cousins -> always fails" + * + * Test ID: "unevaluatedItems::unevaluatedItems can't see inside cousins::always fails" + */ + @Test + fun jsonSchemaSuiteTest_42() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems can't see inside cousins::always fails" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "prefixItems": [ + true + ] + }, + { + "unevaluatedItems": false + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems can't see inside cousins::always fails" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "item is evaluated in an uncle schema to unevaluatedItems -> no extra items" + * + * Test ID: "unevaluatedItems::item is evaluated in an uncle schema to unevaluatedItems::no extra items" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + "test" + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "prefixItems": [ + { + "type": "string" + } + ], + "unevaluatedItems": false + } + }, + "anyOf": [ + { + "properties": { + "foo": { + "prefixItems": [ + true, + { + "type": "string" + } + ] + } + } + } + ] + } + """, + true, + """ schemaTestId: "unevaluatedItems::item is evaluated in an uncle schema to unevaluatedItems::no extra items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "item is evaluated in an uncle schema to unevaluatedItems -> uncle keyword evaluation is not significant" + * + * Test ID: "unevaluatedItems::item is evaluated in an uncle schema to unevaluatedItems::uncle keyword evaluation is not significant" + */ + @Test + fun jsonSchemaSuiteTest_44() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::item is evaluated in an uncle schema to unevaluatedItems::uncle keyword evaluation is not significant" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": [ + "test", + "test" + ] + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": { + "prefixItems": [ + { + "type": "string" + } + ], + "unevaluatedItems": false + } + }, + "anyOf": [ + { + "properties": { + "foo": { + "prefixItems": [ + true, + { + "type": "string" + } + ] + } + } + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedItems::item is evaluated in an uncle schema to unevaluatedItems::uncle keyword evaluation is not significant" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems depends on adjacent contains -> second item is evaluated by contains" + * + * Test ID: "unevaluatedItems::unevaluatedItems depends on adjacent contains::second item is evaluated by contains" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + true + ], + "contains": { + "type": "string" + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems depends on adjacent contains::second item is evaluated by contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems depends on adjacent contains -> contains fails, second item is not evaluated" + * + * Test ID: "unevaluatedItems::unevaluatedItems depends on adjacent contains::contains fails, second item is not evaluated" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + true + ], + "contains": { + "type": "string" + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems depends on adjacent contains::contains fails, second item is not evaluated" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems depends on adjacent contains -> contains passes, second item is not evaluated" + * + * Test ID: "unevaluatedItems::unevaluatedItems depends on adjacent contains::contains passes, second item is not evaluated" + */ + @Test + fun jsonSchemaSuiteTest_47() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems depends on adjacent contains::contains passes, second item is not evaluated" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + true + ], + "contains": { + "type": "string" + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems depends on adjacent contains::contains passes, second item is not evaluated" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems depends on multiple nested contains -> 5 not evaluated, passes unevaluatedItems" + * + * Test ID: "unevaluatedItems::unevaluatedItems depends on multiple nested contains::5 not evaluated, passes unevaluatedItems" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + [ + 2, + 3, + 4, + 5, + 6 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "contains": { + "multipleOf": 2 + } + }, + { + "contains": { + "multipleOf": 3 + } + } + ], + "unevaluatedItems": { + "multipleOf": 5 + } + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems depends on multiple nested contains::5 not evaluated, passes unevaluatedItems" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems depends on multiple nested contains -> 7 not evaluated, fails unevaluatedItems" + * + * Test ID: "unevaluatedItems::unevaluatedItems depends on multiple nested contains::7 not evaluated, fails unevaluatedItems" + */ + @Test + fun jsonSchemaSuiteTest_49() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems depends on multiple nested contains::7 not evaluated, fails unevaluatedItems" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 2, + 3, + 4, + 7, + 8 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "contains": { + "multipleOf": 2 + } + }, + { + "contains": { + "multipleOf": 3 + } + } + ], + "unevaluatedItems": { + "multipleOf": 5 + } + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems depends on multiple nested contains::7 not evaluated, fails unevaluatedItems" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems and contains interact to control item dependency relationship -> empty array is valid" + * + * Test ID: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "contains": { + "const": "a" + } + }, + "then": { + "if": { + "contains": { + "const": "b" + } + }, + "then": { + "if": { + "contains": { + "const": "c" + } + } + } + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems and contains interact to control item dependency relationship -> only a's are valid" + * + * Test ID: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only a's are valid" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + [ + "a", + "a" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "contains": { + "const": "a" + } + }, + "then": { + "if": { + "contains": { + "const": "b" + } + }, + "then": { + "if": { + "contains": { + "const": "c" + } + } + } + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only a's are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems and contains interact to control item dependency relationship -> a's and b's are valid" + * + * Test ID: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::a's and b's are valid" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + [ + "a", + "b", + "a", + "b", + "a" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "contains": { + "const": "a" + } + }, + "then": { + "if": { + "contains": { + "const": "b" + } + }, + "then": { + "if": { + "contains": { + "const": "c" + } + } + } + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::a's and b's are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems and contains interact to control item dependency relationship -> a's, b's and c's are valid" + * + * Test ID: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::a's, b's and c's are valid" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + [ + "c", + "a", + "c", + "c", + "b", + "a" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "contains": { + "const": "a" + } + }, + "then": { + "if": { + "contains": { + "const": "b" + } + }, + "then": { + "if": { + "contains": { + "const": "c" + } + } + } + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::a's, b's and c's are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems and contains interact to control item dependency relationship -> only b's are invalid" + * + * Test ID: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only b's are invalid" + */ + @Test + fun jsonSchemaSuiteTest_54() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only b's are invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "b", + "b" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "contains": { + "const": "a" + } + }, + "then": { + "if": { + "contains": { + "const": "b" + } + }, + "then": { + "if": { + "contains": { + "const": "c" + } + } + } + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only b's are invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems and contains interact to control item dependency relationship -> only c's are invalid" + * + * Test ID: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only c's are invalid" + */ + @Test + fun jsonSchemaSuiteTest_55() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only c's are invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "c", + "c" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "contains": { + "const": "a" + } + }, + "then": { + "if": { + "contains": { + "const": "b" + } + }, + "then": { + "if": { + "contains": { + "const": "c" + } + } + } + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only c's are invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems and contains interact to control item dependency relationship -> only b's and c's are invalid" + * + * Test ID: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only b's and c's are invalid" + */ + @Test + fun jsonSchemaSuiteTest_56() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only b's and c's are invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "c", + "b", + "c", + "b", + "c" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "contains": { + "const": "a" + } + }, + "then": { + "if": { + "contains": { + "const": "b" + } + }, + "then": { + "if": { + "contains": { + "const": "c" + } + } + } + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only b's and c's are invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems and contains interact to control item dependency relationship -> only a's and c's are invalid" + * + * Test ID: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only a's and c's are invalid" + */ + @Test + fun jsonSchemaSuiteTest_57() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only a's and c's are invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "c", + "a", + "c", + "a", + "c" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "contains": { + "const": "a" + } + }, + "then": { + "if": { + "contains": { + "const": "b" + } + }, + "then": { + "if": { + "contains": { + "const": "c" + } + } + } + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems and contains interact to control item dependency relationship::only a's and c's are invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "non-array instances are valid -> ignores booleans" + * + * Test ID: "unevaluatedItems::non-array instances are valid::ignores booleans" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::non-array instances are valid::ignores booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "non-array instances are valid -> ignores integers" + * + * Test ID: "unevaluatedItems::non-array instances are valid::ignores integers" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::non-array instances are valid::ignores integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "non-array instances are valid -> ignores floats" + * + * Test ID: "unevaluatedItems::non-array instances are valid::ignores floats" + */ + @Test + fun jsonSchemaSuiteTest_60() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::non-array instances are valid::ignores floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "non-array instances are valid -> ignores objects" + * + * Test ID: "unevaluatedItems::non-array instances are valid::ignores objects" + */ + @Test + fun jsonSchemaSuiteTest_61() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::non-array instances are valid::ignores objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "non-array instances are valid -> ignores strings" + * + * Test ID: "unevaluatedItems::non-array instances are valid::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::non-array instances are valid::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "non-array instances are valid -> ignores null" + * + * Test ID: "unevaluatedItems::non-array instances are valid::ignores null" + */ + @Test + fun jsonSchemaSuiteTest_63() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::non-array instances are valid::ignores null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems with null instance elements -> allows null elements" + * + * Test ID: "unevaluatedItems::unevaluatedItems with null instance elements::allows null elements" + */ + @Test + fun jsonSchemaSuiteTest_64() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedItems": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems with null instance elements::allows null elements" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems can see annotations from if without then and else -> valid in case if is evaluated" + * + * Test ID: "unevaluatedItems::unevaluatedItems can see annotations from if without then and else::valid in case if is evaluated" + */ + @Test + fun jsonSchemaSuiteTest_65() { + + assertKsonEnforcesSchema( + """ + [ + "a" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "prefixItems": [ + { + "const": "a" + } + ] + }, + "unevaluatedItems": false + } + """, + true, + """ schemaTestId: "unevaluatedItems::unevaluatedItems can see annotations from if without then and else::valid in case if is evaluated" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json`: + * "unevaluatedItems can see annotations from if without then and else -> invalid in case if is evaluated" + * + * Test ID: "unevaluatedItems::unevaluatedItems can see annotations from if without then and else::invalid in case if is evaluated" + */ + @Test + fun jsonSchemaSuiteTest_66() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedItems::unevaluatedItems can see annotations from if without then and else::invalid in case if is evaluated" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + "b" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "prefixItems": [ + { + "const": "a" + } + ] + }, + "unevaluatedItems": false + } + """, + false, + """ schemaTestId: "unevaluatedItems::unevaluatedItems can see annotations from if without then and else::invalid in case if is evaluated" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_unevaluatedProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_unevaluatedProperties.kt new file mode 100644 index 00000000..2106d3e0 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_unevaluatedProperties.kt @@ -0,0 +1,6348 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_unevaluatedProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties true -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties true::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": true + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties true::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties true -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties true::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": true + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties true::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties schema -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties schema::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": { + "type": "string", + "minLength": 3 + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties schema::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties schema -> with valid unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties schema::with valid unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": { + "type": "string", + "minLength": 3 + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties schema::with valid unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties schema -> with invalid unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties schema::with invalid unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_5() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties schema::with invalid unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "fo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": { + "type": "string", + "minLength": 3 + } + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties schema::with invalid unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties false -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties false::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties false::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties false -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties false::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_7() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties false::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties false::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with adjacent properties -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with adjacent properties::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with adjacent properties::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with adjacent properties -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with adjacent properties::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_9() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with adjacent properties::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with adjacent properties::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with adjacent patternProperties -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with adjacent patternProperties::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "patternProperties": { + "^foo": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with adjacent patternProperties::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with adjacent patternProperties -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with adjacent patternProperties::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_11() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with adjacent patternProperties::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "patternProperties": { + "^foo": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with adjacent patternProperties::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with adjacent additionalProperties -> with no additional properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with adjacent additionalProperties::with no additional properties" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "additionalProperties": true, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with adjacent additionalProperties::with no additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with adjacent additionalProperties -> with additional properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with adjacent additionalProperties::with additional properties" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "additionalProperties": true, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with adjacent additionalProperties::with additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with nested properties -> with no additional properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with nested properties::with no additional properties" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "properties": { + "bar": { + "type": "string" + } + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with nested properties::with no additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with nested properties -> with additional properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with nested properties::with additional properties" + */ + @Test + fun jsonSchemaSuiteTest_15() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with nested properties::with additional properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "properties": { + "bar": { + "type": "string" + } + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with nested properties::with additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with nested patternProperties -> with no additional properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with nested patternProperties::with no additional properties" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "patternProperties": { + "^bar": { + "type": "string" + } + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with nested patternProperties::with no additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with nested patternProperties -> with additional properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with nested patternProperties::with additional properties" + */ + @Test + fun jsonSchemaSuiteTest_17() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with nested patternProperties::with additional properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "patternProperties": { + "^bar": { + "type": "string" + } + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with nested patternProperties::with additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with nested additionalProperties -> with no additional properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with nested additionalProperties::with no additional properties" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "additionalProperties": true + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with nested additionalProperties::with no additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with nested additionalProperties -> with additional properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with nested additionalProperties::with additional properties" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "additionalProperties": true + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with nested additionalProperties::with additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with nested unevaluatedProperties -> with no nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with nested unevaluatedProperties::with no nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": { + "type": "string", + "maxLength": 2 + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with nested unevaluatedProperties::with no nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with nested unevaluatedProperties -> with nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with nested unevaluatedProperties::with nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": { + "type": "string", + "maxLength": 2 + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with nested unevaluatedProperties::with nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with anyOf -> when one matches and has no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with anyOf::when one matches and has no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "anyOf": [ + { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "baz": { + "const": "baz" + } + }, + "required": [ + "baz" + ] + }, + { + "properties": { + "quux": { + "const": "quux" + } + }, + "required": [ + "quux" + ] + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with anyOf::when one matches and has no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with anyOf -> when one matches and has unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with anyOf::when one matches and has unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_23() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with anyOf::when one matches and has unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "baz": "not-baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "anyOf": [ + { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "baz": { + "const": "baz" + } + }, + "required": [ + "baz" + ] + }, + { + "properties": { + "quux": { + "const": "quux" + } + }, + "required": [ + "quux" + ] + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with anyOf::when one matches and has unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with anyOf -> when two match and has no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with anyOf::when two match and has no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "anyOf": [ + { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "baz": { + "const": "baz" + } + }, + "required": [ + "baz" + ] + }, + { + "properties": { + "quux": { + "const": "quux" + } + }, + "required": [ + "quux" + ] + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with anyOf::when two match and has no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with anyOf -> when two match and has unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with anyOf::when two match and has unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_25() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with anyOf::when two match and has unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "baz": "baz", + "quux": "not-quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "anyOf": [ + { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "baz": { + "const": "baz" + } + }, + "required": [ + "baz" + ] + }, + { + "properties": { + "quux": { + "const": "quux" + } + }, + "required": [ + "quux" + ] + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with anyOf::when two match and has unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with oneOf -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with oneOf::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "oneOf": [ + { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "baz": { + "const": "baz" + } + }, + "required": [ + "baz" + ] + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with oneOf::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with oneOf -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with oneOf::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_27() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with oneOf::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "quux": "quux" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "oneOf": [ + { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "baz": { + "const": "baz" + } + }, + "required": [ + "baz" + ] + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with oneOf::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with not -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with not::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_28() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with not::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "not": { + "not": { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with not::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else -> when if is true and has no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is true and has no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + { + "foo": "then", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "then": { + "properties": { + "bar": { + "type": "string" + } + }, + "required": [ + "bar" + ] + }, + "else": { + "properties": { + "baz": { + "type": "string" + } + }, + "required": [ + "baz" + ] + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is true and has no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else -> when if is true and has unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is true and has unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_30() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is true and has unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "then", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "then": { + "properties": { + "bar": { + "type": "string" + } + }, + "required": [ + "bar" + ] + }, + "else": { + "properties": { + "baz": { + "type": "string" + } + }, + "required": [ + "baz" + ] + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is true and has unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else -> when if is false and has no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is false and has no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + { + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "then": { + "properties": { + "bar": { + "type": "string" + } + }, + "required": [ + "bar" + ] + }, + "else": { + "properties": { + "baz": { + "type": "string" + } + }, + "required": [ + "baz" + ] + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is false and has no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else -> when if is false and has unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is false and has unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_32() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is false and has unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "else", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "then": { + "properties": { + "bar": { + "type": "string" + } + }, + "required": [ + "bar" + ] + }, + "else": { + "properties": { + "baz": { + "type": "string" + } + }, + "required": [ + "baz" + ] + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else::when if is false and has unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else, then not defined -> when if is true and has no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is true and has no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_33() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is true and has no unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "then", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "else": { + "properties": { + "baz": { + "type": "string" + } + }, + "required": [ + "baz" + ] + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is true and has no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else, then not defined -> when if is true and has unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is true and has unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_34() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is true and has unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "then", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "else": { + "properties": { + "baz": { + "type": "string" + } + }, + "required": [ + "baz" + ] + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is true and has unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else, then not defined -> when if is false and has no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is false and has no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + { + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "else": { + "properties": { + "baz": { + "type": "string" + } + }, + "required": [ + "baz" + ] + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is false and has no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else, then not defined -> when if is false and has unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is false and has unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_36() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is false and has unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "else", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "else": { + "properties": { + "baz": { + "type": "string" + } + }, + "required": [ + "baz" + ] + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else, then not defined::when if is false and has unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else, else not defined -> when if is true and has no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is true and has no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + { + "foo": "then", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "then": { + "properties": { + "bar": { + "type": "string" + } + }, + "required": [ + "bar" + ] + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is true and has no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else, else not defined -> when if is true and has unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is true and has unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_38() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is true and has unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "then", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "then": { + "properties": { + "bar": { + "type": "string" + } + }, + "required": [ + "bar" + ] + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is true and has unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else, else not defined -> when if is false and has no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is false and has no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_39() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is false and has no unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "then": { + "properties": { + "bar": { + "type": "string" + } + }, + "required": [ + "bar" + ] + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is false and has no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with if/then/else, else not defined -> when if is false and has unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is false and has unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_40() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is false and has unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "else", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "if": { + "properties": { + "foo": { + "const": "then" + } + }, + "required": [ + "foo" + ] + }, + "then": { + "properties": { + "bar": { + "type": "string" + } + }, + "required": [ + "bar" + ] + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with if/then/else, else not defined::when if is false and has unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with dependentSchemas -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with dependentSchemas::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with dependentSchemas::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with dependentSchemas -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with dependentSchemas::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_42() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with dependentSchemas::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": { + "const": "bar" + } + }, + "required": [ + "bar" + ] + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with dependentSchemas::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with boolean schemas -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with boolean schemas::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + true + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with boolean schemas::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with boolean schemas -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with boolean schemas::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_44() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with boolean schemas::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + true + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with boolean schemas::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with $ref -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with $ref::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "${'$'}ref": "#/${'$'}defs/bar", + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": false, + "${'$'}defs": { + "bar": { + "properties": { + "bar": { + "type": "string" + } + } + } + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with ${'$'}ref::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with $ref -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with $ref::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_46() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with $ref::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "${'$'}ref": "#/${'$'}defs/bar", + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": false, + "${'$'}defs": { + "bar": { + "properties": { + "bar": { + "type": "string" + } + } + } + } + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with ${'$'}ref::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties before $ref -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties before $ref::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": false, + "properties": { + "foo": { + "type": "string" + } + }, + "${'$'}ref": "#/${'$'}defs/bar", + "${'$'}defs": { + "bar": { + "properties": { + "bar": { + "type": "string" + } + } + } + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties before ${'$'}ref::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties before $ref -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties before $ref::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_48() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties before $ref::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "unevaluatedProperties": false, + "properties": { + "foo": { + "type": "string" + } + }, + "${'$'}ref": "#/${'$'}defs/bar", + "${'$'}defs": { + "bar": { + "properties": { + "bar": { + "type": "string" + } + } + } + } + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties before ${'$'}ref::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with $dynamicRef -> with no unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with $dynamicRef::with no unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://example.com/unevaluated-properties-with-dynamic-ref/derived", + "${'$'}ref": "./baseSchema", + "${'$'}defs": { + "derived": { + "${'$'}dynamicAnchor": "addons", + "properties": { + "bar": { + "type": "string" + } + } + }, + "baseSchema": { + "${'$'}id": "./baseSchema", + "${'$'}comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", + "unevaluatedProperties": false, + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "${'$'}dynamicRef": "#addons", + "${'$'}defs": { + "defaultAddons": { + "${'$'}comment": "Needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "addons" + } + } + } + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with ${'$'}dynamicRef::with no unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with $dynamicRef -> with unevaluated properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with $dynamicRef::with unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_50() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties with $dynamicRef::with unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar", + "baz": "baz" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}id": "https://example.com/unevaluated-properties-with-dynamic-ref/derived", + "${'$'}ref": "./baseSchema", + "${'$'}defs": { + "derived": { + "${'$'}dynamicAnchor": "addons", + "properties": { + "bar": { + "type": "string" + } + } + }, + "baseSchema": { + "${'$'}id": "./baseSchema", + "${'$'}comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", + "unevaluatedProperties": false, + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "${'$'}dynamicRef": "#addons", + "${'$'}defs": { + "defaultAddons": { + "${'$'}comment": "Needed to satisfy the bookending requirement", + "${'$'}dynamicAnchor": "addons" + } + } + } + } + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with ${'$'}dynamicRef::with unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties can't see inside cousins -> always fails" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties can't see inside cousins::always fails" + */ + @Test + fun jsonSchemaSuiteTest_51() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties can't see inside cousins::always fails" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "properties": { + "foo": true + } + }, + { + "unevaluatedProperties": false + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties can't see inside cousins::always fails" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties can't see inside cousins (reverse order) -> always fails" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties can't see inside cousins (reverse order)::always fails" + */ + @Test + fun jsonSchemaSuiteTest_52() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties can't see inside cousins (reverse order)::always fails" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "allOf": [ + { + "unevaluatedProperties": false + }, + { + "properties": { + "foo": true + } + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties can't see inside cousins (reverse order)::always fails" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "nested unevaluatedProperties, outer false, inner true, properties outside -> with no nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::nested unevaluatedProperties, outer false, inner true, properties outside::with no nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::nested unevaluatedProperties, outer false, inner true, properties outside::with no nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "nested unevaluatedProperties, outer false, inner true, properties outside -> with nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::nested unevaluatedProperties, outer false, inner true, properties outside::with nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::nested unevaluatedProperties, outer false, inner true, properties outside::with nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "nested unevaluatedProperties, outer false, inner true, properties inside -> with no nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::nested unevaluatedProperties, outer false, inner true, properties inside::with no nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::nested unevaluatedProperties, outer false, inner true, properties inside::with no nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "nested unevaluatedProperties, outer false, inner true, properties inside -> with nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::nested unevaluatedProperties, outer false, inner true, properties inside::with nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::nested unevaluatedProperties, outer false, inner true, properties inside::with nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "nested unevaluatedProperties, outer true, inner false, properties outside -> with no nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties outside::with no nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_57() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties outside::with no nested unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": true + } + """, + false, + """ schemaTestId: "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties outside::with no nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "nested unevaluatedProperties, outer true, inner false, properties outside -> with nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties outside::with nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_58() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties outside::with nested unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "allOf": [ + { + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": true + } + """, + false, + """ schemaTestId: "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties outside::with nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "nested unevaluatedProperties, outer true, inner false, properties inside -> with no nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties inside::with no nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": true + } + """, + true, + """ schemaTestId: "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties inside::with no nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "nested unevaluatedProperties, outer true, inner false, properties inside -> with nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties inside::with nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_60() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties inside::with nested unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": true + } + """, + false, + """ schemaTestId: "unevaluatedProperties::nested unevaluatedProperties, outer true, inner false, properties inside::with nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "cousin unevaluatedProperties, true and false, true with properties -> with no nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::cousin unevaluatedProperties, true and false, true with properties::with no nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_61() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::cousin unevaluatedProperties, true and false, true with properties::with no nested unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": true + }, + { + "unevaluatedProperties": false + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::cousin unevaluatedProperties, true and false, true with properties::with no nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "cousin unevaluatedProperties, true and false, true with properties -> with nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::cousin unevaluatedProperties, true and false, true with properties::with nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_62() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::cousin unevaluatedProperties, true and false, true with properties::with nested unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": true + }, + { + "unevaluatedProperties": false + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::cousin unevaluatedProperties, true and false, true with properties::with nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "cousin unevaluatedProperties, true and false, false with properties -> with no nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::cousin unevaluatedProperties, true and false, false with properties::with no nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_63() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "unevaluatedProperties": true + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + ] + } + """, + true, + """ schemaTestId: "unevaluatedProperties::cousin unevaluatedProperties, true and false, false with properties::with no nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "cousin unevaluatedProperties, true and false, false with properties -> with nested unevaluated properties" + * + * Test ID: "unevaluatedProperties::cousin unevaluatedProperties, true and false, false with properties::with nested unevaluated properties" + */ + @Test + fun jsonSchemaSuiteTest_64() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::cousin unevaluatedProperties, true and false, false with properties::with nested unevaluated properties" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "unevaluatedProperties": true + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::cousin unevaluatedProperties, true and false, false with properties::with nested unevaluated properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "property is evaluated in an uncle schema to unevaluatedProperties -> no extra properties" + * + * Test ID: "unevaluatedProperties::property is evaluated in an uncle schema to unevaluatedProperties::no extra properties" + */ + @Test + fun jsonSchemaSuiteTest_65() { + // see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "test" + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "object", + "properties": { + "bar": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + }, + "anyOf": [ + { + "properties": { + "foo": { + "properties": { + "faz": { + "type": "string" + } + } + } + } + } + ] + } + """, + true, + """ schemaTestId: "unevaluatedProperties::property is evaluated in an uncle schema to unevaluatedProperties::no extra properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "property is evaluated in an uncle schema to unevaluatedProperties -> uncle keyword evaluation is not significant" + * + * Test ID: "unevaluatedProperties::property is evaluated in an uncle schema to unevaluatedProperties::uncle keyword evaluation is not significant" + */ + @Test + fun jsonSchemaSuiteTest_66() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::property is evaluated in an uncle schema to unevaluatedProperties::uncle keyword evaluation is not significant" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + // see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "test", + "faz": "test" + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { + "type": "object", + "properties": { + "bar": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + }, + "anyOf": [ + { + "properties": { + "foo": { + "properties": { + "faz": { + "type": "string" + } + } + } + } + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::property is evaluated in an uncle schema to unevaluatedProperties::uncle keyword evaluation is not significant" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "in-place applicator siblings, allOf has unevaluated -> base case: both properties present" + * + * Test ID: "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::base case: both properties present" + */ + @Test + fun jsonSchemaSuiteTest_67() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::base case: both properties present" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": true + }, + "unevaluatedProperties": false + } + ], + "anyOf": [ + { + "properties": { + "bar": true + } + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::base case: both properties present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "in-place applicator siblings, allOf has unevaluated -> in place applicator siblings, bar is missing" + * + * Test ID: "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::in place applicator siblings, bar is missing" + */ + @Test + fun jsonSchemaSuiteTest_68() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": true + }, + "unevaluatedProperties": false + } + ], + "anyOf": [ + { + "properties": { + "bar": true + } + } + ] + } + """, + true, + """ schemaTestId: "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::in place applicator siblings, bar is missing" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "in-place applicator siblings, allOf has unevaluated -> in place applicator siblings, foo is missing" + * + * Test ID: "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::in place applicator siblings, foo is missing" + */ + @Test + fun jsonSchemaSuiteTest_69() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::in place applicator siblings, foo is missing" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": true + }, + "unevaluatedProperties": false + } + ], + "anyOf": [ + { + "properties": { + "bar": true + } + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::in-place applicator siblings, allOf has unevaluated::in place applicator siblings, foo is missing" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "in-place applicator siblings, anyOf has unevaluated -> base case: both properties present" + * + * Test ID: "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::base case: both properties present" + */ + @Test + fun jsonSchemaSuiteTest_70() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::base case: both properties present" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": true + } + } + ], + "anyOf": [ + { + "properties": { + "bar": true + }, + "unevaluatedProperties": false + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::base case: both properties present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "in-place applicator siblings, anyOf has unevaluated -> in place applicator siblings, bar is missing" + * + * Test ID: "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::in place applicator siblings, bar is missing" + */ + @Test + fun jsonSchemaSuiteTest_71() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::in place applicator siblings, bar is missing" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": true + } + } + ], + "anyOf": [ + { + "properties": { + "bar": true + }, + "unevaluatedProperties": false + } + ] + } + """, + false, + """ schemaTestId: "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::in place applicator siblings, bar is missing" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "in-place applicator siblings, anyOf has unevaluated -> in place applicator siblings, foo is missing" + * + * Test ID: "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::in place applicator siblings, foo is missing" + */ + @Test + fun jsonSchemaSuiteTest_72() { + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "allOf": [ + { + "properties": { + "foo": true + } + } + ], + "anyOf": [ + { + "properties": { + "bar": true + }, + "unevaluatedProperties": false + } + ] + } + """, + true, + """ schemaTestId: "unevaluatedProperties::in-place applicator siblings, anyOf has unevaluated::in place applicator siblings, foo is missing" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + single cyclic ref -> Empty is valid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Empty is valid" + */ + @Test + fun jsonSchemaSuiteTest_73() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "x": { + "${'$'}ref": "#" + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Empty is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + single cyclic ref -> Single is valid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Single is valid" + */ + @Test + fun jsonSchemaSuiteTest_74() { + + assertKsonEnforcesSchema( + """ + { + "x": { + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "x": { + "${'$'}ref": "#" + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Single is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + single cyclic ref -> Unevaluated on 1st level is invalid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 1st level is invalid" + */ + @Test + fun jsonSchemaSuiteTest_75() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 1st level is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "x": { + }, + "y": { + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "x": { + "${'$'}ref": "#" + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 1st level is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + single cyclic ref -> Nested is valid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Nested is valid" + */ + @Test + fun jsonSchemaSuiteTest_76() { + + assertKsonEnforcesSchema( + """ + { + "x": { + "x": { + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "x": { + "${'$'}ref": "#" + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Nested is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + single cyclic ref -> Unevaluated on 2nd level is invalid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 2nd level is invalid" + */ + @Test + fun jsonSchemaSuiteTest_77() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 2nd level is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "x": { + "x": { + }, + "y": { + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "x": { + "${'$'}ref": "#" + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 2nd level is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + single cyclic ref -> Deep nested is valid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Deep nested is valid" + */ + @Test + fun jsonSchemaSuiteTest_78() { + + assertKsonEnforcesSchema( + """ + { + "x": { + "x": { + "x": { + } + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "x": { + "${'$'}ref": "#" + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Deep nested is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + single cyclic ref -> Unevaluated on 3rd level is invalid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 3rd level is invalid" + */ + @Test + fun jsonSchemaSuiteTest_79() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 3rd level is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "x": { + "x": { + "x": { + }, + "y": { + } + } + } + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "x": { + "${'$'}ref": "#" + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + single cyclic ref::Unevaluated on 3rd level is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + ref inside allOf / oneOf -> Empty is invalid (no x or y)" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::Empty is invalid (no x or y)" + */ + @Test + fun jsonSchemaSuiteTest_80() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "properties": { + "a": true + } + }, + "two": { + "required": [ + "x" + ], + "properties": { + "x": true + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "properties": { + "b": true + } + }, + { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "y" + ], + "properties": { + "y": true + } + } + ] + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::Empty is invalid (no x or y)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + ref inside allOf / oneOf -> a and b are invalid (no x or y)" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and b are invalid (no x or y)" + */ + @Test + fun jsonSchemaSuiteTest_81() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "b": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "properties": { + "a": true + } + }, + "two": { + "required": [ + "x" + ], + "properties": { + "x": true + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "properties": { + "b": true + } + }, + { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "y" + ], + "properties": { + "y": true + } + } + ] + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and b are invalid (no x or y)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + ref inside allOf / oneOf -> x and y are invalid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::x and y are invalid" + */ + @Test + fun jsonSchemaSuiteTest_82() { + + assertKsonEnforcesSchema( + """ + { + "x": 1, + "y": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "properties": { + "a": true + } + }, + "two": { + "required": [ + "x" + ], + "properties": { + "x": true + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "properties": { + "b": true + } + }, + { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "y" + ], + "properties": { + "y": true + } + } + ] + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::x and y are invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + ref inside allOf / oneOf -> a and x are valid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and x are valid" + */ + @Test + fun jsonSchemaSuiteTest_83() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "x": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "properties": { + "a": true + } + }, + "two": { + "required": [ + "x" + ], + "properties": { + "x": true + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "properties": { + "b": true + } + }, + { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "y" + ], + "properties": { + "y": true + } + } + ] + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and x are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + ref inside allOf / oneOf -> a and y are valid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and y are valid" + */ + @Test + fun jsonSchemaSuiteTest_84() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "y": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "properties": { + "a": true + } + }, + "two": { + "required": [ + "x" + ], + "properties": { + "x": true + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "properties": { + "b": true + } + }, + { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "y" + ], + "properties": { + "y": true + } + } + ] + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and y are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + ref inside allOf / oneOf -> a and b and x are valid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and b and x are valid" + */ + @Test + fun jsonSchemaSuiteTest_85() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "b": 1, + "x": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "properties": { + "a": true + } + }, + "two": { + "required": [ + "x" + ], + "properties": { + "x": true + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "properties": { + "b": true + } + }, + { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "y" + ], + "properties": { + "y": true + } + } + ] + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and b and x are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + ref inside allOf / oneOf -> a and b and y are valid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and b and y are valid" + */ + @Test + fun jsonSchemaSuiteTest_86() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "b": 1, + "y": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "properties": { + "a": true + } + }, + "two": { + "required": [ + "x" + ], + "properties": { + "x": true + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "properties": { + "b": true + } + }, + { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "y" + ], + "properties": { + "y": true + } + } + ] + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and b and y are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties + ref inside allOf / oneOf -> a and b and x and y are invalid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and b and x and y are invalid" + */ + @Test + fun jsonSchemaSuiteTest_87() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "b": 1, + "x": 1, + "y": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "properties": { + "a": true + } + }, + "two": { + "required": [ + "x" + ], + "properties": { + "x": true + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "properties": { + "b": true + } + }, + { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "y" + ], + "properties": { + "y": true + } + } + ] + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties + ref inside allOf / oneOf::a and b and x and y are invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> Empty is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::Empty is invalid" + */ + @Test + fun jsonSchemaSuiteTest_88() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::Empty is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> a is valid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::a is valid" + */ + @Test + fun jsonSchemaSuiteTest_89() { + + assertKsonEnforcesSchema( + """ + { + "a": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::a is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> b is valid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::b is valid" + */ + @Test + fun jsonSchemaSuiteTest_90() { + + assertKsonEnforcesSchema( + """ + { + "b": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::b is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> c is valid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::c is valid" + */ + @Test + fun jsonSchemaSuiteTest_91() { + + assertKsonEnforcesSchema( + """ + { + "c": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::c is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> d is valid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::d is valid" + */ + @Test + fun jsonSchemaSuiteTest_92() { + + assertKsonEnforcesSchema( + """ + { + "d": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::d is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> a + b is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::a + b is invalid" + */ + @Test + fun jsonSchemaSuiteTest_93() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "b": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::a + b is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> a + c is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::a + c is invalid" + */ + @Test + fun jsonSchemaSuiteTest_94() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "c": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::a + c is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> a + d is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::a + d is invalid" + */ + @Test + fun jsonSchemaSuiteTest_95() { + + assertKsonEnforcesSchema( + """ + { + "a": 1, + "d": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::a + d is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> b + c is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::b + c is invalid" + */ + @Test + fun jsonSchemaSuiteTest_96() { + + assertKsonEnforcesSchema( + """ + { + "b": 1, + "c": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::b + c is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> b + d is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::b + d is invalid" + */ + @Test + fun jsonSchemaSuiteTest_97() { + + assertKsonEnforcesSchema( + """ + { + "b": 1, + "d": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::b + d is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> c + d is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::c + d is invalid" + */ + @Test + fun jsonSchemaSuiteTest_98() { + + assertKsonEnforcesSchema( + """ + { + "c": 1, + "d": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::c + d is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> xx is valid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::xx is valid" + */ + @Test + fun jsonSchemaSuiteTest_99() { + + assertKsonEnforcesSchema( + """ + { + "xx": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::xx is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> xx + foox is valid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::xx + foox is valid" + */ + @Test + fun jsonSchemaSuiteTest_100() { + + assertKsonEnforcesSchema( + """ + { + "xx": 1, + "foox": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::xx + foox is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> xx + foo is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::xx + foo is invalid" + */ + @Test + fun jsonSchemaSuiteTest_101() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::dynamic evalation inside nested refs::xx + foo is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "xx": 1, + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::xx + foo is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> xx + a is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::xx + a is invalid" + */ + @Test + fun jsonSchemaSuiteTest_102() { + + assertKsonEnforcesSchema( + """ + { + "xx": 1, + "a": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::xx + a is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> xx + b is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::xx + b is invalid" + */ + @Test + fun jsonSchemaSuiteTest_103() { + + assertKsonEnforcesSchema( + """ + { + "xx": 1, + "b": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::xx + b is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> xx + c is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::xx + c is invalid" + */ + @Test + fun jsonSchemaSuiteTest_104() { + + assertKsonEnforcesSchema( + """ + { + "xx": 1, + "c": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::xx + c is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> xx + d is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::xx + d is invalid" + */ + @Test + fun jsonSchemaSuiteTest_105() { + + assertKsonEnforcesSchema( + """ + { + "xx": 1, + "d": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::xx + d is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> all is valid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::all is valid" + */ + @Test + fun jsonSchemaSuiteTest_106() { + + assertKsonEnforcesSchema( + """ + { + "all": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::all is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> all + foo is valid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::all + foo is valid" + */ + @Test + fun jsonSchemaSuiteTest_107() { + + assertKsonEnforcesSchema( + """ + { + "all": 1, + "foo": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::all + foo is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dynamic evalation inside nested refs -> all + a is invalid" + * + * Test ID: "unevaluatedProperties::dynamic evalation inside nested refs::all + a is invalid" + */ + @Test + fun jsonSchemaSuiteTest_108() { + + assertKsonEnforcesSchema( + """ + { + "all": 1, + "a": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "${'$'}defs": { + "one": { + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/two" + }, + { + "required": [ + "b" + ], + "properties": { + "b": true + } + }, + { + "required": [ + "xx" + ], + "patternProperties": { + "x": true + } + }, + { + "required": [ + "all" + ], + "unevaluatedProperties": true + } + ] + }, + "two": { + "oneOf": [ + { + "required": [ + "c" + ], + "properties": { + "c": true + } + }, + { + "required": [ + "d" + ], + "properties": { + "d": true + } + } + ] + } + }, + "oneOf": [ + { + "${'$'}ref": "#/${'$'}defs/one" + }, + { + "required": [ + "a" + ], + "properties": { + "a": true + } + } + ], + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dynamic evalation inside nested refs::all + a is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "non-object instances are valid -> ignores booleans" + * + * Test ID: "unevaluatedProperties::non-object instances are valid::ignores booleans" + */ + @Test + fun jsonSchemaSuiteTest_109() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::non-object instances are valid::ignores booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "non-object instances are valid -> ignores integers" + * + * Test ID: "unevaluatedProperties::non-object instances are valid::ignores integers" + */ + @Test + fun jsonSchemaSuiteTest_110() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::non-object instances are valid::ignores integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "non-object instances are valid -> ignores floats" + * + * Test ID: "unevaluatedProperties::non-object instances are valid::ignores floats" + */ + @Test + fun jsonSchemaSuiteTest_111() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::non-object instances are valid::ignores floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "non-object instances are valid -> ignores arrays" + * + * Test ID: "unevaluatedProperties::non-object instances are valid::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_112() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::non-object instances are valid::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "non-object instances are valid -> ignores strings" + * + * Test ID: "unevaluatedProperties::non-object instances are valid::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_113() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::non-object instances are valid::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "non-object instances are valid -> ignores null" + * + * Test ID: "unevaluatedProperties::non-object instances are valid::ignores null" + */ + @Test + fun jsonSchemaSuiteTest_114() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::non-object instances are valid::ignores null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties with null valued instance properties -> allows null valued properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties with null valued instance properties::allows null valued properties" + */ + @Test + fun jsonSchemaSuiteTest_115() { + + assertKsonEnforcesSchema( + """ + { + "foo": null + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "unevaluatedProperties": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties with null valued instance properties::allows null valued properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties not affected by propertyNames -> allows only number properties" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties not affected by propertyNames::allows only number properties" + */ + @Test + fun jsonSchemaSuiteTest_116() { + + assertKsonEnforcesSchema( + """ + { + "a": 1 + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 1 + }, + "unevaluatedProperties": { + "type": "number" + } + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties not affected by propertyNames::allows only number properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties not affected by propertyNames -> string property is invalid" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties not affected by propertyNames::string property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_117() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties not affected by propertyNames::string property is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "a": "b" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 1 + }, + "unevaluatedProperties": { + "type": "number" + } + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties not affected by propertyNames::string property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties can see annotations from if without then and else -> valid in case if is evaluated" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties can see annotations from if without then and else::valid in case if is evaluated" + */ + @Test + fun jsonSchemaSuiteTest_118() { + + assertKsonEnforcesSchema( + """ + { + "foo": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "patternProperties": { + "foo": { + "type": "string" + } + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties can see annotations from if without then and else::valid in case if is evaluated" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "unevaluatedProperties can see annotations from if without then and else -> invalid in case if is evaluated" + * + * Test ID: "unevaluatedProperties::unevaluatedProperties can see annotations from if without then and else::invalid in case if is evaluated" + */ + @Test + fun jsonSchemaSuiteTest_119() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::unevaluatedProperties can see annotations from if without then and else::invalid in case if is evaluated" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": "a" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "patternProperties": { + "foo": { + "type": "string" + } + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::unevaluatedProperties can see annotations from if without then and else::invalid in case if is evaluated" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dependentSchemas with unevaluatedProperties -> unevaluatedProperties doesn't consider dependentSchemas" + * + * Test ID: "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties doesn't consider dependentSchemas" + */ + @Test + fun jsonSchemaSuiteTest_120() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties doesn't consider dependentSchemas" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo2": { + } + }, + "dependentSchemas": { + "foo": { + }, + "foo2": { + "properties": { + "bar": { + } + } + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties doesn't consider dependentSchemas" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dependentSchemas with unevaluatedProperties -> unevaluatedProperties doesn't see bar when foo2 is absent" + * + * Test ID: "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties doesn't see bar when foo2 is absent" + */ + @Test + fun jsonSchemaSuiteTest_121() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties doesn't see bar when foo2 is absent" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": "" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo2": { + } + }, + "dependentSchemas": { + "foo": { + }, + "foo2": { + "properties": { + "bar": { + } + } + } + }, + "unevaluatedProperties": false + } + """, + false, + """ schemaTestId: "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties doesn't see bar when foo2 is absent" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json`: + * "dependentSchemas with unevaluatedProperties -> unevaluatedProperties sees bar when foo2 is present" + * + * Test ID: "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties sees bar when foo2 is present" + */ + @Test + fun jsonSchemaSuiteTest_122() { + + assertKsonEnforcesSchema( + """ + { + "foo2": "", + "bar": "" + } + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo2": { + } + }, + "dependentSchemas": { + "foo": { + }, + "foo2": { + "properties": { + "bar": { + } + } + } + }, + "unevaluatedProperties": false + } + """, + true, + """ schemaTestId: "unevaluatedProperties::dependentSchemas with unevaluatedProperties::unevaluatedProperties sees bar when foo2 is present" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_uniqueItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_uniqueItems.kt new file mode 100644 index 00000000..bc743bb1 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_uniqueItems.kt @@ -0,0 +1,2256 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_uniqueItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> unique array of integers is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of integers is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of integers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of integers is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of integers is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of integers is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of more than two integers is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of more than two integers is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of more than two integers is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> numbers are unique if mathematically unequal" + * + * Test ID: "uniqueItems::uniqueItems validation::numbers are unique if mathematically unequal" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1.0, + 1.0, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::numbers are unique if mathematically unequal" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> false is not equal to zero" + * + * Test ID: "uniqueItems::uniqueItems validation::false is not equal to zero" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 0, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::false is not equal to zero" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> true is not equal to one" + * + * Test ID: "uniqueItems::uniqueItems validation::true is not equal to one" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + 1, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::true is not equal to one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> unique array of strings is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of strings is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "baz" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of strings is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of strings is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> unique array of objects is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + }, + { + "foo": "baz" + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of objects is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of objects is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + }, + { + "foo": "bar" + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of objects is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> property order of array of objects is ignored" + * + * Test ID: "uniqueItems::uniqueItems validation::property order of array of objects is ignored" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar", + "bar": "foo" + }, + { + "bar": "foo", + "foo": "bar" + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::property order of array of objects is ignored" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> unique array of nested objects is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of nested objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": { + "bar": { + "baz": true + } + } + }, + { + "foo": { + "bar": { + "baz": false + } + } + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of nested objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of nested objects is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of nested objects is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": { + "bar": { + "baz": true + } + } + }, + { + "foo": { + "bar": { + "baz": true + } + } + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of nested objects is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> unique array of arrays is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of arrays is valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "bar" + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of arrays is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of arrays is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of arrays is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "foo" + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of arrays is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of more than two arrays is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of more than two arrays is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "bar" + ], + [ + "foo" + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of more than two arrays is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> 1 and true are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::1 and true are unique" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + 1, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::1 and true are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> 0 and false are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::0 and false are unique" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + 0, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::0 and false are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> [1] and [true] are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::[1] and [true] are unique" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + [ + 1 + ], + [ + true + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::[1] and [true] are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> [0] and [false] are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::[0] and [false] are unique" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + [ + 0 + ], + [ + false + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::[0] and [false] are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> nested [1] and [true] are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::nested [1] and [true] are unique" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + 1 + ], + "foo" + ], + [ + [ + true + ], + "foo" + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::nested [1] and [true] are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> nested [0] and [false] are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::nested [0] and [false] are unique" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + 0 + ], + "foo" + ], + [ + [ + false + ], + "foo" + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::nested [0] and [false] are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> unique heterogeneous types are valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique heterogeneous types are valid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + [ + { + }, + [ + 1 + ], + true, + null, + 1, + "{}" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique heterogeneous types are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> non-unique heterogeneous types are invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique heterogeneous types are invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + [ + { + }, + [ + 1 + ], + true, + null, + { + }, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique heterogeneous types are invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> different objects are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::different objects are unique" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + { + "a": 1, + "b": 2 + }, + { + "a": 2, + "b": 1 + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::different objects are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> objects are non-unique despite key order" + * + * Test ID: "uniqueItems::uniqueItems validation::objects are non-unique despite key order" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + [ + { + "a": 1, + "b": 2 + }, + { + "b": 2, + "a": 1 + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::objects are non-unique despite key order" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> {"a": false} and {"a": 0} are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::{"a": false} and {"a": 0} are unique" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + [ + { + "a": false + }, + { + "a": 0 + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::{"a": false} and {"a": 0} are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems validation -> {"a": true} and {"a": 1} are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::{"a": true} and {"a": 1} are unique" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + [ + { + "a": true + }, + { + "a": 1 + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::{"a": true} and {"a": 1} are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items -> [false, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::[false, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + [ + false, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::[false, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items -> [true, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::[true, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::[true, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items -> [false, false] from items array is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::[false, false] from items array is not valid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + [ + false, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::[false, false] from items array is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items -> [true, true] from items array is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::[true, true] from items array is not valid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + [ + true, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::[true, true] from items array is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items -> unique array extended from [false, true] is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::unique array extended from [false, true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::unique array extended from [false, true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items -> unique array extended from [true, false] is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::unique array extended from [true, false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + [ + true, + false, + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::unique array extended from [true, false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items -> non-unique array extended from [false, true] is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::non-unique array extended from [false, true] is not valid" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + "foo", + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::non-unique array extended from [false, true] is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items -> non-unique array extended from [true, false] is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::non-unique array extended from [true, false] is not valid" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + [ + true, + false, + "foo", + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::non-unique array extended from [true, false] is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> [false, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, true] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + false, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "items": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> [true, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, false] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "items": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> [false, false] from items array is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, false] from items array is not valid" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + [ + false, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "items": false + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, false] from items array is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> [true, true] from items array is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, true] from items array is not valid" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + [ + true, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "items": false + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, true] from items array is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> extra items are invalid even if unique" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::extra items are invalid even if unique" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + null + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "items": false + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::extra items are invalid even if unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> unique array of integers is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique array of integers is valid" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique array of integers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique array of integers is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique array of integers is valid" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique array of integers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> numbers are unique if mathematically unequal" + * + * Test ID: "uniqueItems::uniqueItems=false validation::numbers are unique if mathematically unequal" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + [ + 1.0, + 1.0, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::numbers are unique if mathematically unequal" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> false is not equal to zero" + * + * Test ID: "uniqueItems::uniqueItems=false validation::false is not equal to zero" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + [ + 0, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::false is not equal to zero" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> true is not equal to one" + * + * Test ID: "uniqueItems::uniqueItems=false validation::true is not equal to one" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + [ + 1, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::true is not equal to one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> unique array of objects is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique array of objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + }, + { + "foo": "baz" + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique array of objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique array of objects is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique array of objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + }, + { + "foo": "bar" + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique array of objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> unique array of nested objects is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique array of nested objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": { + "bar": { + "baz": true + } + } + }, + { + "foo": { + "bar": { + "baz": false + } + } + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique array of nested objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique array of nested objects is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique array of nested objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": { + "bar": { + "baz": true + } + } + }, + { + "foo": { + "bar": { + "baz": true + } + } + } + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique array of nested objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> unique array of arrays is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique array of arrays is valid" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "bar" + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique array of arrays is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique array of arrays is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique array of arrays is valid" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "foo" + ] + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique array of arrays is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> 1 and true are unique" + * + * Test ID: "uniqueItems::uniqueItems=false validation::1 and true are unique" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + [ + 1, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::1 and true are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> 0 and false are unique" + * + * Test ID: "uniqueItems::uniqueItems=false validation::0 and false are unique" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + [ + 0, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::0 and false are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> unique heterogeneous types are valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique heterogeneous types are valid" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + [ + { + }, + [ + 1 + ], + true, + null, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique heterogeneous types are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique heterogeneous types are valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique heterogeneous types are valid" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + [ + { + }, + [ + 1 + ], + true, + null, + { + }, + 1 + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique heterogeneous types are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items -> [false, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::[false, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_57() { + + assertKsonEnforcesSchema( + """ + [ + false, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::[false, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items -> [true, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::[true, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::[true, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items -> [false, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::[false, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + [ + false, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::[false, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items -> [true, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::[true, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_60() { + + assertKsonEnforcesSchema( + """ + [ + true, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::[true, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items -> unique array extended from [false, true] is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::unique array extended from [false, true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_61() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::unique array extended from [false, true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items -> unique array extended from [true, false] is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::unique array extended from [true, false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + [ + true, + false, + "foo", + "bar" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::unique array extended from [true, false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items -> non-unique array extended from [false, true] is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::non-unique array extended from [false, true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_63() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + "foo", + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::non-unique array extended from [false, true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items -> non-unique array extended from [true, false] is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::non-unique array extended from [true, false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_64() { + + assertKsonEnforcesSchema( + """ + [ + true, + false, + "foo", + "foo" + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::non-unique array extended from [true, false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> [false, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_65() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, true] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + false, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "items": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> [true, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_66() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, false] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "items": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> [false, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_67() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, false] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + false, + false + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "items": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> [true, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_68() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, true] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + true, + true + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "items": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> extra items are invalid even if unique" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::extra items are invalid even if unique" + */ + @Test + fun jsonSchemaSuiteTest_69() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + null + ] + """, + """ + { + "${'$'}schema": "https://json-schema.org/draft/2020-12/schema", + "prefixItems": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "items": false + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::extra items are invalid even if unique" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_vocabulary.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_vocabulary.kt new file mode 100644 index 00000000..69d0fa81 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft2020_12SuiteTest_vocabulary.kt @@ -0,0 +1,160 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft2020_12SuiteTest_vocabulary : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/vocabulary.json`: + * "schema that uses custom metaschema with with no validation vocabulary -> applicator vocabulary still works" + * + * Test ID: "vocabulary::schema that uses custom metaschema with with no validation vocabulary::applicator vocabulary still works" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "badProperty": "this property should not exist" + } + """, + """ + { + "${'$'}id": "https://schema/using/no/validation", + "${'$'}schema": "http://localhost:1234/draft2020-12/metaschema-no-validation.json", + "properties": { + "badProperty": false, + "numberProperty": { + "minimum": 10 + } + } + } + """, + false, + """ schemaTestId: "vocabulary::schema that uses custom metaschema with with no validation vocabulary::applicator vocabulary still works" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/vocabulary.json`: + * "schema that uses custom metaschema with with no validation vocabulary -> no validation: valid number" + * + * Test ID: "vocabulary::schema that uses custom metaschema with with no validation vocabulary::no validation: valid number" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "numberProperty": 20 + } + """, + """ + { + "${'$'}id": "https://schema/using/no/validation", + "${'$'}schema": "http://localhost:1234/draft2020-12/metaschema-no-validation.json", + "properties": { + "badProperty": false, + "numberProperty": { + "minimum": 10 + } + } + } + """, + true, + """ schemaTestId: "vocabulary::schema that uses custom metaschema with with no validation vocabulary::no validation: valid number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/vocabulary.json`: + * "schema that uses custom metaschema with with no validation vocabulary -> no validation: invalid number, but it still validates" + * + * Test ID: "vocabulary::schema that uses custom metaschema with with no validation vocabulary::no validation: invalid number, but it still validates" + */ + @Test + fun jsonSchemaSuiteTest_3() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "vocabulary::schema that uses custom metaschema with with no validation vocabulary::no validation: invalid number, but it still validates" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "numberProperty": 1 + } + """, + """ + { + "${'$'}id": "https://schema/using/no/validation", + "${'$'}schema": "http://localhost:1234/draft2020-12/metaschema-no-validation.json", + "properties": { + "badProperty": false, + "numberProperty": { + "minimum": 10 + } + } + } + """, + true, + """ schemaTestId: "vocabulary::schema that uses custom metaschema with with no validation vocabulary::no validation: invalid number, but it still validates" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/vocabulary.json`: + * "ignore unrecognized optional vocabulary -> string value" + * + * Test ID: "vocabulary::ignore unrecognized optional vocabulary::string value" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "${'$'}schema": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json", + "type": "number" + } + """, + false, + """ schemaTestId: "vocabulary::ignore unrecognized optional vocabulary::string value" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft2020-12/vocabulary.json`: + * "ignore unrecognized optional vocabulary -> number value" + * + * Test ID: "vocabulary::ignore unrecognized optional vocabulary::number value" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 20 + """, + """ + { + "${'$'}schema": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json", + "type": "number" + } + """, + true, + """ schemaTestId: "vocabulary::ignore unrecognized optional vocabulary::number value" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_additionalItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_additionalItems.kt new file mode 100644 index 00000000..8b1deae2 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_additionalItems.kt @@ -0,0 +1,649 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_additionalItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems as schema -> additional items match schema" + * + * Test ID: "additionalItems::additionalItems as schema::additional items match schema" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + null, + 2, + 3, + 4 + ] + """, + """ + { + "items": [ + { + } + ], + "additionalItems": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "additionalItems::additionalItems as schema::additional items match schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems as schema -> additional items do not match schema" + * + * Test ID: "additionalItems::additionalItems as schema::additional items do not match schema" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + null, + 2, + 3, + "foo" + ] + """, + """ + { + "items": [ + { + } + ], + "additionalItems": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "additionalItems::additionalItems as schema::additional items do not match schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "when items is schema, additionalItems does nothing -> valid with a array of type integers" + * + * Test ID: "additionalItems::when items is schema, additionalItems does nothing::valid with a array of type integers" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "items": { + "type": "integer" + }, + "additionalItems": { + "type": "string" + } + } + """, + true, + """ schemaTestId: "additionalItems::when items is schema, additionalItems does nothing::valid with a array of type integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "when items is schema, additionalItems does nothing -> invalid with a array of mixed types" + * + * Test ID: "additionalItems::when items is schema, additionalItems does nothing::invalid with a array of mixed types" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "2", + "3" + ] + """, + """ + { + "items": { + "type": "integer" + }, + "additionalItems": { + "type": "string" + } + } + """, + false, + """ schemaTestId: "additionalItems::when items is schema, additionalItems does nothing::invalid with a array of mixed types" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "when items is schema, boolean additionalItems does nothing -> all items match schema" + * + * Test ID: "additionalItems::when items is schema, boolean additionalItems does nothing::all items match schema" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3, + 4, + 5 + ] + """, + """ + { + "items": { + }, + "additionalItems": false + } + """, + true, + """ schemaTestId: "additionalItems::when items is schema, boolean additionalItems does nothing::all items match schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "array of items with no additionalItems permitted -> empty array" + * + * Test ID: "additionalItems::array of items with no additionalItems permitted::empty array" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "items": [ + { + }, + { + }, + { + } + ], + "additionalItems": false + } + """, + true, + """ schemaTestId: "additionalItems::array of items with no additionalItems permitted::empty array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "array of items with no additionalItems permitted -> fewer number of items present (1)" + * + * Test ID: "additionalItems::array of items with no additionalItems permitted::fewer number of items present (1)" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "items": [ + { + }, + { + }, + { + } + ], + "additionalItems": false + } + """, + true, + """ schemaTestId: "additionalItems::array of items with no additionalItems permitted::fewer number of items present (1)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "array of items with no additionalItems permitted -> fewer number of items present (2)" + * + * Test ID: "additionalItems::array of items with no additionalItems permitted::fewer number of items present (2)" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "items": [ + { + }, + { + }, + { + } + ], + "additionalItems": false + } + """, + true, + """ schemaTestId: "additionalItems::array of items with no additionalItems permitted::fewer number of items present (2)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "array of items with no additionalItems permitted -> equal number of items present" + * + * Test ID: "additionalItems::array of items with no additionalItems permitted::equal number of items present" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "items": [ + { + }, + { + }, + { + } + ], + "additionalItems": false + } + """, + true, + """ schemaTestId: "additionalItems::array of items with no additionalItems permitted::equal number of items present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "array of items with no additionalItems permitted -> additional items are not permitted" + * + * Test ID: "additionalItems::array of items with no additionalItems permitted::additional items are not permitted" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3, + 4 + ] + """, + """ + { + "items": [ + { + }, + { + }, + { + } + ], + "additionalItems": false + } + """, + false, + """ schemaTestId: "additionalItems::array of items with no additionalItems permitted::additional items are not permitted" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems as false without items -> items defaults to empty schema so everything is valid" + * + * Test ID: "additionalItems::additionalItems as false without items::items defaults to empty schema so everything is valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3, + 4, + 5 + ] + """, + """ + { + "additionalItems": false + } + """, + true, + """ schemaTestId: "additionalItems::additionalItems as false without items::items defaults to empty schema so everything is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems as false without items -> ignores non-arrays" + * + * Test ID: "additionalItems::additionalItems as false without items::ignores non-arrays" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "additionalItems": false + } + """, + true, + """ schemaTestId: "additionalItems::additionalItems as false without items::ignores non-arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems are allowed by default -> only the first item is validated" + * + * Test ID: "additionalItems::additionalItems are allowed by default::only the first item is validated" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo", + false + ] + """, + """ + { + "items": [ + { + "type": "integer" + } + ] + } + """, + true, + """ schemaTestId: "additionalItems::additionalItems are allowed by default::only the first item is validated" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems does not look in applicators, valid case -> items defined in allOf are not examined" + * + * Test ID: "additionalItems::additionalItems does not look in applicators, valid case::items defined in allOf are not examined" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + [ + 1, + null + ] + """, + """ + { + "allOf": [ + { + "items": [ + { + "type": "integer" + } + ] + } + ], + "additionalItems": { + "type": "boolean" + } + } + """, + true, + """ schemaTestId: "additionalItems::additionalItems does not look in applicators, valid case::items defined in allOf are not examined" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems does not look in applicators, invalid case -> items defined in allOf are not examined" + * + * Test ID: "additionalItems::additionalItems does not look in applicators, invalid case::items defined in allOf are not examined" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "hello" + ] + """, + """ + { + "allOf": [ + { + "items": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + ], + "items": [ + { + "type": "integer" + } + ], + "additionalItems": { + "type": "boolean" + } + } + """, + false, + """ schemaTestId: "additionalItems::additionalItems does not look in applicators, invalid case::items defined in allOf are not examined" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "items validation adjusts the starting index for additionalItems -> valid items" + * + * Test ID: "additionalItems::items validation adjusts the starting index for additionalItems::valid items" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + "x", + 2, + 3 + ] + """, + """ + { + "items": [ + { + "type": "string" + } + ], + "additionalItems": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "additionalItems::items validation adjusts the starting index for additionalItems::valid items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "items validation adjusts the starting index for additionalItems -> wrong type of second item" + * + * Test ID: "additionalItems::items validation adjusts the starting index for additionalItems::wrong type of second item" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + "x", + "y" + ] + """, + """ + { + "items": [ + { + "type": "string" + } + ], + "additionalItems": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "additionalItems::items validation adjusts the starting index for additionalItems::wrong type of second item" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems with heterogeneous array -> heterogeneous invalid instance" + * + * Test ID: "additionalItems::additionalItems with heterogeneous array::heterogeneous invalid instance" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + 37 + ] + """, + """ + { + "items": [ + { + } + ], + "additionalItems": false + } + """, + false, + """ schemaTestId: "additionalItems::additionalItems with heterogeneous array::heterogeneous invalid instance" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems with heterogeneous array -> valid instance" + * + * Test ID: "additionalItems::additionalItems with heterogeneous array::valid instance" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "items": [ + { + } + ], + "additionalItems": false + } + """, + true, + """ schemaTestId: "additionalItems::additionalItems with heterogeneous array::valid instance" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: + * "additionalItems with null instance elements -> allows null elements" + * + * Test ID: "additionalItems::additionalItems with null instance elements::allows null elements" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "additionalItems": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "additionalItems::additionalItems with null instance elements::allows null elements" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_additionalProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_additionalProperties.kt new file mode 100644 index 00000000..510b43eb --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_additionalProperties.kt @@ -0,0 +1,520 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_additionalProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> no additional properties is valid" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::no additional properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::no additional properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> an additional property is invalid" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::an additional property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": "boom" + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::an additional property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> ignores arrays" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> ignores strings" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "foobarbaz" + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> ignores other non-objects" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties being false does not allow other properties -> patternProperties are not additional properties" + * + * Test ID: "additionalProperties::additionalProperties being false does not allow other properties::patternProperties are not additional properties" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "vroom": 2 + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "patternProperties": { + "^v": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties being false does not allow other properties::patternProperties are not additional properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "non-ASCII pattern with additionalProperties -> matching the pattern is valid" + * + * Test ID: "additionalProperties::non-ASCII pattern with additionalProperties::matching the pattern is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "ármányos": 2 + } + """, + """ + { + "patternProperties": { + "^á": { + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "additionalProperties::non-ASCII pattern with additionalProperties::matching the pattern is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "non-ASCII pattern with additionalProperties -> not matching the pattern is invalid" + * + * Test ID: "additionalProperties::non-ASCII pattern with additionalProperties::not matching the pattern is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "élmény": 2 + } + """, + """ + { + "patternProperties": { + "^á": { + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "additionalProperties::non-ASCII pattern with additionalProperties::not matching the pattern is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties with schema -> no additional properties is valid" + * + * Test ID: "additionalProperties::additionalProperties with schema::no additional properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "additionalProperties": { + "type": "boolean" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties with schema::no additional properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties with schema -> an additional valid property is valid" + * + * Test ID: "additionalProperties::additionalProperties with schema::an additional valid property is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": true + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "additionalProperties": { + "type": "boolean" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties with schema::an additional valid property is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties with schema -> an additional invalid property is invalid" + * + * Test ID: "additionalProperties::additionalProperties with schema::an additional invalid property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": 12 + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "additionalProperties": { + "type": "boolean" + } + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties with schema::an additional invalid property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties can exist by itself -> an additional valid property is valid" + * + * Test ID: "additionalProperties::additionalProperties can exist by itself::an additional valid property is valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": true + } + """, + """ + { + "additionalProperties": { + "type": "boolean" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties can exist by itself::an additional valid property is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties can exist by itself -> an additional invalid property is invalid" + * + * Test ID: "additionalProperties::additionalProperties can exist by itself::an additional invalid property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "additionalProperties": { + "type": "boolean" + } + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties can exist by itself::an additional invalid property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties are allowed by default -> additional properties are allowed" + * + * Test ID: "additionalProperties::additionalProperties are allowed by default::additional properties are allowed" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": true + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties are allowed by default::additional properties are allowed" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties does not look in applicators -> properties defined in allOf are not examined" + * + * Test ID: "additionalProperties::additionalProperties does not look in applicators::properties defined in allOf are not examined" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": true + } + """, + """ + { + "allOf": [ + { + "properties": { + "foo": { + } + } + } + ], + "additionalProperties": { + "type": "boolean" + } + } + """, + false, + """ schemaTestId: "additionalProperties::additionalProperties does not look in applicators::properties defined in allOf are not examined" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: + * "additionalProperties with null valued instance properties -> allows null values" + * + * Test ID: "additionalProperties::additionalProperties with null valued instance properties::allows null values" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "foo": null + } + """, + """ + { + "additionalProperties": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "additionalProperties::additionalProperties with null valued instance properties::allows null values" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_allOf.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_allOf.kt new file mode 100644 index 00000000..ddeda1d8 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_allOf.kt @@ -0,0 +1,1112 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_allOf : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf -> allOf" + * + * Test ID: "allOf::allOf::allOf" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz", + "bar": 2 + } + """, + """ + { + "allOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf::allOf" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf -> mismatch second" + * + * Test ID: "allOf::allOf::mismatch second" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz" + } + """, + """ + { + "allOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf::mismatch second" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf -> mismatch first" + * + * Test ID: "allOf::allOf::mismatch first" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "allOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf::mismatch first" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf -> wrong type" + * + * Test ID: "allOf::allOf::wrong type" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz", + "bar": "quux" + } + """, + """ + { + "allOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf::wrong type" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with base schema -> valid" + * + * Test ID: "allOf::allOf with base schema::valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "bar": 2, + "baz": null + } + """, + """ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with base schema::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with base schema -> mismatch base schema" + * + * Test ID: "allOf::allOf with base schema::mismatch base schema" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "baz": null + } + """, + """ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with base schema::mismatch base schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with base schema -> mismatch first allOf" + * + * Test ID: "allOf::allOf with base schema::mismatch first allOf" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2, + "baz": null + } + """, + """ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with base schema::mismatch first allOf" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with base schema -> mismatch second allOf" + * + * Test ID: "allOf::allOf with base schema::mismatch second allOf" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "bar": 2 + } + """, + """ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with base schema::mismatch second allOf" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with base schema -> mismatch both" + * + * Test ID: "allOf::allOf with base schema::mismatch both" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ], + "allOf": [ + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + }, + { + "properties": { + "baz": { + "type": "null" + } + }, + "required": [ + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with base schema::mismatch both" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf simple types -> valid" + * + * Test ID: "allOf::allOf simple types::valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 25 + """, + """ + { + "allOf": [ + { + "maximum": 30 + }, + { + "minimum": 20 + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf simple types::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf simple types -> mismatch one" + * + * Test ID: "allOf::allOf simple types::mismatch one" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + 35 + """, + """ + { + "allOf": [ + { + "maximum": 30 + }, + { + "minimum": 20 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf simple types::mismatch one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with boolean schemas, all true -> any value is valid" + * + * Test ID: "allOf::allOf with boolean schemas, all true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + true, + true + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with boolean schemas, all true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with boolean schemas, some false -> any value is invalid" + * + * Test ID: "allOf::allOf with boolean schemas, some false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + true, + false + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with boolean schemas, some false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with boolean schemas, all false -> any value is invalid" + * + * Test ID: "allOf::allOf with boolean schemas, all false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + false, + false + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with boolean schemas, all false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with one empty schema -> any data is valid" + * + * Test ID: "allOf::allOf with one empty schema::any data is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "allOf": [ + { + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with one empty schema::any data is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with two empty schemas -> any data is valid" + * + * Test ID: "allOf::allOf with two empty schemas::any data is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "allOf": [ + { + }, + { + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with two empty schemas::any data is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with the first empty schema -> number is valid" + * + * Test ID: "allOf::allOf with the first empty schema::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "allOf": [ + { + }, + { + "type": "number" + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with the first empty schema::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with the first empty schema -> string is invalid" + * + * Test ID: "allOf::allOf with the first empty schema::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + { + }, + { + "type": "number" + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with the first empty schema::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with the last empty schema -> number is valid" + * + * Test ID: "allOf::allOf with the last empty schema::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "allOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf with the last empty schema::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf with the last empty schema -> string is invalid" + * + * Test ID: "allOf::allOf with the last empty schema::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf with the last empty schema::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "nested allOf, to check validation semantics -> null is valid" + * + * Test ID: "allOf::nested allOf, to check validation semantics::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "allOf": [ + { + "allOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + true, + """ schemaTestId: "allOf::nested allOf, to check validation semantics::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "nested allOf, to check validation semantics -> anything non-null is invalid" + * + * Test ID: "allOf::nested allOf, to check validation semantics::anything non-null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "allOf": [ + { + "allOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + false, + """ schemaTestId: "allOf::nested allOf, to check validation semantics::anything non-null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: false, oneOf: false" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: false, oneOf: false" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: false, oneOf: false" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: false, oneOf: true" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: false, oneOf: true" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + 5 + """, + """ + { + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: false, oneOf: true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: true, oneOf: false" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: true, oneOf: false" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: true, oneOf: false" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: true, oneOf: true" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: true, oneOf: true" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + 15 + """, + """ + { + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: false, anyOf: true, oneOf: true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: false, oneOf: false" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: false, oneOf: false" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + 2 + """, + """ + { + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: false, oneOf: false" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: false, oneOf: true" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: false, oneOf: true" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + 10 + """, + """ + { + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: false, oneOf: true" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: true, oneOf: false" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: true, oneOf: false" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + 6 + """, + """ + { + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + false, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: true, oneOf: false" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: + * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: true, oneOf: true" + * + * Test ID: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: true, oneOf: true" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + 30 + """, + """ + { + "allOf": [ + { + "multipleOf": 2 + } + ], + "anyOf": [ + { + "multipleOf": 3 + } + ], + "oneOf": [ + { + "multipleOf": 5 + } + ] + } + """, + true, + """ schemaTestId: "allOf::allOf combined with anyOf, oneOf::allOf: true, anyOf: true, oneOf: true" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_anyOf.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_anyOf.kt new file mode 100644 index 00000000..0a2f47ab --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_anyOf.kt @@ -0,0 +1,594 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_anyOf : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf -> first anyOf valid" + * + * Test ID: "anyOf::anyOf::first anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf::first anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf -> second anyOf valid" + * + * Test ID: "anyOf::anyOf::second anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 2.5 + """, + """ + { + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf::second anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf -> both anyOf valid" + * + * Test ID: "anyOf::anyOf::both anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf::both anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf -> neither anyOf valid" + * + * Test ID: "anyOf::anyOf::neither anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 1.5 + """, + """ + { + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf::neither anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf with base schema -> mismatch base schema" + * + * Test ID: "anyOf::anyOf with base schema::mismatch base schema" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "type": "string", + "anyOf": [ + { + "maxLength": 2 + }, + { + "minLength": 4 + } + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf with base schema::mismatch base schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf with base schema -> one anyOf valid" + * + * Test ID: "anyOf::anyOf with base schema::one anyOf valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "type": "string", + "anyOf": [ + { + "maxLength": 2 + }, + { + "minLength": 4 + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with base schema::one anyOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf with base schema -> both anyOf invalid" + * + * Test ID: "anyOf::anyOf with base schema::both anyOf invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "string", + "anyOf": [ + { + "maxLength": 2 + }, + { + "minLength": 4 + } + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf with base schema::both anyOf invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf with boolean schemas, all true -> any value is valid" + * + * Test ID: "anyOf::anyOf with boolean schemas, all true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "anyOf": [ + true, + true + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with boolean schemas, all true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf with boolean schemas, some true -> any value is valid" + * + * Test ID: "anyOf::anyOf with boolean schemas, some true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "anyOf": [ + true, + false + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with boolean schemas, some true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf with boolean schemas, all false -> any value is invalid" + * + * Test ID: "anyOf::anyOf with boolean schemas, all false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "anyOf": [ + false, + false + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf with boolean schemas, all false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf complex types -> first anyOf valid (complex)" + * + * Test ID: "anyOf::anyOf complex types::first anyOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "anyOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf complex types::first anyOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf complex types -> second anyOf valid (complex)" + * + * Test ID: "anyOf::anyOf complex types::second anyOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz" + } + """, + """ + { + "anyOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf complex types::second anyOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf complex types -> both anyOf valid (complex)" + * + * Test ID: "anyOf::anyOf complex types::both anyOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz", + "bar": 2 + } + """, + """ + { + "anyOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf complex types::both anyOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf complex types -> neither anyOf valid (complex)" + * + * Test ID: "anyOf::anyOf complex types::neither anyOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "foo": 2, + "bar": "quux" + } + """, + """ + { + "anyOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "anyOf::anyOf complex types::neither anyOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf with one empty schema -> string is valid" + * + * Test ID: "anyOf::anyOf with one empty schema::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "anyOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with one empty schema::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "anyOf with one empty schema -> number is valid" + * + * Test ID: "anyOf::anyOf with one empty schema::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "anyOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + true, + """ schemaTestId: "anyOf::anyOf with one empty schema::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "nested anyOf, to check validation semantics -> null is valid" + * + * Test ID: "anyOf::nested anyOf, to check validation semantics::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + true, + """ schemaTestId: "anyOf::nested anyOf, to check validation semantics::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: + * "nested anyOf, to check validation semantics -> anything non-null is invalid" + * + * Test ID: "anyOf::nested anyOf, to check validation semantics::anything non-null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + false, + """ schemaTestId: "anyOf::nested anyOf, to check validation semantics::anything non-null is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_boolean_schema.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_boolean_schema.kt new file mode 100644 index 00000000..38f685a2 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_boolean_schema.kt @@ -0,0 +1,387 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_boolean_schema : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> number is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> string is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> boolean true is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::boolean true is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::boolean true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> boolean false is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::boolean false is valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::boolean false is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> null is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> object is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::object is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> empty object is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> array is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::array is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'true' -> empty array is valid" + * + * Test ID: "boolean_schema::boolean schema 'true'::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + true + """, + true, + """ schemaTestId: "boolean_schema::boolean schema 'true'::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> number is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> string is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> boolean true is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::boolean true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::boolean true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> boolean false is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::boolean false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::boolean false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> null is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> object is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> empty object is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::empty object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::empty object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> array is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: + * "boolean schema 'false' -> empty array is invalid" + * + * Test ID: "boolean_schema::boolean schema 'false'::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + false + """, + false, + """ schemaTestId: "boolean_schema::boolean schema 'false'::empty array is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_const.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_const.kt new file mode 100644 index 00000000..08553c0a --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_const.kt @@ -0,0 +1,1210 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_const : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const validation -> same value is valid" + * + * Test ID: "const::const validation::same value is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 2 + """, + """ + { + "const": 2 + } + """, + true, + """ schemaTestId: "const::const validation::same value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const validation -> another value is invalid" + * + * Test ID: "const::const validation::another value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 5 + """, + """ + { + "const": 2 + } + """, + false, + """ schemaTestId: "const::const validation::another value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const validation -> another type is invalid" + * + * Test ID: "const::const validation::another type is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "const": 2 + } + """, + false, + """ schemaTestId: "const::const validation::another type is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with object -> same object is valid" + * + * Test ID: "const::const with object::same object is valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar", + "baz": "bax" + } + """, + """ + { + "const": { + "foo": "bar", + "baz": "bax" + } + } + """, + true, + """ schemaTestId: "const::const with object::same object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with object -> same object with different property order is valid" + * + * Test ID: "const::const with object::same object with different property order is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "baz": "bax", + "foo": "bar" + } + """, + """ + { + "const": { + "foo": "bar", + "baz": "bax" + } + } + """, + true, + """ schemaTestId: "const::const with object::same object with different property order is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with object -> another object is invalid" + * + * Test ID: "const::const with object::another object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "const": { + "foo": "bar", + "baz": "bax" + } + } + """, + false, + """ schemaTestId: "const::const with object::another object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with object -> another type is invalid" + * + * Test ID: "const::const with object::another type is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "const": { + "foo": "bar", + "baz": "bax" + } + } + """, + false, + """ schemaTestId: "const::const with object::another type is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with array -> same array is valid" + * + * Test ID: "const::const with array::same array is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + } + ] + """, + """ + { + "const": [ + { + "foo": "bar" + } + ] + } + """, + true, + """ schemaTestId: "const::const with array::same array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with array -> another array item is invalid" + * + * Test ID: "const::const with array::another array item is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + 2 + ] + """, + """ + { + "const": [ + { + "foo": "bar" + } + ] + } + """, + false, + """ schemaTestId: "const::const with array::another array item is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with array -> array with additional items is invalid" + * + * Test ID: "const::const with array::array with additional items is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "const": [ + { + "foo": "bar" + } + ] + } + """, + false, + """ schemaTestId: "const::const with array::array with additional items is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with null -> null is valid" + * + * Test ID: "const::const with null::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "const": null + } + """, + true, + """ schemaTestId: "const::const with null::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with null -> not null is invalid" + * + * Test ID: "const::const with null::not null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "const": null + } + """, + false, + """ schemaTestId: "const::const with null::not null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with false does not match 0 -> false is valid" + * + * Test ID: "const::const with false does not match 0::false is valid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "const": false + } + """, + true, + """ schemaTestId: "const::const with false does not match 0::false is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with false does not match 0 -> integer zero is invalid" + * + * Test ID: "const::const with false does not match 0::integer zero is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "const": false + } + """, + false, + """ schemaTestId: "const::const with false does not match 0::integer zero is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with false does not match 0 -> float zero is invalid" + * + * Test ID: "const::const with false does not match 0::float zero is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 0.0 + """, + """ + { + "const": false + } + """, + false, + """ schemaTestId: "const::const with false does not match 0::float zero is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with true does not match 1 -> true is valid" + * + * Test ID: "const::const with true does not match 1::true is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "const": true + } + """, + true, + """ schemaTestId: "const::const with true does not match 1::true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with true does not match 1 -> integer one is invalid" + * + * Test ID: "const::const with true does not match 1::integer one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "const": true + } + """, + false, + """ schemaTestId: "const::const with true does not match 1::integer one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with true does not match 1 -> float one is invalid" + * + * Test ID: "const::const with true does not match 1::float one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "const": true + } + """, + false, + """ schemaTestId: "const::const with true does not match 1::float one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with [false] does not match [0] -> [false] is valid" + * + * Test ID: "const::const with [false] does not match [0]::[false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + false + ] + """, + """ + { + "const": [ + false + ] + } + """, + true, + """ schemaTestId: "const::const with [false] does not match [0]::[false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with [false] does not match [0] -> [0] is invalid" + * + * Test ID: "const::const with [false] does not match [0]::[0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + 0 + ] + """, + """ + { + "const": [ + false + ] + } + """, + false, + """ schemaTestId: "const::const with [false] does not match [0]::[0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with [false] does not match [0] -> [0.0] is invalid" + * + * Test ID: "const::const with [false] does not match [0]::[0.0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + [ + 0.0 + ] + """, + """ + { + "const": [ + false + ] + } + """, + false, + """ schemaTestId: "const::const with [false] does not match [0]::[0.0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with [true] does not match [1] -> [true] is valid" + * + * Test ID: "const::const with [true] does not match [1]::[true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + [ + true + ] + """, + """ + { + "const": [ + true + ] + } + """, + true, + """ schemaTestId: "const::const with [true] does not match [1]::[true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with [true] does not match [1] -> [1] is invalid" + * + * Test ID: "const::const with [true] does not match [1]::[1] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "const": [ + true + ] + } + """, + false, + """ schemaTestId: "const::const with [true] does not match [1]::[1] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with [true] does not match [1] -> [1.0] is invalid" + * + * Test ID: "const::const with [true] does not match [1]::[1.0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + [ + 1.0 + ] + """, + """ + { + "const": [ + true + ] + } + """, + false, + """ schemaTestId: "const::const with [true] does not match [1]::[1.0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with {"a": false} does not match {"a": 0} -> {"a": false} is valid" + * + * Test ID: "const::const with {"a": false} does not match {"a": 0}::{"a": false} is valid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + "a": false + } + """, + """ + { + "const": { + "a": false + } + } + """, + true, + """ schemaTestId: "const::const with {"a": false} does not match {"a": 0}::{"a": false} is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with {"a": false} does not match {"a": 0} -> {"a": 0} is invalid" + * + * Test ID: "const::const with {"a": false} does not match {"a": 0}::{"a": 0} is invalid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + { + "a": 0 + } + """, + """ + { + "const": { + "a": false + } + } + """, + false, + """ schemaTestId: "const::const with {"a": false} does not match {"a": 0}::{"a": 0} is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with {"a": false} does not match {"a": 0} -> {"a": 0.0} is invalid" + * + * Test ID: "const::const with {"a": false} does not match {"a": 0}::{"a": 0.0} is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + { + "a": 0.0 + } + """, + """ + { + "const": { + "a": false + } + } + """, + false, + """ schemaTestId: "const::const with {"a": false} does not match {"a": 0}::{"a": 0.0} is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with {"a": true} does not match {"a": 1} -> {"a": true} is valid" + * + * Test ID: "const::const with {"a": true} does not match {"a": 1}::{"a": true} is valid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + { + "a": true + } + """, + """ + { + "const": { + "a": true + } + } + """, + true, + """ schemaTestId: "const::const with {"a": true} does not match {"a": 1}::{"a": true} is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with {"a": true} does not match {"a": 1} -> {"a": 1} is invalid" + * + * Test ID: "const::const with {"a": true} does not match {"a": 1}::{"a": 1} is invalid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + { + "a": 1 + } + """, + """ + { + "const": { + "a": true + } + } + """, + false, + """ schemaTestId: "const::const with {"a": true} does not match {"a": 1}::{"a": 1} is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with {"a": true} does not match {"a": 1} -> {"a": 1.0} is invalid" + * + * Test ID: "const::const with {"a": true} does not match {"a": 1}::{"a": 1.0} is invalid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + { + "a": 1.0 + } + """, + """ + { + "const": { + "a": true + } + } + """, + false, + """ schemaTestId: "const::const with {"a": true} does not match {"a": 1}::{"a": 1.0} is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 0 does not match other zero-like types -> false is invalid" + * + * Test ID: "const::const with 0 does not match other zero-like types::false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "const": 0 + } + """, + false, + """ schemaTestId: "const::const with 0 does not match other zero-like types::false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 0 does not match other zero-like types -> integer zero is valid" + * + * Test ID: "const::const with 0 does not match other zero-like types::integer zero is valid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "const": 0 + } + """, + true, + """ schemaTestId: "const::const with 0 does not match other zero-like types::integer zero is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 0 does not match other zero-like types -> float zero is valid" + * + * Test ID: "const::const with 0 does not match other zero-like types::float zero is valid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + 0.0 + """, + """ + { + "const": 0 + } + """, + true, + """ schemaTestId: "const::const with 0 does not match other zero-like types::float zero is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 0 does not match other zero-like types -> empty object is invalid" + * + * Test ID: "const::const with 0 does not match other zero-like types::empty object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "const": 0 + } + """, + false, + """ schemaTestId: "const::const with 0 does not match other zero-like types::empty object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 0 does not match other zero-like types -> empty array is invalid" + * + * Test ID: "const::const with 0 does not match other zero-like types::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "const": 0 + } + """, + false, + """ schemaTestId: "const::const with 0 does not match other zero-like types::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 0 does not match other zero-like types -> empty string is invalid" + * + * Test ID: "const::const with 0 does not match other zero-like types::empty string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "const": 0 + } + """, + false, + """ schemaTestId: "const::const with 0 does not match other zero-like types::empty string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 1 does not match true -> true is invalid" + * + * Test ID: "const::const with 1 does not match true::true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "const": 1 + } + """, + false, + """ schemaTestId: "const::const with 1 does not match true::true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 1 does not match true -> integer one is valid" + * + * Test ID: "const::const with 1 does not match true::integer one is valid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "const": 1 + } + """, + true, + """ schemaTestId: "const::const with 1 does not match true::integer one is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with 1 does not match true -> float one is valid" + * + * Test ID: "const::const with 1 does not match true::float one is valid" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "const": 1 + } + """, + true, + """ schemaTestId: "const::const with 1 does not match true::float one is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with -2.0 matches integer and float types -> integer -2 is valid" + * + * Test ID: "const::const with -2.0 matches integer and float types::integer -2 is valid" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + -2 + """, + """ + { + "const": -2.0 + } + """, + true, + """ schemaTestId: "const::const with -2.0 matches integer and float types::integer -2 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with -2.0 matches integer and float types -> integer 2 is invalid" + * + * Test ID: "const::const with -2.0 matches integer and float types::integer 2 is invalid" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + 2 + """, + """ + { + "const": -2.0 + } + """, + false, + """ schemaTestId: "const::const with -2.0 matches integer and float types::integer 2 is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with -2.0 matches integer and float types -> float -2.0 is valid" + * + * Test ID: "const::const with -2.0 matches integer and float types::float -2.0 is valid" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + -2.0 + """, + """ + { + "const": -2.0 + } + """, + true, + """ schemaTestId: "const::const with -2.0 matches integer and float types::float -2.0 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with -2.0 matches integer and float types -> float 2.0 is invalid" + * + * Test ID: "const::const with -2.0 matches integer and float types::float 2.0 is invalid" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + 2.0 + """, + """ + { + "const": -2.0 + } + """, + false, + """ schemaTestId: "const::const with -2.0 matches integer and float types::float 2.0 is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "const with -2.0 matches integer and float types -> float -2.00001 is invalid" + * + * Test ID: "const::const with -2.0 matches integer and float types::float -2.00001 is invalid" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + -2.00001 + """, + """ + { + "const": -2.0 + } + """, + false, + """ schemaTestId: "const::const with -2.0 matches integer and float types::float -2.00001 is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "float and integers are equal up to 64-bit representation limits -> integer is valid" + * + * Test ID: "const::float and integers are equal up to 64-bit representation limits::integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + 9007199254740992 + """, + """ + { + "const": 9007199254740992 + } + """, + true, + """ schemaTestId: "const::float and integers are equal up to 64-bit representation limits::integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "float and integers are equal up to 64-bit representation limits -> integer minus one is invalid" + * + * Test ID: "const::float and integers are equal up to 64-bit representation limits::integer minus one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + 9007199254740991 + """, + """ + { + "const": 9007199254740992 + } + """, + false, + """ schemaTestId: "const::float and integers are equal up to 64-bit representation limits::integer minus one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "float and integers are equal up to 64-bit representation limits -> float is valid" + * + * Test ID: "const::float and integers are equal up to 64-bit representation limits::float is valid" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + 9.007199254740992E15 + """, + """ + { + "const": 9007199254740992 + } + """, + true, + """ schemaTestId: "const::float and integers are equal up to 64-bit representation limits::float is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "float and integers are equal up to 64-bit representation limits -> float minus one is invalid" + * + * Test ID: "const::float and integers are equal up to 64-bit representation limits::float minus one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + 9.007199254740991E15 + """, + """ + { + "const": 9007199254740992 + } + """, + false, + """ schemaTestId: "const::float and integers are equal up to 64-bit representation limits::float minus one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "nul characters in strings -> match string with nul" + * + * Test ID: "const::nul characters in strings::match string with nul" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + "hello\u0000there" + """, + """ + { + "const": "hello\u0000there" + } + """, + true, + """ schemaTestId: "const::nul characters in strings::match string with nul" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: + * "nul characters in strings -> do not match string lacking nul" + * + * Test ID: "const::nul characters in strings::do not match string lacking nul" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + "hellothere" + """, + """ + { + "const": "hello\u0000there" + } + """, + false, + """ schemaTestId: "const::nul characters in strings::do not match string lacking nul" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_contains.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_contains.kt new file mode 100644 index 00000000..f4bf04a7 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_contains.kt @@ -0,0 +1,581 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_contains : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword validation -> array with item matching schema (5) is valid" + * + * Test ID: "contains::contains keyword validation::array with item matching schema (5) is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 5 + ] + """, + """ + { + "contains": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword validation::array with item matching schema (5) is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword validation -> array with item matching schema (6) is valid" + * + * Test ID: "contains::contains keyword validation::array with item matching schema (6) is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 6 + ] + """, + """ + { + "contains": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword validation::array with item matching schema (6) is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword validation -> array with two items matching schema (5, 6) is valid" + * + * Test ID: "contains::contains keyword validation::array with two items matching schema (5, 6) is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 5, + 6 + ] + """, + """ + { + "contains": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword validation::array with two items matching schema (5, 6) is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword validation -> array without items matching schema is invalid" + * + * Test ID: "contains::contains keyword validation::array without items matching schema is invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 2, + 3, + 4 + ] + """, + """ + { + "contains": { + "minimum": 5 + } + } + """, + false, + """ schemaTestId: "contains::contains keyword validation::array without items matching schema is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword validation -> empty array is invalid" + * + * Test ID: "contains::contains keyword validation::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "contains": { + "minimum": 5 + } + } + """, + false, + """ schemaTestId: "contains::contains keyword validation::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword validation -> not array is valid" + * + * Test ID: "contains::contains keyword validation::not array is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "contains": { + "minimum": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword validation::not array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword with const keyword -> array with item 5 is valid" + * + * Test ID: "contains::contains keyword with const keyword::array with item 5 is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 5 + ] + """, + """ + { + "contains": { + "const": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword with const keyword::array with item 5 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword with const keyword -> array with two items 5 is valid" + * + * Test ID: "contains::contains keyword with const keyword::array with two items 5 is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 4, + 5, + 5 + ] + """, + """ + { + "contains": { + "const": 5 + } + } + """, + true, + """ schemaTestId: "contains::contains keyword with const keyword::array with two items 5 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword with const keyword -> array without item 5 is invalid" + * + * Test ID: "contains::contains keyword with const keyword::array without item 5 is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3, + 4 + ] + """, + """ + { + "contains": { + "const": 5 + } + } + """, + false, + """ schemaTestId: "contains::contains keyword with const keyword::array without item 5 is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword with boolean schema true -> any non-empty array is valid" + * + * Test ID: "contains::contains keyword with boolean schema true::any non-empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "contains": true + } + """, + true, + """ schemaTestId: "contains::contains keyword with boolean schema true::any non-empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword with boolean schema true -> empty array is invalid" + * + * Test ID: "contains::contains keyword with boolean schema true::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "contains": true + } + """, + false, + """ schemaTestId: "contains::contains keyword with boolean schema true::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword with boolean schema false -> any non-empty array is invalid" + * + * Test ID: "contains::contains keyword with boolean schema false::any non-empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "contains": false + } + """, + false, + """ schemaTestId: "contains::contains keyword with boolean schema false::any non-empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword with boolean schema false -> empty array is invalid" + * + * Test ID: "contains::contains keyword with boolean schema false::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "contains": false + } + """, + false, + """ schemaTestId: "contains::contains keyword with boolean schema false::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains keyword with boolean schema false -> non-arrays are valid" + * + * Test ID: "contains::contains keyword with boolean schema false::non-arrays are valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + "contains does not apply to strings" + """, + """ + { + "contains": false + } + """, + true, + """ schemaTestId: "contains::contains keyword with boolean schema false::non-arrays are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "items + contains -> matches items, does not match contains" + * + * Test ID: "contains::items + contains::matches items, does not match contains" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + 2, + 4, + 8 + ] + """, + """ + { + "items": { + "multipleOf": 2 + }, + "contains": { + "multipleOf": 3 + } + } + """, + false, + """ schemaTestId: "contains::items + contains::matches items, does not match contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "items + contains -> does not match items, matches contains" + * + * Test ID: "contains::items + contains::does not match items, matches contains" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + 3, + 6, + 9 + ] + """, + """ + { + "items": { + "multipleOf": 2 + }, + "contains": { + "multipleOf": 3 + } + } + """, + false, + """ schemaTestId: "contains::items + contains::does not match items, matches contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "items + contains -> matches both items and contains" + * + * Test ID: "contains::items + contains::matches both items and contains" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + 6, + 12 + ] + """, + """ + { + "items": { + "multipleOf": 2 + }, + "contains": { + "multipleOf": 3 + } + } + """, + true, + """ schemaTestId: "contains::items + contains::matches both items and contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "items + contains -> matches neither items nor contains" + * + * Test ID: "contains::items + contains::matches neither items nor contains" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 5 + ] + """, + """ + { + "items": { + "multipleOf": 2 + }, + "contains": { + "multipleOf": 3 + } + } + """, + false, + """ schemaTestId: "contains::items + contains::matches neither items nor contains" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains with false if subschema -> any non-empty array is valid" + * + * Test ID: "contains::contains with false if subschema::any non-empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "contains": { + "if": false, + "else": true + } + } + """, + true, + """ schemaTestId: "contains::contains with false if subschema::any non-empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains with false if subschema -> empty array is invalid" + * + * Test ID: "contains::contains with false if subschema::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "contains": { + "if": false, + "else": true + } + } + """, + false, + """ schemaTestId: "contains::contains with false if subschema::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: + * "contains with null instance elements -> allows null items" + * + * Test ID: "contains::contains with null instance elements::allows null items" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "contains": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "contains::contains with null instance elements::allows null items" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_default.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_default.kt new file mode 100644 index 00000000..0e8394a3 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_default.kt @@ -0,0 +1,225 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_default : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: + * "invalid type for default -> valid when property is specified" + * + * Test ID: "default::invalid type for default::valid when property is specified" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 13 + } + """, + """ + { + "properties": { + "foo": { + "type": "integer", + "default": [ + ] + } + } + } + """, + true, + """ schemaTestId: "default::invalid type for default::valid when property is specified" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: + * "invalid type for default -> still valid when the invalid default is used" + * + * Test ID: "default::invalid type for default::still valid when the invalid default is used" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "properties": { + "foo": { + "type": "integer", + "default": [ + ] + } + } + } + """, + true, + """ schemaTestId: "default::invalid type for default::still valid when the invalid default is used" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: + * "invalid string value for default -> valid when property is specified" + * + * Test ID: "default::invalid string value for default::valid when property is specified" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "bar": "good" + } + """, + """ + { + "properties": { + "bar": { + "type": "string", + "minLength": 4, + "default": "bad" + } + } + } + """, + true, + """ schemaTestId: "default::invalid string value for default::valid when property is specified" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: + * "invalid string value for default -> still valid when the invalid default is used" + * + * Test ID: "default::invalid string value for default::still valid when the invalid default is used" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "properties": { + "bar": { + "type": "string", + "minLength": 4, + "default": "bad" + } + } + } + """, + true, + """ schemaTestId: "default::invalid string value for default::still valid when the invalid default is used" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: + * "the default keyword does not do anything if the property is missing -> an explicit property value is checked against maximum (passing)" + * + * Test ID: "default::the default keyword does not do anything if the property is missing::an explicit property value is checked against maximum (passing)" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "alpha": 1 + } + """, + """ + { + "type": "object", + "properties": { + "alpha": { + "type": "number", + "maximum": 3, + "default": 5 + } + } + } + """, + true, + """ schemaTestId: "default::the default keyword does not do anything if the property is missing::an explicit property value is checked against maximum (passing)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: + * "the default keyword does not do anything if the property is missing -> an explicit property value is checked against maximum (failing)" + * + * Test ID: "default::the default keyword does not do anything if the property is missing::an explicit property value is checked against maximum (failing)" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "alpha": 5 + } + """, + """ + { + "type": "object", + "properties": { + "alpha": { + "type": "number", + "maximum": 3, + "default": 5 + } + } + } + """, + false, + """ schemaTestId: "default::the default keyword does not do anything if the property is missing::an explicit property value is checked against maximum (failing)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: + * "the default keyword does not do anything if the property is missing -> missing properties are not filled in with the default" + * + * Test ID: "default::the default keyword does not do anything if the property is missing::missing properties are not filled in with the default" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "object", + "properties": { + "alpha": { + "type": "number", + "maximum": 3, + "default": 5 + } + } + } + """, + true, + """ schemaTestId: "default::the default keyword does not do anything if the property is missing::missing properties are not filled in with the default" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_definitions.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_definitions.kt new file mode 100644 index 00000000..abf17dfa --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_definitions.kt @@ -0,0 +1,71 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_definitions : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/definitions.json`: + * "validate definition against metaschema -> valid definition schema" + * + * Test ID: "definitions::validate definition against metaschema::valid definition schema" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "definitions": { + "foo": { + "type": "integer" + } + } + } + """, + """ + { + "${'$'}ref": "http://json-schema.org/draft-07/schema#" + } + """, + true, + """ schemaTestId: "definitions::validate definition against metaschema::valid definition schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/definitions.json`: + * "validate definition against metaschema -> invalid definition schema" + * + * Test ID: "definitions::validate definition against metaschema::invalid definition schema" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "definitions": { + "foo": { + "type": 1 + } + } + } + """, + """ + { + "${'$'}ref": "http://json-schema.org/draft-07/schema#" + } + """, + false, + """ schemaTestId: "definitions::validate definition against metaschema::invalid definition schema" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_dependencies.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_dependencies.kt new file mode 100644 index 00000000..676f3870 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_dependencies.kt @@ -0,0 +1,1175 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_dependencies : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies -> neither" + * + * Test ID: "dependencies::dependencies::neither" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "dependencies": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies::neither" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies -> nondependant" + * + * Test ID: "dependencies::dependencies::nondependant" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "dependencies": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies::nondependant" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies -> with dependency" + * + * Test ID: "dependencies::dependencies::with dependency" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "dependencies": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies::with dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies -> missing dependency" + * + * Test ID: "dependencies::dependencies::missing dependency" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "dependencies": { + "bar": [ + "foo" + ] + } + } + """, + false, + """ schemaTestId: "dependencies::dependencies::missing dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies -> ignores arrays" + * + * Test ID: "dependencies::dependencies::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + "bar" + ] + """, + """ + { + "dependencies": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies -> ignores strings" + * + * Test ID: "dependencies::dependencies::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "dependencies": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies -> ignores other non-objects" + * + * Test ID: "dependencies::dependencies::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "dependencies": { + "bar": [ + "foo" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with empty array -> empty object" + * + * Test ID: "dependencies::dependencies with empty array::empty object" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "dependencies": { + "bar": [ + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies with empty array::empty object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with empty array -> object with one property" + * + * Test ID: "dependencies::dependencies with empty array::object with one property" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "dependencies": { + "bar": [ + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies with empty array::object with one property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with empty array -> non-object is valid" + * + * Test ID: "dependencies::dependencies with empty array::non-object is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "dependencies": { + "bar": [ + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies with empty array::non-object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies -> neither" + * + * Test ID: "dependencies::multiple dependencies::neither" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "dependencies": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::multiple dependencies::neither" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies -> nondependants" + * + * Test ID: "dependencies::multiple dependencies::nondependants" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "dependencies": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::multiple dependencies::nondependants" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies -> with dependencies" + * + * Test ID: "dependencies::multiple dependencies::with dependencies" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "quux": 3 + } + """, + """ + { + "dependencies": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::multiple dependencies::with dependencies" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies -> missing dependency" + * + * Test ID: "dependencies::multiple dependencies::missing dependency" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "quux": 2 + } + """, + """ + { + "dependencies": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + false, + """ schemaTestId: "dependencies::multiple dependencies::missing dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies -> missing other dependency" + * + * Test ID: "dependencies::multiple dependencies::missing other dependency" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "bar": 1, + "quux": 2 + } + """, + """ + { + "dependencies": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + false, + """ schemaTestId: "dependencies::multiple dependencies::missing other dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies -> missing both dependencies" + * + * Test ID: "dependencies::multiple dependencies::missing both dependencies" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "quux": 1 + } + """, + """ + { + "dependencies": { + "quux": [ + "foo", + "bar" + ] + } + } + """, + false, + """ schemaTestId: "dependencies::multiple dependencies::missing both dependencies" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies subschema -> valid" + * + * Test ID: "dependencies::multiple dependencies subschema::valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "dependencies": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "dependencies::multiple dependencies subschema::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies subschema -> no dependency" + * + * Test ID: "dependencies::multiple dependencies subschema::no dependency" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux" + } + """, + """ + { + "dependencies": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "dependencies::multiple dependencies subschema::no dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies subschema -> wrong type" + * + * Test ID: "dependencies::multiple dependencies subschema::wrong type" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "bar": 2 + } + """, + """ + { + "dependencies": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + false, + """ schemaTestId: "dependencies::multiple dependencies subschema::wrong type" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies subschema -> wrong type other" + * + * Test ID: "dependencies::multiple dependencies subschema::wrong type other" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "foo": 2, + "bar": "quux" + } + """, + """ + { + "dependencies": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + false, + """ schemaTestId: "dependencies::multiple dependencies subschema::wrong type other" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "multiple dependencies subschema -> wrong type both" + * + * Test ID: "dependencies::multiple dependencies subschema::wrong type both" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foo": "quux", + "bar": "quux" + } + """, + """ + { + "dependencies": { + "bar": { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "integer" + } + } + } + } + } + """, + false, + """ schemaTestId: "dependencies::multiple dependencies subschema::wrong type both" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with boolean subschemas -> object with property having schema true is valid" + * + * Test ID: "dependencies::dependencies with boolean subschemas::object with property having schema true is valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "dependencies": { + "foo": true, + "bar": false + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies with boolean subschemas::object with property having schema true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with boolean subschemas -> object with property having schema false is invalid" + * + * Test ID: "dependencies::dependencies with boolean subschemas::object with property having schema false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "dependencies": { + "foo": true, + "bar": false + } + } + """, + false, + """ schemaTestId: "dependencies::dependencies with boolean subschemas::object with property having schema false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with boolean subschemas -> object with both properties is invalid" + * + * Test ID: "dependencies::dependencies with boolean subschemas::object with both properties is invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "dependencies": { + "foo": true, + "bar": false + } + } + """, + false, + """ schemaTestId: "dependencies::dependencies with boolean subschemas::object with both properties is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with boolean subschemas -> empty object is valid" + * + * Test ID: "dependencies::dependencies with boolean subschemas::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "dependencies": { + "foo": true, + "bar": false + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies with boolean subschemas::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with escaped characters -> valid object 1" + * + * Test ID: "dependencies::dependencies with escaped characters::valid object 1" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": 1, + "foo\rbar": 2 + } + """, + """ + { + "dependencies": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + }, + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies with escaped characters::valid object 1" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with escaped characters -> valid object 2" + * + * Test ID: "dependencies::dependencies with escaped characters::valid object 2" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + { + "foo\tbar": 1, + "a": 2, + "b": 3, + "c": 4 + } + """, + """ + { + "dependencies": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + }, + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies with escaped characters::valid object 2" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with escaped characters -> valid object 3" + * + * Test ID: "dependencies::dependencies with escaped characters::valid object 3" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + { + "foo'bar": 1, + "foo\"bar": 2 + } + """, + """ + { + "dependencies": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + }, + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + true, + """ schemaTestId: "dependencies::dependencies with escaped characters::valid object 3" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with escaped characters -> invalid object 1" + * + * Test ID: "dependencies::dependencies with escaped characters::invalid object 1" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": 1, + "foo": 2 + } + """, + """ + { + "dependencies": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + }, + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + false, + """ schemaTestId: "dependencies::dependencies with escaped characters::invalid object 1" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with escaped characters -> invalid object 2" + * + * Test ID: "dependencies::dependencies with escaped characters::invalid object 2" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + { + "foo\tbar": 1, + "a": 2 + } + """, + """ + { + "dependencies": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + }, + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + false, + """ schemaTestId: "dependencies::dependencies with escaped characters::invalid object 2" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with escaped characters -> invalid object 3" + * + * Test ID: "dependencies::dependencies with escaped characters::invalid object 3" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + { + "foo'bar": 1 + } + """, + """ + { + "dependencies": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + }, + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + false, + """ schemaTestId: "dependencies::dependencies with escaped characters::invalid object 3" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependencies with escaped characters -> invalid object 4" + * + * Test ID: "dependencies::dependencies with escaped characters::invalid object 4" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + { + "foo\"bar": 2 + } + """, + """ + { + "dependencies": { + "foo\nbar": [ + "foo\rbar" + ], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": { + "required": [ + "foo\"bar" + ] + }, + "foo\"bar": [ + "foo'bar" + ] + } + } + """, + false, + """ schemaTestId: "dependencies::dependencies with escaped characters::invalid object 4" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependent subschema incompatible with root -> matches root" + * + * Test ID: "dependencies::dependent subschema incompatible with root::matches root" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "properties": { + "foo": { + } + }, + "dependencies": { + "foo": { + "properties": { + "bar": { + } + }, + "additionalProperties": false + } + } + } + """, + false, + """ schemaTestId: "dependencies::dependent subschema incompatible with root::matches root" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependent subschema incompatible with root -> matches dependency" + * + * Test ID: "dependencies::dependent subschema incompatible with root::matches dependency" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "properties": { + "foo": { + } + }, + "dependencies": { + "foo": { + "properties": { + "bar": { + } + }, + "additionalProperties": false + } + } + } + """, + true, + """ schemaTestId: "dependencies::dependent subschema incompatible with root::matches dependency" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependent subschema incompatible with root -> matches both" + * + * Test ID: "dependencies::dependent subschema incompatible with root::matches both" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "properties": { + "foo": { + } + }, + "dependencies": { + "foo": { + "properties": { + "bar": { + } + }, + "additionalProperties": false + } + } + } + """, + false, + """ schemaTestId: "dependencies::dependent subschema incompatible with root::matches both" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: + * "dependent subschema incompatible with root -> no dependency" + * + * Test ID: "dependencies::dependent subschema incompatible with root::no dependency" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + { + "baz": 1 + } + """, + """ + { + "properties": { + "foo": { + } + }, + "dependencies": { + "foo": { + "properties": { + "bar": { + } + }, + "additionalProperties": false + } + } + } + """, + true, + """ schemaTestId: "dependencies::dependent subschema incompatible with root::no dependency" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_enum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_enum.kt new file mode 100644 index 00000000..80b22e6f --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_enum.kt @@ -0,0 +1,1288 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_enum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "simple enum validation -> one of the enum is valid" + * + * Test ID: "enum::simple enum validation::one of the enum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "enum": [ + 1, + 2, + 3 + ] + } + """, + true, + """ schemaTestId: "enum::simple enum validation::one of the enum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "simple enum validation -> something else is invalid" + * + * Test ID: "enum::simple enum validation::something else is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 4 + """, + """ + { + "enum": [ + 1, + 2, + 3 + ] + } + """, + false, + """ schemaTestId: "enum::simple enum validation::something else is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "heterogeneous enum validation -> one of the enum is valid" + * + * Test ID: "enum::heterogeneous enum validation::one of the enum is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + true, + """ schemaTestId: "enum::heterogeneous enum validation::one of the enum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "heterogeneous enum validation -> something else is invalid" + * + * Test ID: "enum::heterogeneous enum validation::something else is invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + false, + """ schemaTestId: "enum::heterogeneous enum validation::something else is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "heterogeneous enum validation -> objects are deep compared" + * + * Test ID: "enum::heterogeneous enum validation::objects are deep compared" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "foo": false + } + """, + """ + { + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + false, + """ schemaTestId: "enum::heterogeneous enum validation::objects are deep compared" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "heterogeneous enum validation -> valid object matches" + * + * Test ID: "enum::heterogeneous enum validation::valid object matches" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + true, + """ schemaTestId: "enum::heterogeneous enum validation::valid object matches" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "heterogeneous enum validation -> extra properties in object is invalid" + * + * Test ID: "enum::heterogeneous enum validation::extra properties in object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12, + "boo": 42 + } + """, + """ + { + "enum": [ + 6, + "foo", + [ + ], + true, + { + "foo": 12 + } + ] + } + """, + false, + """ schemaTestId: "enum::heterogeneous enum validation::extra properties in object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "heterogeneous enum-with-null validation -> null is valid" + * + * Test ID: "enum::heterogeneous enum-with-null validation::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "enum": [ + 6, + null + ] + } + """, + true, + """ schemaTestId: "enum::heterogeneous enum-with-null validation::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "heterogeneous enum-with-null validation -> number is valid" + * + * Test ID: "enum::heterogeneous enum-with-null validation::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + 6 + """, + """ + { + "enum": [ + 6, + null + ] + } + """, + true, + """ schemaTestId: "enum::heterogeneous enum-with-null validation::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "heterogeneous enum-with-null validation -> something else is invalid" + * + * Test ID: "enum::heterogeneous enum-with-null validation::something else is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + "test" + """, + """ + { + "enum": [ + 6, + null + ] + } + """, + false, + """ schemaTestId: "enum::heterogeneous enum-with-null validation::something else is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enums in properties -> both properties are valid" + * + * Test ID: "enum::enums in properties::both properties are valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bar" + } + """, + """ + { + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + true, + """ schemaTestId: "enum::enums in properties::both properties are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enums in properties -> wrong foo value" + * + * Test ID: "enum::enums in properties::wrong foo value" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foot", + "bar": "bar" + } + """, + """ + { + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + false, + """ schemaTestId: "enum::enums in properties::wrong foo value" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enums in properties -> wrong bar value" + * + * Test ID: "enum::enums in properties::wrong bar value" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": "bart" + } + """, + """ + { + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + false, + """ schemaTestId: "enum::enums in properties::wrong bar value" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enums in properties -> missing optional property is valid" + * + * Test ID: "enum::enums in properties::missing optional property is valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "bar": "bar" + } + """, + """ + { + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + true, + """ schemaTestId: "enum::enums in properties::missing optional property is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enums in properties -> missing required property is invalid" + * + * Test ID: "enum::enums in properties::missing required property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + false, + """ schemaTestId: "enum::enums in properties::missing required property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enums in properties -> missing all properties is invalid" + * + * Test ID: "enum::enums in properties::missing all properties is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "object", + "properties": { + "foo": { + "enum": [ + "foo" + ] + }, + "bar": { + "enum": [ + "bar" + ] + } + }, + "required": [ + "bar" + ] + } + """, + false, + """ schemaTestId: "enum::enums in properties::missing all properties is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with escaped characters -> member 1 is valid" + * + * Test ID: "enum::enum with escaped characters::member 1 is valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + "foo\nbar" + """, + """ + { + "enum": [ + "foo\nbar", + "foo\rbar" + ] + } + """, + true, + """ schemaTestId: "enum::enum with escaped characters::member 1 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with escaped characters -> member 2 is valid" + * + * Test ID: "enum::enum with escaped characters::member 2 is valid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + "foo\rbar" + """, + """ + { + "enum": [ + "foo\nbar", + "foo\rbar" + ] + } + """, + true, + """ schemaTestId: "enum::enum with escaped characters::member 2 is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with escaped characters -> another string is invalid" + * + * Test ID: "enum::enum with escaped characters::another string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + "abc" + """, + """ + { + "enum": [ + "foo\nbar", + "foo\rbar" + ] + } + """, + false, + """ schemaTestId: "enum::enum with escaped characters::another string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with false does not match 0 -> false is valid" + * + * Test ID: "enum::enum with false does not match 0::false is valid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "enum": [ + false + ] + } + """, + true, + """ schemaTestId: "enum::enum with false does not match 0::false is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with false does not match 0 -> integer zero is invalid" + * + * Test ID: "enum::enum with false does not match 0::integer zero is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "enum": [ + false + ] + } + """, + false, + """ schemaTestId: "enum::enum with false does not match 0::integer zero is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with false does not match 0 -> float zero is invalid" + * + * Test ID: "enum::enum with false does not match 0::float zero is invalid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + 0.0 + """, + """ + { + "enum": [ + false + ] + } + """, + false, + """ schemaTestId: "enum::enum with false does not match 0::float zero is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [false] does not match [0] -> [false] is valid" + * + * Test ID: "enum::enum with [false] does not match [0]::[false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + [ + false + ] + """, + """ + { + "enum": [ + [ + false + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [false] does not match [0]::[false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [false] does not match [0] -> [0] is invalid" + * + * Test ID: "enum::enum with [false] does not match [0]::[0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + [ + 0 + ] + """, + """ + { + "enum": [ + [ + false + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [false] does not match [0]::[0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [false] does not match [0] -> [0.0] is invalid" + * + * Test ID: "enum::enum with [false] does not match [0]::[0.0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + 0.0 + ] + """, + """ + { + "enum": [ + [ + false + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [false] does not match [0]::[0.0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with true does not match 1 -> true is valid" + * + * Test ID: "enum::enum with true does not match 1::true is valid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "enum": [ + true + ] + } + """, + true, + """ schemaTestId: "enum::enum with true does not match 1::true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with true does not match 1 -> integer one is invalid" + * + * Test ID: "enum::enum with true does not match 1::integer one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "enum": [ + true + ] + } + """, + false, + """ schemaTestId: "enum::enum with true does not match 1::integer one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with true does not match 1 -> float one is invalid" + * + * Test ID: "enum::enum with true does not match 1::float one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "enum": [ + true + ] + } + """, + false, + """ schemaTestId: "enum::enum with true does not match 1::float one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [true] does not match [1] -> [true] is valid" + * + * Test ID: "enum::enum with [true] does not match [1]::[true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + [ + true + ] + """, + """ + { + "enum": [ + [ + true + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [true] does not match [1]::[true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [true] does not match [1] -> [1] is invalid" + * + * Test ID: "enum::enum with [true] does not match [1]::[1] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "enum": [ + [ + true + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [true] does not match [1]::[1] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [true] does not match [1] -> [1.0] is invalid" + * + * Test ID: "enum::enum with [true] does not match [1]::[1.0] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + [ + 1.0 + ] + """, + """ + { + "enum": [ + [ + true + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [true] does not match [1]::[1.0] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with 0 does not match false -> false is invalid" + * + * Test ID: "enum::enum with 0 does not match false::false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "enum": [ + 0 + ] + } + """, + false, + """ schemaTestId: "enum::enum with 0 does not match false::false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with 0 does not match false -> integer zero is valid" + * + * Test ID: "enum::enum with 0 does not match false::integer zero is valid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "enum": [ + 0 + ] + } + """, + true, + """ schemaTestId: "enum::enum with 0 does not match false::integer zero is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with 0 does not match false -> float zero is valid" + * + * Test ID: "enum::enum with 0 does not match false::float zero is valid" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + 0.0 + """, + """ + { + "enum": [ + 0 + ] + } + """, + true, + """ schemaTestId: "enum::enum with 0 does not match false::float zero is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [0] does not match [false] -> [false] is invalid" + * + * Test ID: "enum::enum with [0] does not match [false]::[false] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + [ + false + ] + """, + """ + { + "enum": [ + [ + 0 + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [0] does not match [false]::[false] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [0] does not match [false] -> [0] is valid" + * + * Test ID: "enum::enum with [0] does not match [false]::[0] is valid" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + [ + 0 + ] + """, + """ + { + "enum": [ + [ + 0 + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [0] does not match [false]::[0] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [0] does not match [false] -> [0.0] is valid" + * + * Test ID: "enum::enum with [0] does not match [false]::[0.0] is valid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + [ + 0.0 + ] + """, + """ + { + "enum": [ + [ + 0 + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [0] does not match [false]::[0.0] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with 1 does not match true -> true is invalid" + * + * Test ID: "enum::enum with 1 does not match true::true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "enum": [ + 1 + ] + } + """, + false, + """ schemaTestId: "enum::enum with 1 does not match true::true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with 1 does not match true -> integer one is valid" + * + * Test ID: "enum::enum with 1 does not match true::integer one is valid" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "enum": [ + 1 + ] + } + """, + true, + """ schemaTestId: "enum::enum with 1 does not match true::integer one is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with 1 does not match true -> float one is valid" + * + * Test ID: "enum::enum with 1 does not match true::float one is valid" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "enum": [ + 1 + ] + } + """, + true, + """ schemaTestId: "enum::enum with 1 does not match true::float one is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [1] does not match [true] -> [true] is invalid" + * + * Test ID: "enum::enum with [1] does not match [true]::[true] is invalid" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + [ + true + ] + """, + """ + { + "enum": [ + [ + 1 + ] + ] + } + """, + false, + """ schemaTestId: "enum::enum with [1] does not match [true]::[true] is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [1] does not match [true] -> [1] is valid" + * + * Test ID: "enum::enum with [1] does not match [true]::[1] is valid" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "enum": [ + [ + 1 + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [1] does not match [true]::[1] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "enum with [1] does not match [true] -> [1.0] is valid" + * + * Test ID: "enum::enum with [1] does not match [true]::[1.0] is valid" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + [ + 1.0 + ] + """, + """ + { + "enum": [ + [ + 1 + ] + ] + } + """, + true, + """ schemaTestId: "enum::enum with [1] does not match [true]::[1.0] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "nul characters in strings -> match string with nul" + * + * Test ID: "enum::nul characters in strings::match string with nul" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + "hello\u0000there" + """, + """ + { + "enum": [ + "hello\u0000there" + ] + } + """, + true, + """ schemaTestId: "enum::nul characters in strings::match string with nul" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: + * "nul characters in strings -> do not match string lacking nul" + * + * Test ID: "enum::nul characters in strings::do not match string lacking nul" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + "hellothere" + """, + """ + { + "enum": [ + "hello\u0000there" + ] + } + """, + false, + """ schemaTestId: "enum::nul characters in strings::do not match string lacking nul" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_exclusiveMaximum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_exclusiveMaximum.kt new file mode 100644 index 00000000..80a17473 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_exclusiveMaximum.kt @@ -0,0 +1,103 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_exclusiveMaximum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json`: + * "exclusiveMaximum validation -> below the exclusiveMaximum is valid" + * + * Test ID: "exclusiveMaximum::exclusiveMaximum validation::below the exclusiveMaximum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 2.2 + """, + """ + { + "exclusiveMaximum": 3.0 + } + """, + true, + """ schemaTestId: "exclusiveMaximum::exclusiveMaximum validation::below the exclusiveMaximum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json`: + * "exclusiveMaximum validation -> boundary point is invalid" + * + * Test ID: "exclusiveMaximum::exclusiveMaximum validation::boundary point is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 3.0 + """, + """ + { + "exclusiveMaximum": 3.0 + } + """, + false, + """ schemaTestId: "exclusiveMaximum::exclusiveMaximum validation::boundary point is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json`: + * "exclusiveMaximum validation -> above the exclusiveMaximum is invalid" + * + * Test ID: "exclusiveMaximum::exclusiveMaximum validation::above the exclusiveMaximum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 3.5 + """, + """ + { + "exclusiveMaximum": 3.0 + } + """, + false, + """ schemaTestId: "exclusiveMaximum::exclusiveMaximum validation::above the exclusiveMaximum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json`: + * "exclusiveMaximum validation -> ignores non-numbers" + * + * Test ID: "exclusiveMaximum::exclusiveMaximum validation::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "exclusiveMaximum": 3.0 + } + """, + true, + """ schemaTestId: "exclusiveMaximum::exclusiveMaximum validation::ignores non-numbers" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_exclusiveMinimum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_exclusiveMinimum.kt new file mode 100644 index 00000000..6fe39f52 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_exclusiveMinimum.kt @@ -0,0 +1,103 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_exclusiveMinimum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json`: + * "exclusiveMinimum validation -> above the exclusiveMinimum is valid" + * + * Test ID: "exclusiveMinimum::exclusiveMinimum validation::above the exclusiveMinimum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1.2 + """, + """ + { + "exclusiveMinimum": 1.1 + } + """, + true, + """ schemaTestId: "exclusiveMinimum::exclusiveMinimum validation::above the exclusiveMinimum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json`: + * "exclusiveMinimum validation -> boundary point is invalid" + * + * Test ID: "exclusiveMinimum::exclusiveMinimum validation::boundary point is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "exclusiveMinimum": 1.1 + } + """, + false, + """ schemaTestId: "exclusiveMinimum::exclusiveMinimum validation::boundary point is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json`: + * "exclusiveMinimum validation -> below the exclusiveMinimum is invalid" + * + * Test ID: "exclusiveMinimum::exclusiveMinimum validation::below the exclusiveMinimum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 0.6 + """, + """ + { + "exclusiveMinimum": 1.1 + } + """, + false, + """ schemaTestId: "exclusiveMinimum::exclusiveMinimum validation::below the exclusiveMinimum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json`: + * "exclusiveMinimum validation -> ignores non-numbers" + * + * Test ID: "exclusiveMinimum::exclusiveMinimum validation::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "exclusiveMinimum": 1.1 + } + """, + true, + """ schemaTestId: "exclusiveMinimum::exclusiveMinimum validation::ignores non-numbers" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_format.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_format.kt new file mode 100644 index 00000000..c13b6759 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_format.kt @@ -0,0 +1,2293 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_format : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "email format -> all string formats ignore integers" + * + * Test ID: "format::email format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "email format -> all string formats ignore floats" + * + * Test ID: "format::email format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "email format -> all string formats ignore objects" + * + * Test ID: "format::email format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "email format -> all string formats ignore arrays" + * + * Test ID: "format::email format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "email format -> all string formats ignore booleans" + * + * Test ID: "format::email format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "email format -> all string formats ignore nulls" + * + * Test ID: "format::email format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "email" + } + """, + true, + """ schemaTestId: "format::email format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-email format -> all string formats ignore integers" + * + * Test ID: "format::idn-email format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-email format -> all string formats ignore floats" + * + * Test ID: "format::idn-email format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-email format -> all string formats ignore objects" + * + * Test ID: "format::idn-email format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-email format -> all string formats ignore arrays" + * + * Test ID: "format::idn-email format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-email format -> all string formats ignore booleans" + * + * Test ID: "format::idn-email format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-email format -> all string formats ignore nulls" + * + * Test ID: "format::idn-email format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "idn-email" + } + """, + true, + """ schemaTestId: "format::idn-email format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "regex format -> all string formats ignore integers" + * + * Test ID: "format::regex format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "regex format -> all string formats ignore floats" + * + * Test ID: "format::regex format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "regex format -> all string formats ignore objects" + * + * Test ID: "format::regex format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "regex format -> all string formats ignore arrays" + * + * Test ID: "format::regex format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "regex format -> all string formats ignore booleans" + * + * Test ID: "format::regex format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "regex format -> all string formats ignore nulls" + * + * Test ID: "format::regex format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "regex" + } + """, + true, + """ schemaTestId: "format::regex format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv4 format -> all string formats ignore integers" + * + * Test ID: "format::ipv4 format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv4 format -> all string formats ignore floats" + * + * Test ID: "format::ipv4 format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv4 format -> all string formats ignore objects" + * + * Test ID: "format::ipv4 format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv4 format -> all string formats ignore arrays" + * + * Test ID: "format::ipv4 format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv4 format -> all string formats ignore booleans" + * + * Test ID: "format::ipv4 format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv4 format -> all string formats ignore nulls" + * + * Test ID: "format::ipv4 format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "ipv4" + } + """, + true, + """ schemaTestId: "format::ipv4 format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv6 format -> all string formats ignore integers" + * + * Test ID: "format::ipv6 format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv6 format -> all string formats ignore floats" + * + * Test ID: "format::ipv6 format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv6 format -> all string formats ignore objects" + * + * Test ID: "format::ipv6 format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv6 format -> all string formats ignore arrays" + * + * Test ID: "format::ipv6 format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv6 format -> all string formats ignore booleans" + * + * Test ID: "format::ipv6 format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "ipv6 format -> all string formats ignore nulls" + * + * Test ID: "format::ipv6 format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "ipv6" + } + """, + true, + """ schemaTestId: "format::ipv6 format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-hostname format -> all string formats ignore integers" + * + * Test ID: "format::idn-hostname format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-hostname format -> all string formats ignore floats" + * + * Test ID: "format::idn-hostname format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-hostname format -> all string formats ignore objects" + * + * Test ID: "format::idn-hostname format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-hostname format -> all string formats ignore arrays" + * + * Test ID: "format::idn-hostname format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-hostname format -> all string formats ignore booleans" + * + * Test ID: "format::idn-hostname format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "idn-hostname format -> all string formats ignore nulls" + * + * Test ID: "format::idn-hostname format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "idn-hostname" + } + """, + true, + """ schemaTestId: "format::idn-hostname format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "hostname format -> all string formats ignore integers" + * + * Test ID: "format::hostname format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "hostname format -> all string formats ignore floats" + * + * Test ID: "format::hostname format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "hostname format -> all string formats ignore objects" + * + * Test ID: "format::hostname format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "hostname format -> all string formats ignore arrays" + * + * Test ID: "format::hostname format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "hostname format -> all string formats ignore booleans" + * + * Test ID: "format::hostname format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "hostname format -> all string formats ignore nulls" + * + * Test ID: "format::hostname format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "hostname" + } + """, + true, + """ schemaTestId: "format::hostname format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date format -> all string formats ignore integers" + * + * Test ID: "format::date format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date format -> all string formats ignore floats" + * + * Test ID: "format::date format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date format -> all string formats ignore objects" + * + * Test ID: "format::date format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date format -> all string formats ignore arrays" + * + * Test ID: "format::date format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date format -> all string formats ignore booleans" + * + * Test ID: "format::date format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date format -> all string formats ignore nulls" + * + * Test ID: "format::date format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "date" + } + """, + true, + """ schemaTestId: "format::date format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date-time format -> all string formats ignore integers" + * + * Test ID: "format::date-time format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date-time format -> all string formats ignore floats" + * + * Test ID: "format::date-time format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date-time format -> all string formats ignore objects" + * + * Test ID: "format::date-time format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date-time format -> all string formats ignore arrays" + * + * Test ID: "format::date-time format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date-time format -> all string formats ignore booleans" + * + * Test ID: "format::date-time format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "date-time format -> all string formats ignore nulls" + * + * Test ID: "format::date-time format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "date-time" + } + """, + true, + """ schemaTestId: "format::date-time format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "time format -> all string formats ignore integers" + * + * Test ID: "format::time format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "time format -> all string formats ignore floats" + * + * Test ID: "format::time format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "time format -> all string formats ignore objects" + * + * Test ID: "format::time format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_57() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "time format -> all string formats ignore arrays" + * + * Test ID: "format::time format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "time format -> all string formats ignore booleans" + * + * Test ID: "format::time format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "time format -> all string formats ignore nulls" + * + * Test ID: "format::time format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_60() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "time" + } + """, + true, + """ schemaTestId: "format::time format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "json-pointer format -> all string formats ignore integers" + * + * Test ID: "format::json-pointer format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_61() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "json-pointer format -> all string formats ignore floats" + * + * Test ID: "format::json-pointer format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "json-pointer format -> all string formats ignore objects" + * + * Test ID: "format::json-pointer format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_63() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "json-pointer format -> all string formats ignore arrays" + * + * Test ID: "format::json-pointer format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_64() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "json-pointer format -> all string formats ignore booleans" + * + * Test ID: "format::json-pointer format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_65() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "json-pointer format -> all string formats ignore nulls" + * + * Test ID: "format::json-pointer format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_66() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "json-pointer" + } + """, + true, + """ schemaTestId: "format::json-pointer format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "relative-json-pointer format -> all string formats ignore integers" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_67() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "relative-json-pointer format -> all string formats ignore floats" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_68() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "relative-json-pointer format -> all string formats ignore objects" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_69() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "relative-json-pointer format -> all string formats ignore arrays" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_70() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "relative-json-pointer format -> all string formats ignore booleans" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_71() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "relative-json-pointer format -> all string formats ignore nulls" + * + * Test ID: "format::relative-json-pointer format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_72() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "relative-json-pointer" + } + """, + true, + """ schemaTestId: "format::relative-json-pointer format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri format -> all string formats ignore integers" + * + * Test ID: "format::iri format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_73() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri format -> all string formats ignore floats" + * + * Test ID: "format::iri format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_74() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri format -> all string formats ignore objects" + * + * Test ID: "format::iri format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_75() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri format -> all string formats ignore arrays" + * + * Test ID: "format::iri format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_76() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri format -> all string formats ignore booleans" + * + * Test ID: "format::iri format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_77() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri format -> all string formats ignore nulls" + * + * Test ID: "format::iri format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_78() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "iri" + } + """, + true, + """ schemaTestId: "format::iri format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri-reference format -> all string formats ignore integers" + * + * Test ID: "format::iri-reference format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_79() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri-reference format -> all string formats ignore floats" + * + * Test ID: "format::iri-reference format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_80() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri-reference format -> all string formats ignore objects" + * + * Test ID: "format::iri-reference format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_81() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri-reference format -> all string formats ignore arrays" + * + * Test ID: "format::iri-reference format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_82() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri-reference format -> all string formats ignore booleans" + * + * Test ID: "format::iri-reference format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_83() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "iri-reference format -> all string formats ignore nulls" + * + * Test ID: "format::iri-reference format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_84() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "iri-reference" + } + """, + true, + """ schemaTestId: "format::iri-reference format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri format -> all string formats ignore integers" + * + * Test ID: "format::uri format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_85() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri format -> all string formats ignore floats" + * + * Test ID: "format::uri format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_86() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri format -> all string formats ignore objects" + * + * Test ID: "format::uri format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_87() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri format -> all string formats ignore arrays" + * + * Test ID: "format::uri format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_88() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri format -> all string formats ignore booleans" + * + * Test ID: "format::uri format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_89() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri format -> all string formats ignore nulls" + * + * Test ID: "format::uri format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_90() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "uri" + } + """, + true, + """ schemaTestId: "format::uri format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-reference format -> all string formats ignore integers" + * + * Test ID: "format::uri-reference format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_91() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-reference format -> all string formats ignore floats" + * + * Test ID: "format::uri-reference format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_92() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-reference format -> all string formats ignore objects" + * + * Test ID: "format::uri-reference format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_93() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-reference format -> all string formats ignore arrays" + * + * Test ID: "format::uri-reference format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_94() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-reference format -> all string formats ignore booleans" + * + * Test ID: "format::uri-reference format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_95() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-reference format -> all string formats ignore nulls" + * + * Test ID: "format::uri-reference format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_96() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "uri-reference" + } + """, + true, + """ schemaTestId: "format::uri-reference format::all string formats ignore nulls" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-template format -> all string formats ignore integers" + * + * Test ID: "format::uri-template format::all string formats ignore integers" + */ + @Test + fun jsonSchemaSuiteTest_97() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-template format -> all string formats ignore floats" + * + * Test ID: "format::uri-template format::all string formats ignore floats" + */ + @Test + fun jsonSchemaSuiteTest_98() { + + assertKsonEnforcesSchema( + """ + 13.7 + """, + """ + { + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-template format -> all string formats ignore objects" + * + * Test ID: "format::uri-template format::all string formats ignore objects" + */ + @Test + fun jsonSchemaSuiteTest_99() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-template format -> all string formats ignore arrays" + * + * Test ID: "format::uri-template format::all string formats ignore arrays" + */ + @Test + fun jsonSchemaSuiteTest_100() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-template format -> all string formats ignore booleans" + * + * Test ID: "format::uri-template format::all string formats ignore booleans" + */ + @Test + fun jsonSchemaSuiteTest_101() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: + * "uri-template format -> all string formats ignore nulls" + * + * Test ID: "format::uri-template format::all string formats ignore nulls" + */ + @Test + fun jsonSchemaSuiteTest_102() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "format": "uri-template" + } + """, + true, + """ schemaTestId: "format::uri-template format::all string formats ignore nulls" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_if_then_else.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_if_then_else.kt new file mode 100644 index 00000000..d65af459 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_if_then_else.kt @@ -0,0 +1,749 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_if_then_else : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "ignore if without then or else -> valid when valid against lone if" + * + * Test ID: "if-then-else::ignore if without then or else::valid when valid against lone if" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "if": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore if without then or else::valid when valid against lone if" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "ignore if without then or else -> valid when invalid against lone if" + * + * Test ID: "if-then-else::ignore if without then or else::valid when invalid against lone if" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "hello" + """, + """ + { + "if": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore if without then or else::valid when invalid against lone if" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "ignore then without if -> valid when valid against lone then" + * + * Test ID: "if-then-else::ignore then without if::valid when valid against lone then" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "then": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore then without if::valid when valid against lone then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "ignore then without if -> valid when invalid against lone then" + * + * Test ID: "if-then-else::ignore then without if::valid when invalid against lone then" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "hello" + """, + """ + { + "then": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore then without if::valid when invalid against lone then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "ignore else without if -> valid when valid against lone else" + * + * Test ID: "if-then-else::ignore else without if::valid when valid against lone else" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "else": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore else without if::valid when valid against lone else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "ignore else without if -> valid when invalid against lone else" + * + * Test ID: "if-then-else::ignore else without if::valid when invalid against lone else" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "hello" + """, + """ + { + "else": { + "const": 0 + } + } + """, + true, + """ schemaTestId: "if-then-else::ignore else without if::valid when invalid against lone else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if and then without else -> valid through then" + * + * Test ID: "if-then-else::if and then without else::valid through then" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + -1 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + } + } + """, + true, + """ schemaTestId: "if-then-else::if and then without else::valid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if and then without else -> invalid through then" + * + * Test ID: "if-then-else::if and then without else::invalid through then" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + -100 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + } + } + """, + false, + """ schemaTestId: "if-then-else::if and then without else::invalid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if and then without else -> valid when if test fails" + * + * Test ID: "if-then-else::if and then without else::valid when if test fails" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + } + } + """, + true, + """ schemaTestId: "if-then-else::if and then without else::valid when if test fails" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if and else without then -> valid when if test passes" + * + * Test ID: "if-then-else::if and else without then::valid when if test passes" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + -1 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "else": { + "multipleOf": 2 + } + } + """, + true, + """ schemaTestId: "if-then-else::if and else without then::valid when if test passes" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if and else without then -> valid through else" + * + * Test ID: "if-then-else::if and else without then::valid through else" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + 4 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "else": { + "multipleOf": 2 + } + } + """, + true, + """ schemaTestId: "if-then-else::if and else without then::valid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if and else without then -> invalid through else" + * + * Test ID: "if-then-else::if and else without then::invalid through else" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "else": { + "multipleOf": 2 + } + } + """, + false, + """ schemaTestId: "if-then-else::if and else without then::invalid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "validate against correct branch, then vs else -> valid through then" + * + * Test ID: "if-then-else::validate against correct branch, then vs else::valid through then" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + -1 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + }, + "else": { + "multipleOf": 2 + } + } + """, + true, + """ schemaTestId: "if-then-else::validate against correct branch, then vs else::valid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "validate against correct branch, then vs else -> invalid through then" + * + * Test ID: "if-then-else::validate against correct branch, then vs else::invalid through then" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + -100 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + }, + "else": { + "multipleOf": 2 + } + } + """, + false, + """ schemaTestId: "if-then-else::validate against correct branch, then vs else::invalid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "validate against correct branch, then vs else -> valid through else" + * + * Test ID: "if-then-else::validate against correct branch, then vs else::valid through else" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 4 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + }, + "else": { + "multipleOf": 2 + } + } + """, + true, + """ schemaTestId: "if-then-else::validate against correct branch, then vs else::valid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "validate against correct branch, then vs else -> invalid through else" + * + * Test ID: "if-then-else::validate against correct branch, then vs else::invalid through else" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "if": { + "exclusiveMaximum": 0 + }, + "then": { + "minimum": -10 + }, + "else": { + "multipleOf": 2 + } + } + """, + false, + """ schemaTestId: "if-then-else::validate against correct branch, then vs else::invalid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "non-interference across combined schemas -> valid, but would have been invalid through then" + * + * Test ID: "if-then-else::non-interference across combined schemas::valid, but would have been invalid through then" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + -100 + """, + """ + { + "allOf": [ + { + "if": { + "exclusiveMaximum": 0 + } + }, + { + "then": { + "minimum": -10 + } + }, + { + "else": { + "multipleOf": 2 + } + } + ] + } + """, + true, + """ schemaTestId: "if-then-else::non-interference across combined schemas::valid, but would have been invalid through then" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "non-interference across combined schemas -> valid, but would have been invalid through else" + * + * Test ID: "if-then-else::non-interference across combined schemas::valid, but would have been invalid through else" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "allOf": [ + { + "if": { + "exclusiveMaximum": 0 + } + }, + { + "then": { + "minimum": -10 + } + }, + { + "else": { + "multipleOf": 2 + } + } + ] + } + """, + true, + """ schemaTestId: "if-then-else::non-interference across combined schemas::valid, but would have been invalid through else" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if with boolean schema true -> boolean schema true in if always chooses the then path (valid)" + * + * Test ID: "if-then-else::if with boolean schema true::boolean schema true in if always chooses the then path (valid)" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + "then" + """, + """ + { + "if": true, + "then": { + "const": "then" + }, + "else": { + "const": "else" + } + } + """, + true, + """ schemaTestId: "if-then-else::if with boolean schema true::boolean schema true in if always chooses the then path (valid)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if with boolean schema true -> boolean schema true in if always chooses the then path (invalid)" + * + * Test ID: "if-then-else::if with boolean schema true::boolean schema true in if always chooses the then path (invalid)" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + "else" + """, + """ + { + "if": true, + "then": { + "const": "then" + }, + "else": { + "const": "else" + } + } + """, + false, + """ schemaTestId: "if-then-else::if with boolean schema true::boolean schema true in if always chooses the then path (invalid)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if with boolean schema false -> boolean schema false in if always chooses the else path (invalid)" + * + * Test ID: "if-then-else::if with boolean schema false::boolean schema false in if always chooses the else path (invalid)" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + "then" + """, + """ + { + "if": false, + "then": { + "const": "then" + }, + "else": { + "const": "else" + } + } + """, + false, + """ schemaTestId: "if-then-else::if with boolean schema false::boolean schema false in if always chooses the else path (invalid)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if with boolean schema false -> boolean schema false in if always chooses the else path (valid)" + * + * Test ID: "if-then-else::if with boolean schema false::boolean schema false in if always chooses the else path (valid)" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + "else" + """, + """ + { + "if": false, + "then": { + "const": "then" + }, + "else": { + "const": "else" + } + } + """, + true, + """ schemaTestId: "if-then-else::if with boolean schema false::boolean schema false in if always chooses the else path (valid)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if appears at the end when serialized (keyword processing sequence) -> yes redirects to then and passes" + * + * Test ID: "if-then-else::if appears at the end when serialized (keyword processing sequence)::yes redirects to then and passes" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + "yes" + """, + """ + { + "then": { + "const": "yes" + }, + "else": { + "const": "other" + }, + "if": { + "maxLength": 4 + } + } + """, + true, + """ schemaTestId: "if-then-else::if appears at the end when serialized (keyword processing sequence)::yes redirects to then and passes" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if appears at the end when serialized (keyword processing sequence) -> other redirects to else and passes" + * + * Test ID: "if-then-else::if appears at the end when serialized (keyword processing sequence)::other redirects to else and passes" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + "other" + """, + """ + { + "then": { + "const": "yes" + }, + "else": { + "const": "other" + }, + "if": { + "maxLength": 4 + } + } + """, + true, + """ schemaTestId: "if-then-else::if appears at the end when serialized (keyword processing sequence)::other redirects to else and passes" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if appears at the end when serialized (keyword processing sequence) -> no redirects to then and fails" + * + * Test ID: "if-then-else::if appears at the end when serialized (keyword processing sequence)::no redirects to then and fails" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + "no" + """, + """ + { + "then": { + "const": "yes" + }, + "else": { + "const": "other" + }, + "if": { + "maxLength": 4 + } + } + """, + false, + """ schemaTestId: "if-then-else::if appears at the end when serialized (keyword processing sequence)::no redirects to then and fails" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: + * "if appears at the end when serialized (keyword processing sequence) -> invalid redirects to else and fails" + * + * Test ID: "if-then-else::if appears at the end when serialized (keyword processing sequence)::invalid redirects to else and fails" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + "invalid" + """, + """ + { + "then": { + "const": "yes" + }, + "else": { + "const": "other" + }, + "if": { + "maxLength": 4 + } + } + """, + false, + """ schemaTestId: "if-then-else::if appears at the end when serialized (keyword processing sequence)::invalid redirects to else and fails" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_infinite_loop_detection.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_infinite_loop_detection.kt new file mode 100644 index 00000000..96643811 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_infinite_loop_detection.kt @@ -0,0 +1,99 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_infinite_loop_detection : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/infinite-loop-detection.json`: + * "evaluating the same schema location against the same data location twice is not a sign of an infinite loop -> passing case" + * + * Test ID: "infinite-loop-detection::evaluating the same schema location against the same data location twice is not a sign of an infinite loop::passing case" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "definitions": { + "int": { + "type": "integer" + } + }, + "allOf": [ + { + "properties": { + "foo": { + "${'$'}ref": "#/definitions/int" + } + } + }, + { + "additionalProperties": { + "${'$'}ref": "#/definitions/int" + } + } + ] + } + """, + true, + """ schemaTestId: "infinite-loop-detection::evaluating the same schema location against the same data location twice is not a sign of an infinite loop::passing case" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/infinite-loop-detection.json`: + * "evaluating the same schema location against the same data location twice is not a sign of an infinite loop -> failing case" + * + * Test ID: "infinite-loop-detection::evaluating the same schema location against the same data location twice is not a sign of an infinite loop::failing case" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": "a string" + } + """, + """ + { + "definitions": { + "int": { + "type": "integer" + } + }, + "allOf": [ + { + "properties": { + "foo": { + "${'$'}ref": "#/definitions/int" + } + } + }, + { + "additionalProperties": { + "${'$'}ref": "#/definitions/int" + } + } + ] + } + """, + false, + """ schemaTestId: "infinite-loop-detection::evaluating the same schema location against the same data location twice is not a sign of an infinite loop::failing case" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_items.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_items.kt new file mode 100644 index 00000000..dd06924a --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_items.kt @@ -0,0 +1,1207 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_items : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "a schema given for items -> valid items" + * + * Test ID: "items::a schema given for items::valid items" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "items": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "items::a schema given for items::valid items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "a schema given for items -> wrong type of items" + * + * Test ID: "items::a schema given for items::wrong type of items" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "x" + ] + """, + """ + { + "items": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "items::a schema given for items::wrong type of items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "a schema given for items -> ignores non-arrays" + * + * Test ID: "items::a schema given for items::ignores non-arrays" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "items": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "items::a schema given for items::ignores non-arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "a schema given for items -> JavaScript pseudo-array is valid" + * + * Test ID: "items::a schema given for items::JavaScript pseudo-array is valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "0": "invalid", + "length": 1 + } + """, + """ + { + "items": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "items::a schema given for items::JavaScript pseudo-array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "an array of schemas for items -> correct types" + * + * Test ID: "items::an array of schemas for items::correct types" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo" + ] + """, + """ + { + "items": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "items::an array of schemas for items::correct types" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "an array of schemas for items -> wrong types" + * + * Test ID: "items::an array of schemas for items::wrong types" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + 1 + ] + """, + """ + { + "items": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + false, + """ schemaTestId: "items::an array of schemas for items::wrong types" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "an array of schemas for items -> incomplete array of items" + * + * Test ID: "items::an array of schemas for items::incomplete array of items" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "items": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "items::an array of schemas for items::incomplete array of items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "an array of schemas for items -> array with additional items" + * + * Test ID: "items::an array of schemas for items::array with additional items" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo", + true + ] + """, + """ + { + "items": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "items::an array of schemas for items::array with additional items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "an array of schemas for items -> empty array" + * + * Test ID: "items::an array of schemas for items::empty array" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "items": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "items::an array of schemas for items::empty array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "an array of schemas for items -> JavaScript pseudo-array is valid" + * + * Test ID: "items::an array of schemas for items::JavaScript pseudo-array is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "0": "invalid", + "1": "valid", + "length": 2 + } + """, + """ + { + "items": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + } + """, + true, + """ schemaTestId: "items::an array of schemas for items::JavaScript pseudo-array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items with boolean schema (true) -> any array is valid" + * + * Test ID: "items::items with boolean schema (true)::any array is valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo", + true + ] + """, + """ + { + "items": true + } + """, + true, + """ schemaTestId: "items::items with boolean schema (true)::any array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items with boolean schema (true) -> empty array is valid" + * + * Test ID: "items::items with boolean schema (true)::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "items": true + } + """, + true, + """ schemaTestId: "items::items with boolean schema (true)::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items with boolean schema (false) -> any non-empty array is invalid" + * + * Test ID: "items::items with boolean schema (false)::any non-empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo", + true + ] + """, + """ + { + "items": false + } + """, + false, + """ schemaTestId: "items::items with boolean schema (false)::any non-empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items with boolean schema (false) -> empty array is valid" + * + * Test ID: "items::items with boolean schema (false)::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "items": false + } + """, + true, + """ schemaTestId: "items::items with boolean schema (false)::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items with boolean schemas -> array with one item is valid" + * + * Test ID: "items::items with boolean schemas::array with one item is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "items": [ + true, + false + ] + } + """, + true, + """ schemaTestId: "items::items with boolean schemas::array with one item is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items with boolean schemas -> array with two items is invalid" + * + * Test ID: "items::items with boolean schemas::array with two items is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo" + ] + """, + """ + { + "items": [ + true, + false + ] + } + """, + false, + """ schemaTestId: "items::items with boolean schemas::array with two items is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items with boolean schemas -> empty array is valid" + * + * Test ID: "items::items with boolean schemas::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "items": [ + true, + false + ] + } + """, + true, + """ schemaTestId: "items::items with boolean schemas::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items and subitems -> valid items" + * + * Test ID: "items::items and subitems::valid items" + */ + @Test + fun jsonSchemaSuiteTest_18() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::items and subitems::valid items" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "definitions": { + "item": { + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/sub-item" + }, + { + "${'$'}ref": "#/definitions/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + } + ] + } + """, + true, + """ schemaTestId: "items::items and subitems::valid items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items and subitems -> too many items" + * + * Test ID: "items::items and subitems::too many items" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "definitions": { + "item": { + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/sub-item" + }, + { + "${'$'}ref": "#/definitions/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + } + ] + } + """, + false, + """ schemaTestId: "items::items and subitems::too many items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items and subitems -> too many sub-items" + * + * Test ID: "items::items and subitems::too many sub-items" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + [ + { + "foo": null + }, + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "definitions": { + "item": { + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/sub-item" + }, + { + "${'$'}ref": "#/definitions/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + } + ] + } + """, + false, + """ schemaTestId: "items::items and subitems::too many sub-items" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items and subitems -> wrong item" + * + * Test ID: "items::items and subitems::wrong item" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": null + }, + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "definitions": { + "item": { + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/sub-item" + }, + { + "${'$'}ref": "#/definitions/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + } + ] + } + """, + false, + """ schemaTestId: "items::items and subitems::wrong item" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items and subitems -> wrong sub-item" + * + * Test ID: "items::items and subitems::wrong sub-item" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + [ + [ + { + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ], + [ + { + "foo": null + }, + { + "foo": null + } + ] + ] + """, + """ + { + "definitions": { + "item": { + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/sub-item" + }, + { + "${'$'}ref": "#/definitions/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + } + ] + } + """, + false, + """ schemaTestId: "items::items and subitems::wrong sub-item" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "items and subitems -> fewer items is valid" + * + * Test ID: "items::items and subitems::fewer items is valid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "items::items and subitems::fewer items is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + [ + { + "foo": null + } + ], + [ + { + "foo": null + } + ] + ] + """, + """ + { + "definitions": { + "item": { + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/sub-item" + }, + { + "${'$'}ref": "#/definitions/sub-item" + } + ] + }, + "sub-item": { + "type": "object", + "required": [ + "foo" + ] + } + }, + "type": "array", + "additionalItems": false, + "items": [ + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + }, + { + "${'$'}ref": "#/definitions/item" + } + ] + } + """, + true, + """ schemaTestId: "items::items and subitems::fewer items is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "nested items -> valid nested array" + * + * Test ID: "items::nested items::valid nested array" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + [ + 1 + ] + ], + [ + [ + 2 + ], + [ + 3 + ] + ] + ], + [ + [ + [ + 4 + ], + [ + 5 + ], + [ + 6 + ] + ] + ] + ] + """, + """ + { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "number" + } + } + } + } + } + """, + true, + """ schemaTestId: "items::nested items::valid nested array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "nested items -> nested array with invalid type" + * + * Test ID: "items::nested items::nested array with invalid type" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + [ + "1" + ] + ], + [ + [ + 2 + ], + [ + 3 + ] + ] + ], + [ + [ + [ + 4 + ], + [ + 5 + ], + [ + 6 + ] + ] + ] + ] + """, + """ + { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "number" + } + } + } + } + } + """, + false, + """ schemaTestId: "items::nested items::nested array with invalid type" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "nested items -> not deep enough" + * + * Test ID: "items::nested items::not deep enough" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + 1 + ], + [ + 2 + ], + [ + 3 + ] + ], + [ + [ + 4 + ], + [ + 5 + ], + [ + 6 + ] + ] + ] + """, + """ + { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "number" + } + } + } + } + } + """, + false, + """ schemaTestId: "items::nested items::not deep enough" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "single-form items with null instance elements -> allows null elements" + * + * Test ID: "items::single-form items with null instance elements::allows null elements" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "items": { + "type": "null" + } + } + """, + true, + """ schemaTestId: "items::single-form items with null instance elements::allows null elements" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: + * "array-form items with null instance elements -> allows null elements" + * + * Test ID: "items::array-form items with null instance elements::allows null elements" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + [ + null + ] + """, + """ + { + "items": [ + { + "type": "null" + } + ] + } + """, + true, + """ schemaTestId: "items::array-form items with null instance elements::allows null elements" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxItems.kt new file mode 100644 index 00000000..a23b04af --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxItems.kt @@ -0,0 +1,162 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_maxItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: + * "maxItems validation -> shorter is valid" + * + * Test ID: "maxItems::maxItems validation::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "maxItems": 2 + } + """, + true, + """ schemaTestId: "maxItems::maxItems validation::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: + * "maxItems validation -> exact length is valid" + * + * Test ID: "maxItems::maxItems validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "maxItems": 2 + } + """, + true, + """ schemaTestId: "maxItems::maxItems validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: + * "maxItems validation -> too long is invalid" + * + * Test ID: "maxItems::maxItems validation::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "maxItems": 2 + } + """, + false, + """ schemaTestId: "maxItems::maxItems validation::too long is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: + * "maxItems validation -> ignores non-arrays" + * + * Test ID: "maxItems::maxItems validation::ignores non-arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "maxItems": 2 + } + """, + true, + """ schemaTestId: "maxItems::maxItems validation::ignores non-arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: + * "maxItems validation with a decimal -> shorter is valid" + * + * Test ID: "maxItems::maxItems validation with a decimal::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "maxItems": 2.0 + } + """, + true, + """ schemaTestId: "maxItems::maxItems validation with a decimal::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: + * "maxItems validation with a decimal -> too long is invalid" + * + * Test ID: "maxItems::maxItems validation with a decimal::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "maxItems": 2.0 + } + """, + false, + """ schemaTestId: "maxItems::maxItems validation with a decimal::too long is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxLength.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxLength.kt new file mode 100644 index 00000000..11809556 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxLength.kt @@ -0,0 +1,169 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_maxLength : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: + * "maxLength validation -> shorter is valid" + * + * Test ID: "maxLength::maxLength validation::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "f" + """, + """ + { + "maxLength": 2 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: + * "maxLength validation -> exact length is valid" + * + * Test ID: "maxLength::maxLength validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "fo" + """, + """ + { + "maxLength": 2 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: + * "maxLength validation -> too long is invalid" + * + * Test ID: "maxLength::maxLength validation::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "maxLength": 2 + } + """, + false, + """ schemaTestId: "maxLength::maxLength validation::too long is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: + * "maxLength validation -> ignores non-strings" + * + * Test ID: "maxLength::maxLength validation::ignores non-strings" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 100 + """, + """ + { + "maxLength": 2 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation::ignores non-strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: + * "maxLength validation -> two graphemes is long enough" + * + * Test ID: "maxLength::maxLength validation::two graphemes is long enough" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "💩💩" + """, + """ + { + "maxLength": 2 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation::two graphemes is long enough" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: + * "maxLength validation with a decimal -> shorter is valid" + * + * Test ID: "maxLength::maxLength validation with a decimal::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "f" + """, + """ + { + "maxLength": 2.0 + } + """, + true, + """ schemaTestId: "maxLength::maxLength validation with a decimal::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: + * "maxLength validation with a decimal -> too long is invalid" + * + * Test ID: "maxLength::maxLength validation with a decimal::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "maxLength": 2.0 + } + """, + false, + """ schemaTestId: "maxLength::maxLength validation with a decimal::too long is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxProperties.kt new file mode 100644 index 00000000..8eee2ce8 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maxProperties.kt @@ -0,0 +1,257 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_maxProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties validation -> shorter is valid" + * + * Test ID: "maxProperties::maxProperties validation::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties validation -> exact length is valid" + * + * Test ID: "maxProperties::maxProperties validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties validation -> too long is invalid" + * + * Test ID: "maxProperties::maxProperties validation::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "baz": 3 + } + """, + """ + { + "maxProperties": 2 + } + """, + false, + """ schemaTestId: "maxProperties::maxProperties validation::too long is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties validation -> ignores arrays" + * + * Test ID: "maxProperties::maxProperties validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties validation -> ignores strings" + * + * Test ID: "maxProperties::maxProperties validation::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties validation -> ignores other non-objects" + * + * Test ID: "maxProperties::maxProperties validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "maxProperties": 2 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties validation with a decimal -> shorter is valid" + * + * Test ID: "maxProperties::maxProperties validation with a decimal::shorter is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "maxProperties": 2.0 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties validation with a decimal::shorter is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties validation with a decimal -> too long is invalid" + * + * Test ID: "maxProperties::maxProperties validation with a decimal::too long is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "baz": 3 + } + """, + """ + { + "maxProperties": 2.0 + } + """, + false, + """ schemaTestId: "maxProperties::maxProperties validation with a decimal::too long is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties = 0 means the object is empty -> no properties is valid" + * + * Test ID: "maxProperties::maxProperties = 0 means the object is empty::no properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "maxProperties": 0 + } + """, + true, + """ schemaTestId: "maxProperties::maxProperties = 0 means the object is empty::no properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: + * "maxProperties = 0 means the object is empty -> one property is invalid" + * + * Test ID: "maxProperties::maxProperties = 0 means the object is empty::one property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "maxProperties": 0 + } + """, + false, + """ schemaTestId: "maxProperties::maxProperties = 0 means the object is empty::one property is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maximum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maximum.kt new file mode 100644 index 00000000..f7989a90 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_maximum.kt @@ -0,0 +1,191 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_maximum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: + * "maximum validation -> below the maximum is valid" + * + * Test ID: "maximum::maximum validation::below the maximum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 2.6 + """, + """ + { + "maximum": 3.0 + } + """, + true, + """ schemaTestId: "maximum::maximum validation::below the maximum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: + * "maximum validation -> boundary point is valid" + * + * Test ID: "maximum::maximum validation::boundary point is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 3.0 + """, + """ + { + "maximum": 3.0 + } + """, + true, + """ schemaTestId: "maximum::maximum validation::boundary point is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: + * "maximum validation -> above the maximum is invalid" + * + * Test ID: "maximum::maximum validation::above the maximum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 3.5 + """, + """ + { + "maximum": 3.0 + } + """, + false, + """ schemaTestId: "maximum::maximum validation::above the maximum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: + * "maximum validation -> ignores non-numbers" + * + * Test ID: "maximum::maximum validation::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "maximum": 3.0 + } + """, + true, + """ schemaTestId: "maximum::maximum validation::ignores non-numbers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: + * "maximum validation with unsigned integer -> below the maximum is invalid" + * + * Test ID: "maximum::maximum validation with unsigned integer::below the maximum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 299.97 + """, + """ + { + "maximum": 300 + } + """, + true, + """ schemaTestId: "maximum::maximum validation with unsigned integer::below the maximum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: + * "maximum validation with unsigned integer -> boundary point integer is valid" + * + * Test ID: "maximum::maximum validation with unsigned integer::boundary point integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 300 + """, + """ + { + "maximum": 300 + } + """, + true, + """ schemaTestId: "maximum::maximum validation with unsigned integer::boundary point integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: + * "maximum validation with unsigned integer -> boundary point float is valid" + * + * Test ID: "maximum::maximum validation with unsigned integer::boundary point float is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 300.0 + """, + """ + { + "maximum": 300 + } + """, + true, + """ schemaTestId: "maximum::maximum validation with unsigned integer::boundary point float is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: + * "maximum validation with unsigned integer -> above the maximum is invalid" + * + * Test ID: "maximum::maximum validation with unsigned integer::above the maximum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + 300.5 + """, + """ + { + "maximum": 300 + } + """, + false, + """ schemaTestId: "maximum::maximum validation with unsigned integer::above the maximum is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minItems.kt new file mode 100644 index 00000000..403c5ac8 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minItems.kt @@ -0,0 +1,157 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_minItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: + * "minItems validation -> longer is valid" + * + * Test ID: "minItems::minItems validation::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "minItems": 1 + } + """, + true, + """ schemaTestId: "minItems::minItems validation::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: + * "minItems validation -> exact length is valid" + * + * Test ID: "minItems::minItems validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1 + ] + """, + """ + { + "minItems": 1 + } + """, + true, + """ schemaTestId: "minItems::minItems validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: + * "minItems validation -> too short is invalid" + * + * Test ID: "minItems::minItems validation::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "minItems": 1 + } + """, + false, + """ schemaTestId: "minItems::minItems validation::too short is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: + * "minItems validation -> ignores non-arrays" + * + * Test ID: "minItems::minItems validation::ignores non-arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "minItems": 1 + } + """, + true, + """ schemaTestId: "minItems::minItems validation::ignores non-arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: + * "minItems validation with a decimal -> longer is valid" + * + * Test ID: "minItems::minItems validation with a decimal::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "minItems": 1.0 + } + """, + true, + """ schemaTestId: "minItems::minItems validation with a decimal::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: + * "minItems validation with a decimal -> too short is invalid" + * + * Test ID: "minItems::minItems validation with a decimal::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "minItems": 1.0 + } + """, + false, + """ schemaTestId: "minItems::minItems validation with a decimal::too short is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minLength.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minLength.kt new file mode 100644 index 00000000..4d2173af --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minLength.kt @@ -0,0 +1,169 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_minLength : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: + * "minLength validation -> longer is valid" + * + * Test ID: "minLength::minLength validation::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "minLength": 2 + } + """, + true, + """ schemaTestId: "minLength::minLength validation::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: + * "minLength validation -> exact length is valid" + * + * Test ID: "minLength::minLength validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "fo" + """, + """ + { + "minLength": 2 + } + """, + true, + """ schemaTestId: "minLength::minLength validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: + * "minLength validation -> too short is invalid" + * + * Test ID: "minLength::minLength validation::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "f" + """, + """ + { + "minLength": 2 + } + """, + false, + """ schemaTestId: "minLength::minLength validation::too short is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: + * "minLength validation -> ignores non-strings" + * + * Test ID: "minLength::minLength validation::ignores non-strings" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "minLength": 2 + } + """, + true, + """ schemaTestId: "minLength::minLength validation::ignores non-strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: + * "minLength validation -> one grapheme is not long enough" + * + * Test ID: "minLength::minLength validation::one grapheme is not long enough" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "💩" + """, + """ + { + "minLength": 2 + } + """, + false, + """ schemaTestId: "minLength::minLength validation::one grapheme is not long enough" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: + * "minLength validation with a decimal -> longer is valid" + * + * Test ID: "minLength::minLength validation with a decimal::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "minLength": 2.0 + } + """, + true, + """ schemaTestId: "minLength::minLength validation with a decimal::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: + * "minLength validation with a decimal -> too short is invalid" + * + * Test ID: "minLength::minLength validation with a decimal::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "f" + """, + """ + { + "minLength": 2.0 + } + """, + false, + """ schemaTestId: "minLength::minLength validation with a decimal::too short is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minProperties.kt new file mode 100644 index 00000000..57634ecc --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minProperties.kt @@ -0,0 +1,202 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_minProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: + * "minProperties validation -> longer is valid" + * + * Test ID: "minProperties::minProperties validation::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: + * "minProperties validation -> exact length is valid" + * + * Test ID: "minProperties::minProperties validation::exact length is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::exact length is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: + * "minProperties validation -> too short is invalid" + * + * Test ID: "minProperties::minProperties validation::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "minProperties": 1 + } + """, + false, + """ schemaTestId: "minProperties::minProperties validation::too short is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: + * "minProperties validation -> ignores arrays" + * + * Test ID: "minProperties::minProperties validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: + * "minProperties validation -> ignores strings" + * + * Test ID: "minProperties::minProperties validation::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: + * "minProperties validation -> ignores other non-objects" + * + * Test ID: "minProperties::minProperties validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "minProperties": 1 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: + * "minProperties validation with a decimal -> longer is valid" + * + * Test ID: "minProperties::minProperties validation with a decimal::longer is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "minProperties": 1.0 + } + """, + true, + """ schemaTestId: "minProperties::minProperties validation with a decimal::longer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: + * "minProperties validation with a decimal -> too short is invalid" + * + * Test ID: "minProperties::minProperties validation with a decimal::too short is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "minProperties": 1.0 + } + """, + false, + """ schemaTestId: "minProperties::minProperties validation with a decimal::too short is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minimum.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minimum.kt new file mode 100644 index 00000000..199f8522 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_minimum.kt @@ -0,0 +1,257 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_minimum : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation -> above the minimum is valid" + * + * Test ID: "minimum::minimum validation::above the minimum is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 2.6 + """, + """ + { + "minimum": 1.1 + } + """, + true, + """ schemaTestId: "minimum::minimum validation::above the minimum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation -> boundary point is valid" + * + * Test ID: "minimum::minimum validation::boundary point is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "minimum": 1.1 + } + """, + true, + """ schemaTestId: "minimum::minimum validation::boundary point is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation -> below the minimum is invalid" + * + * Test ID: "minimum::minimum validation::below the minimum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 0.6 + """, + """ + { + "minimum": 1.1 + } + """, + false, + """ schemaTestId: "minimum::minimum validation::below the minimum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation -> ignores non-numbers" + * + * Test ID: "minimum::minimum validation::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "minimum": 1.1 + } + """, + true, + """ schemaTestId: "minimum::minimum validation::ignores non-numbers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation with signed integer -> negative above the minimum is valid" + * + * Test ID: "minimum::minimum validation with signed integer::negative above the minimum is valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + -1 + """, + """ + { + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::negative above the minimum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation with signed integer -> positive above the minimum is valid" + * + * Test ID: "minimum::minimum validation with signed integer::positive above the minimum is valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::positive above the minimum is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation with signed integer -> boundary point is valid" + * + * Test ID: "minimum::minimum validation with signed integer::boundary point is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + -2 + """, + """ + { + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::boundary point is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation with signed integer -> boundary point with float is valid" + * + * Test ID: "minimum::minimum validation with signed integer::boundary point with float is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + -2.0 + """, + """ + { + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::boundary point with float is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation with signed integer -> float below the minimum is invalid" + * + * Test ID: "minimum::minimum validation with signed integer::float below the minimum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + -2.0001 + """, + """ + { + "minimum": -2 + } + """, + false, + """ schemaTestId: "minimum::minimum validation with signed integer::float below the minimum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation with signed integer -> int below the minimum is invalid" + * + * Test ID: "minimum::minimum validation with signed integer::int below the minimum is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + -3 + """, + """ + { + "minimum": -2 + } + """, + false, + """ schemaTestId: "minimum::minimum validation with signed integer::int below the minimum is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: + * "minimum validation with signed integer -> ignores non-numbers" + * + * Test ID: "minimum::minimum validation with signed integer::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + "x" + """, + """ + { + "minimum": -2 + } + """, + true, + """ schemaTestId: "minimum::minimum validation with signed integer::ignores non-numbers" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_multipleOf.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_multipleOf.kt new file mode 100644 index 00000000..15089b17 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_multipleOf.kt @@ -0,0 +1,237 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_multipleOf : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "by int -> int by int" + * + * Test ID: "multipleOf::by int::int by int" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 10 + """, + """ + { + "multipleOf": 2 + } + """, + true, + """ schemaTestId: "multipleOf::by int::int by int" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "by int -> int by int fail" + * + * Test ID: "multipleOf::by int::int by int fail" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 7 + """, + """ + { + "multipleOf": 2 + } + """, + false, + """ schemaTestId: "multipleOf::by int::int by int fail" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "by int -> ignores non-numbers" + * + * Test ID: "multipleOf::by int::ignores non-numbers" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "multipleOf": 2 + } + """, + true, + """ schemaTestId: "multipleOf::by int::ignores non-numbers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "by number -> zero is multiple of anything" + * + * Test ID: "multipleOf::by number::zero is multiple of anything" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "multipleOf": 1.5 + } + """, + true, + """ schemaTestId: "multipleOf::by number::zero is multiple of anything" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "by number -> 4.5 is multiple of 1.5" + * + * Test ID: "multipleOf::by number::4.5 is multiple of 1.5" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 4.5 + """, + """ + { + "multipleOf": 1.5 + } + """, + true, + """ schemaTestId: "multipleOf::by number::4.5 is multiple of 1.5" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "by number -> 35 is not multiple of 1.5" + * + * Test ID: "multipleOf::by number::35 is not multiple of 1.5" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 35 + """, + """ + { + "multipleOf": 1.5 + } + """, + false, + """ schemaTestId: "multipleOf::by number::35 is not multiple of 1.5" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "by small number -> 0.0075 is multiple of 0.0001" + * + * Test ID: "multipleOf::by small number::0.0075 is multiple of 0.0001" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 0.0075 + """, + """ + { + "multipleOf": 1.0E-4 + } + """, + true, + """ schemaTestId: "multipleOf::by small number::0.0075 is multiple of 0.0001" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "by small number -> 0.00751 is not multiple of 0.0001" + * + * Test ID: "multipleOf::by small number::0.00751 is not multiple of 0.0001" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + 0.00751 + """, + """ + { + "multipleOf": 1.0E-4 + } + """, + false, + """ schemaTestId: "multipleOf::by small number::0.00751 is not multiple of 0.0001" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "float division = inf -> always invalid, but naive implementations may raise an overflow error" + * + * Test ID: "multipleOf::float division = inf::always invalid, but naive implementations may raise an overflow error" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + 1.0E308 + """, + """ + { + "type": "integer", + "multipleOf": 0.123456789 + } + """, + false, + """ schemaTestId: "multipleOf::float division = inf::always invalid, but naive implementations may raise an overflow error" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: + * "small multiple of large integer -> any integer is a multiple of 1e-8" + * + * Test ID: "multipleOf::small multiple of large integer::any integer is a multiple of 1e-8" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 12391239123 + """, + """ + { + "type": "integer", + "multipleOf": 1.0E-8 + } + """, + true, + """ schemaTestId: "multipleOf::small multiple of large integer::any integer is a multiple of 1e-8" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_not.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_not.kt new file mode 100644 index 00000000..629e5deb --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_not.kt @@ -0,0 +1,941 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_not : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "not -> allowed" + * + * Test ID: "not::not::allowed" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "not": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "not::not::allowed" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "not -> disallowed" + * + * Test ID: "not::not::disallowed" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "not": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "not::not::disallowed" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "not multiple types -> valid" + * + * Test ID: "not::not multiple types::valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "not": { + "type": [ + "integer", + "boolean" + ] + } + } + """, + true, + """ schemaTestId: "not::not multiple types::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "not multiple types -> mismatch" + * + * Test ID: "not::not multiple types::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "not": { + "type": [ + "integer", + "boolean" + ] + } + } + """, + false, + """ schemaTestId: "not::not multiple types::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "not multiple types -> other mismatch" + * + * Test ID: "not::not multiple types::other mismatch" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "not": { + "type": [ + "integer", + "boolean" + ] + } + } + """, + false, + """ schemaTestId: "not::not multiple types::other mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "not more complex schema -> match" + * + * Test ID: "not::not more complex schema::match" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "not": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "not::not more complex schema::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "not more complex schema -> other match" + * + * Test ID: "not::not more complex schema::other match" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "not": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + true, + """ schemaTestId: "not::not more complex schema::other match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "not more complex schema -> mismatch" + * + * Test ID: "not::not more complex schema::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "not": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + } + } + } + """, + false, + """ schemaTestId: "not::not more complex schema::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbidden property -> property present" + * + * Test ID: "not::forbidden property::property present" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "properties": { + "foo": { + "not": { + } + } + } + } + """, + false, + """ schemaTestId: "not::forbidden property::property present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbidden property -> property absent" + * + * Test ID: "not::forbidden property::property absent" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "bar": 1, + "baz": 2 + } + """, + """ + { + "properties": { + "foo": { + "not": { + } + } + } + } + """, + true, + """ schemaTestId: "not::forbidden property::property absent" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> number is invalid" + * + * Test ID: "not::forbid everything with empty schema::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> string is invalid" + * + * Test ID: "not::forbid everything with empty schema::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> boolean true is invalid" + * + * Test ID: "not::forbid everything with empty schema::boolean true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::boolean true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> boolean false is invalid" + * + * Test ID: "not::forbid everything with empty schema::boolean false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::boolean false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> null is invalid" + * + * Test ID: "not::forbid everything with empty schema::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> object is invalid" + * + * Test ID: "not::forbid everything with empty schema::object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> empty object is invalid" + * + * Test ID: "not::forbid everything with empty schema::empty object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::empty object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> array is invalid" + * + * Test ID: "not::forbid everything with empty schema::array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with empty schema -> empty array is invalid" + * + * Test ID: "not::forbid everything with empty schema::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "not": { + } + } + """, + false, + """ schemaTestId: "not::forbid everything with empty schema::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> number is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> string is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> boolean true is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::boolean true is invalid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::boolean true is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> boolean false is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::boolean false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::boolean false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> null is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> object is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> empty object is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::empty object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::empty object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> array is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "forbid everything with boolean schema true -> empty array is invalid" + * + * Test ID: "not::forbid everything with boolean schema true::empty array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "not": true + } + """, + false, + """ schemaTestId: "not::forbid everything with boolean schema true::empty array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> number is valid" + * + * Test ID: "not::allow everything with boolean schema false::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> string is valid" + * + * Test ID: "not::allow everything with boolean schema false::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> boolean true is valid" + * + * Test ID: "not::allow everything with boolean schema false::boolean true is valid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::boolean true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> boolean false is valid" + * + * Test ID: "not::allow everything with boolean schema false::boolean false is valid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::boolean false is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> null is valid" + * + * Test ID: "not::allow everything with boolean schema false::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> object is valid" + * + * Test ID: "not::allow everything with boolean schema false::object is valid" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> empty object is valid" + * + * Test ID: "not::allow everything with boolean schema false::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> array is valid" + * + * Test ID: "not::allow everything with boolean schema false::array is valid" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "allow everything with boolean schema false -> empty array is valid" + * + * Test ID: "not::allow everything with boolean schema false::empty array is valid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "not": false + } + """, + true, + """ schemaTestId: "not::allow everything with boolean schema false::empty array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: + * "double negation -> any value is valid" + * + * Test ID: "not::double negation::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "not": { + "not": { + } + } + } + """, + true, + """ schemaTestId: "not::double negation::any value is valid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_oneOf.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_oneOf.kt new file mode 100644 index 00000000..b0f6c1f7 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_oneOf.kt @@ -0,0 +1,948 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_oneOf : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf -> first oneOf valid" + * + * Test ID: "oneOf::oneOf::first oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf::first oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf -> second oneOf valid" + * + * Test ID: "oneOf::oneOf::second oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 2.5 + """, + """ + { + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf::second oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf -> both oneOf valid" + * + * Test ID: "oneOf::oneOf::both oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf::both oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf -> neither oneOf valid" + * + * Test ID: "oneOf::oneOf::neither oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 1.5 + """, + """ + { + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf::neither oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with base schema -> mismatch base schema" + * + * Test ID: "oneOf::oneOf with base schema::mismatch base schema" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 3 + """, + """ + { + "type": "string", + "oneOf": [ + { + "minLength": 2 + }, + { + "maxLength": 4 + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with base schema::mismatch base schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with base schema -> one oneOf valid" + * + * Test ID: "oneOf::oneOf with base schema::one oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "type": "string", + "oneOf": [ + { + "minLength": 2 + }, + { + "maxLength": 4 + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with base schema::one oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with base schema -> both oneOf valid" + * + * Test ID: "oneOf::oneOf with base schema::both oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "string", + "oneOf": [ + { + "minLength": 2 + }, + { + "maxLength": 4 + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with base schema::both oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with boolean schemas, all true -> any value is invalid" + * + * Test ID: "oneOf::oneOf with boolean schemas, all true::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "oneOf": [ + true, + true, + true + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with boolean schemas, all true::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with boolean schemas, one true -> any value is valid" + * + * Test ID: "oneOf::oneOf with boolean schemas, one true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "oneOf": [ + true, + false, + false + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with boolean schemas, one true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with boolean schemas, more than one true -> any value is invalid" + * + * Test ID: "oneOf::oneOf with boolean schemas, more than one true::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "oneOf": [ + true, + true, + false + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with boolean schemas, more than one true::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with boolean schemas, all false -> any value is invalid" + * + * Test ID: "oneOf::oneOf with boolean schemas, all false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "oneOf": [ + false, + false, + false + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with boolean schemas, all false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf complex types -> first oneOf valid (complex)" + * + * Test ID: "oneOf::oneOf complex types::first oneOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "oneOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf complex types::first oneOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf complex types -> second oneOf valid (complex)" + * + * Test ID: "oneOf::oneOf complex types::second oneOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz" + } + """, + """ + { + "oneOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf complex types::second oneOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf complex types -> both oneOf valid (complex)" + * + * Test ID: "oneOf::oneOf complex types::both oneOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "foo": "baz", + "bar": 2 + } + """, + """ + { + "oneOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf complex types::both oneOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf complex types -> neither oneOf valid (complex)" + * + * Test ID: "oneOf::oneOf complex types::neither oneOf valid (complex)" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "foo": 2, + "bar": "quux" + } + """, + """ + { + "oneOf": [ + { + "properties": { + "bar": { + "type": "integer" + } + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf complex types::neither oneOf valid (complex)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with empty schema -> one valid - valid" + * + * Test ID: "oneOf::oneOf with empty schema::one valid - valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "oneOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with empty schema::one valid - valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with empty schema -> both valid - invalid" + * + * Test ID: "oneOf::oneOf with empty schema::both valid - invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "oneOf": [ + { + "type": "number" + }, + { + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with empty schema::both valid - invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with required -> both invalid - invalid" + * + * Test ID: "oneOf::oneOf with required::both invalid - invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "type": "object", + "oneOf": [ + { + "required": [ + "foo", + "bar" + ] + }, + { + "required": [ + "foo", + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with required::both invalid - invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with required -> first valid - valid" + * + * Test ID: "oneOf::oneOf with required::first valid - valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "type": "object", + "oneOf": [ + { + "required": [ + "foo", + "bar" + ] + }, + { + "required": [ + "foo", + "baz" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with required::first valid - valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with required -> second valid - valid" + * + * Test ID: "oneOf::oneOf with required::second valid - valid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "baz": 3 + } + """, + """ + { + "type": "object", + "oneOf": [ + { + "required": [ + "foo", + "bar" + ] + }, + { + "required": [ + "foo", + "baz" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with required::second valid - valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with required -> both valid - invalid" + * + * Test ID: "oneOf::oneOf with required::both valid - invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2, + "baz": 3 + } + """, + """ + { + "type": "object", + "oneOf": [ + { + "required": [ + "foo", + "bar" + ] + }, + { + "required": [ + "foo", + "baz" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with required::both valid - invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with missing optional property -> first oneOf valid" + * + * Test ID: "oneOf::oneOf with missing optional property::first oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + { + "bar": 8 + } + """, + """ + { + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": true + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with missing optional property::first oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with missing optional property -> second oneOf valid" + * + * Test ID: "oneOf::oneOf with missing optional property::second oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo" + } + """, + """ + { + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": true + }, + "required": [ + "foo" + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::oneOf with missing optional property::second oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with missing optional property -> both oneOf valid" + * + * Test ID: "oneOf::oneOf with missing optional property::both oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + "foo": "foo", + "bar": 8 + } + """, + """ + { + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": true + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with missing optional property::both oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "oneOf with missing optional property -> neither oneOf valid" + * + * Test ID: "oneOf::oneOf with missing optional property::neither oneOf valid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + "baz": "quux" + } + """, + """ + { + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": [ + "bar" + ] + }, + { + "properties": { + "foo": true + }, + "required": [ + "foo" + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::oneOf with missing optional property::neither oneOf valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "nested oneOf, to check validation semantics -> null is valid" + * + * Test ID: "oneOf::nested oneOf, to check validation semantics::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "oneOf": [ + { + "oneOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + true, + """ schemaTestId: "oneOf::nested oneOf, to check validation semantics::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: + * "nested oneOf, to check validation semantics -> anything non-null is invalid" + * + * Test ID: "oneOf::nested oneOf, to check validation semantics::anything non-null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "oneOf": [ + { + "oneOf": [ + { + "type": "null" + } + ] + } + ] + } + """, + false, + """ schemaTestId: "oneOf::nested oneOf, to check validation semantics::anything non-null is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_pattern.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_pattern.kt new file mode 100644 index 00000000..5e58f4f1 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_pattern.kt @@ -0,0 +1,215 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_pattern : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern validation -> a matching pattern is valid" + * + * Test ID: "pattern::pattern validation::a matching pattern is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + "aaa" + """, + """ + { + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::a matching pattern is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern validation -> a non-matching pattern is invalid" + * + * Test ID: "pattern::pattern validation::a non-matching pattern is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + "abc" + """, + """ + { + "pattern": "^a*${'$'}" + } + """, + false, + """ schemaTestId: "pattern::pattern validation::a non-matching pattern is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern validation -> ignores booleans" + * + * Test ID: "pattern::pattern validation::ignores booleans" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores booleans" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern validation -> ignores integers" + * + * Test ID: "pattern::pattern validation::ignores integers" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores integers" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern validation -> ignores floats" + * + * Test ID: "pattern::pattern validation::ignores floats" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores floats" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern validation -> ignores objects" + * + * Test ID: "pattern::pattern validation::ignores objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern validation -> ignores arrays" + * + * Test ID: "pattern::pattern validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern validation -> ignores null" + * + * Test ID: "pattern::pattern validation::ignores null" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "pattern": "^a*${'$'}" + } + """, + true, + """ schemaTestId: "pattern::pattern validation::ignores null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: + * "pattern is not anchored -> matches a substring" + * + * Test ID: "pattern::pattern is not anchored::matches a substring" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + "xxaayy" + """, + """ + { + "pattern": "a+" + } + """, + true, + """ schemaTestId: "pattern::pattern is not anchored::matches a substring" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_patternProperties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_patternProperties.kt new file mode 100644 index 00000000..59b9395b --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_patternProperties.kt @@ -0,0 +1,685 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_patternProperties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties validates properties matching a regex -> a single valid match is valid" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::a single valid match is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::a single valid match is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties validates properties matching a regex -> multiple valid matches is valid" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::multiple valid matches is valid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "foooooo": 2 + } + """, + """ + { + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::multiple valid matches is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties validates properties matching a regex -> a single invalid match is invalid" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::a single invalid match is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar", + "fooooo": 2 + } + """, + """ + { + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::a single invalid match is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties validates properties matching a regex -> multiple invalid matches is invalid" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::multiple invalid matches is invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar", + "foooooo": "baz" + } + """, + """ + { + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::multiple invalid matches is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties validates properties matching a regex -> ignores arrays" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + "foo" + ] + """, + """ + { + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties validates properties matching a regex -> ignores strings" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties validates properties matching a regex -> ignores other non-objects" + * + * Test ID: "patternProperties::patternProperties validates properties matching a regex::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "patternProperties": { + "f.*o": { + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties validates properties matching a regex::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> a single valid match is valid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::a single valid match is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "a": 21 + } + """, + """ + { + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + true, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::a single valid match is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> a simultaneous match is valid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::a simultaneous match is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "aaaa": 18 + } + """, + """ + { + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + true, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::a simultaneous match is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> multiple matches is valid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::multiple matches is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "a": 21, + "aaaa": 18 + } + """, + """ + { + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + true, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::multiple matches is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> an invalid due to one is invalid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to one is invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "a": "bar" + } + """, + """ + { + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + false, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to one is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> an invalid due to the other is invalid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to the other is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "aaaa": 31 + } + """, + """ + { + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + false, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to the other is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "multiple simultaneous patternProperties are validated -> an invalid due to both is invalid" + * + * Test ID: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to both is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "aaa": "foo", + "aaaa": 31 + } + """, + """ + { + "patternProperties": { + "a*": { + "type": "integer" + }, + "aaa*": { + "maximum": 20 + } + } + } + """, + false, + """ schemaTestId: "patternProperties::multiple simultaneous patternProperties are validated::an invalid due to both is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "regexes are not anchored by default and are case sensitive -> non recognized members are ignored" + * + * Test ID: "patternProperties::regexes are not anchored by default and are case sensitive::non recognized members are ignored" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "answer 1": "42" + } + """, + """ + { + "patternProperties": { + "[0-9]{2,}": { + "type": "boolean" + }, + "X_": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::regexes are not anchored by default and are case sensitive::non recognized members are ignored" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "regexes are not anchored by default and are case sensitive -> recognized members are accounted for" + * + * Test ID: "patternProperties::regexes are not anchored by default and are case sensitive::recognized members are accounted for" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + "a31b": null + } + """, + """ + { + "patternProperties": { + "[0-9]{2,}": { + "type": "boolean" + }, + "X_": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "patternProperties::regexes are not anchored by default and are case sensitive::recognized members are accounted for" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "regexes are not anchored by default and are case sensitive -> regexes are case sensitive" + * + * Test ID: "patternProperties::regexes are not anchored by default and are case sensitive::regexes are case sensitive" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "a_x_3": 3 + } + """, + """ + { + "patternProperties": { + "[0-9]{2,}": { + "type": "boolean" + }, + "X_": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::regexes are not anchored by default and are case sensitive::regexes are case sensitive" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "regexes are not anchored by default and are case sensitive -> regexes are case sensitive, 2" + * + * Test ID: "patternProperties::regexes are not anchored by default and are case sensitive::regexes are case sensitive, 2" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "a_X_3": 3 + } + """, + """ + { + "patternProperties": { + "[0-9]{2,}": { + "type": "boolean" + }, + "X_": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "patternProperties::regexes are not anchored by default and are case sensitive::regexes are case sensitive, 2" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties with boolean schemas -> object with property matching schema true is valid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::object with property matching schema true is valid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::object with property matching schema true is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties with boolean schemas -> object with property matching schema false is invalid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::object with property matching schema false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::object with property matching schema false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties with boolean schemas -> object with both properties is invalid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::object with both properties is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::object with both properties is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties with boolean schemas -> object with a property matching both true and false is invalid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::object with a property matching both true and false is invalid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foobar": 1 + } + """, + """ + { + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + false, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::object with a property matching both true and false is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties with boolean schemas -> empty object is valid" + * + * Test ID: "patternProperties::patternProperties with boolean schemas::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "patternProperties": { + "f.*": true, + "b.*": false + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties with boolean schemas::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: + * "patternProperties with null valued instance properties -> allows null values" + * + * Test ID: "patternProperties::patternProperties with null valued instance properties::allows null values" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + { + "foobar": null + } + """, + """ + { + "patternProperties": { + "^.*bar${'$'}": { + "type": "null" + } + } + } + """, + true, + """ schemaTestId: "patternProperties::patternProperties with null valued instance properties::allows null values" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_properties.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_properties.kt new file mode 100644 index 00000000..7480bc23 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_properties.kt @@ -0,0 +1,1041 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_properties : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "object properties validation -> both properties present and valid is valid" + * + * Test ID: "properties::object properties validation::both properties present and valid is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": "baz" + } + """, + """ + { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "properties::object properties validation::both properties present and valid is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "object properties validation -> one property invalid is invalid" + * + * Test ID: "properties::object properties validation::one property invalid is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": { + } + } + """, + """ + { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "properties::object properties validation::one property invalid is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "object properties validation -> both properties invalid is invalid" + * + * Test ID: "properties::object properties validation::both properties invalid is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + ], + "bar": { + } + } + """, + """ + { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "properties::object properties validation::both properties invalid is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "object properties validation -> doesn't invalidate other properties" + * + * Test ID: "properties::object properties validation::doesn't invalidate other properties" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "quux": [ + ] + } + """, + """ + { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "properties::object properties validation::doesn't invalidate other properties" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "object properties validation -> ignores arrays" + * + * Test ID: "properties::object properties validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "properties::object properties validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "object properties validation -> ignores other non-objects" + * + * Test ID: "properties::object properties validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "properties::object properties validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> property validates property" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::property validates property" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + 1, + 2 + ] + } + """, + """ + { + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::property validates property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> property invalidates property" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::property invalidates property" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + 1, + 2, + 3, + 4 + ] + } + """, + """ + { + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::property invalidates property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> patternProperty invalidates property" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::patternProperty invalidates property" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + ] + } + """, + """ + { + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::patternProperty invalidates property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> patternProperty validates nonproperty" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::patternProperty validates nonproperty" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "fxo": [ + 1, + 2 + ] + } + """, + """ + { + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::patternProperty validates nonproperty" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> patternProperty invalidates nonproperty" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::patternProperty invalidates nonproperty" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "fxo": [ + ] + } + """, + """ + { + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::patternProperty invalidates nonproperty" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> additionalProperty ignores property" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty ignores property" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "bar": [ + ] + } + """, + """ + { + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty ignores property" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> additionalProperty validates others" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty validates others" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "quux": 3 + } + """, + """ + { + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + true, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty validates others" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties, patternProperties, additionalProperties interaction -> additionalProperty invalidates others" + * + * Test ID: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty invalidates others" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "quux": "foo" + } + """, + """ + { + "properties": { + "foo": { + "type": "array", + "maxItems": 3 + }, + "bar": { + "type": "array" + } + }, + "patternProperties": { + "f.o": { + "minItems": 2 + } + }, + "additionalProperties": { + "type": "integer" + } + } + """, + false, + """ schemaTestId: "properties::properties, patternProperties, additionalProperties interaction::additionalProperty invalidates others" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties with boolean schema -> no property present is valid" + * + * Test ID: "properties::properties with boolean schema::no property present is valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "properties": { + "foo": true, + "bar": false + } + } + """, + true, + """ schemaTestId: "properties::properties with boolean schema::no property present is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties with boolean schema -> only 'true' property present is valid" + * + * Test ID: "properties::properties with boolean schema::only 'true' property present is valid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "properties": { + "foo": true, + "bar": false + } + } + """, + true, + """ schemaTestId: "properties::properties with boolean schema::only 'true' property present is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties with boolean schema -> only 'false' property present is invalid" + * + * Test ID: "properties::properties with boolean schema::only 'false' property present is invalid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "bar": 2 + } + """, + """ + { + "properties": { + "foo": true, + "bar": false + } + } + """, + false, + """ schemaTestId: "properties::properties with boolean schema::only 'false' property present is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties with boolean schema -> both properties present is invalid" + * + * Test ID: "properties::properties with boolean schema::both properties present is invalid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1, + "bar": 2 + } + """, + """ + { + "properties": { + "foo": true, + "bar": false + } + } + """, + false, + """ schemaTestId: "properties::properties with boolean schema::both properties present is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties with escaped characters -> object with all numbers is valid" + * + * Test ID: "properties::properties with escaped characters::object with all numbers is valid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": 1, + "foo\"bar": 1, + "foo\\bar": 1, + "foo\rbar": 1, + "foo\tbar": 1, + "foo\fbar": 1 + } + """, + """ + { + "properties": { + "foo\nbar": { + "type": "number" + }, + "foo\"bar": { + "type": "number" + }, + "foo\\bar": { + "type": "number" + }, + "foo\rbar": { + "type": "number" + }, + "foo\tbar": { + "type": "number" + }, + "foo\fbar": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties with escaped characters::object with all numbers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties with escaped characters -> object with strings is invalid" + * + * Test ID: "properties::properties with escaped characters::object with strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": "1", + "foo\"bar": "1", + "foo\\bar": "1", + "foo\rbar": "1", + "foo\tbar": "1", + "foo\fbar": "1" + } + """, + """ + { + "properties": { + "foo\nbar": { + "type": "number" + }, + "foo\"bar": { + "type": "number" + }, + "foo\\bar": { + "type": "number" + }, + "foo\rbar": { + "type": "number" + }, + "foo\tbar": { + "type": "number" + }, + "foo\fbar": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "properties::properties with escaped characters::object with strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties with null valued instance properties -> allows null values" + * + * Test ID: "properties::properties with null valued instance properties::allows null values" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + { + "foo": null + } + """, + """ + { + "properties": { + "foo": { + "type": "null" + } + } + } + """, + true, + """ schemaTestId: "properties::properties with null valued instance properties::allows null values" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties whose names are Javascript object property names -> ignores arrays" + * + * Test ID: "properties::properties whose names are Javascript object property names::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_22() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties whose names are Javascript object property names::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties whose names are Javascript object property names -> ignores other non-objects" + * + * Test ID: "properties::properties whose names are Javascript object property names::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_23() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties whose names are Javascript object property names::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties whose names are Javascript object property names -> none of the properties mentioned" + * + * Test ID: "properties::properties whose names are Javascript object property names::none of the properties mentioned" + */ + @Test + fun jsonSchemaSuiteTest_24() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties whose names are Javascript object property names::none of the properties mentioned" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties whose names are Javascript object property names -> __proto__ not valid" + * + * Test ID: "properties::properties whose names are Javascript object property names::__proto__ not valid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "__proto__": "foo" + } + """, + """ + { + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "properties::properties whose names are Javascript object property names::__proto__ not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties whose names are Javascript object property names -> toString not valid" + * + * Test ID: "properties::properties whose names are Javascript object property names::toString not valid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "toString": { + "length": 37 + } + } + """, + """ + { + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "properties::properties whose names are Javascript object property names::toString not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties whose names are Javascript object property names -> constructor not valid" + * + * Test ID: "properties::properties whose names are Javascript object property names::constructor not valid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "constructor": { + "length": 37 + } + } + """, + """ + { + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "properties::properties whose names are Javascript object property names::constructor not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: + * "properties whose names are Javascript object property names -> all present and valid" + * + * Test ID: "properties::properties whose names are Javascript object property names::all present and valid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "__proto__": 12, + "toString": { + "length": "foo" + }, + "constructor": 37 + } + """, + """ + { + "properties": { + "__proto__": { + "type": "number" + }, + "toString": { + "properties": { + "length": { + "type": "string" + } + } + }, + "constructor": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "properties::properties whose names are Javascript object property names::all present and valid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_propertyNames.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_propertyNames.kt new file mode 100644 index 00000000..0a13205b --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_propertyNames.kt @@ -0,0 +1,352 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_propertyNames : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation -> all property names valid" + * + * Test ID: "propertyNames::propertyNames validation::all property names valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "f": { + }, + "foo": { + } + } + """, + """ + { + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::all property names valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation -> some property names invalid" + * + * Test ID: "propertyNames::propertyNames validation::some property names invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + }, + "foobar": { + } + } + """, + """ + { + "propertyNames": { + "maxLength": 3 + } + } + """, + false, + """ schemaTestId: "propertyNames::propertyNames validation::some property names invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation -> object without properties is valid" + * + * Test ID: "propertyNames::propertyNames validation::object without properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::object without properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation -> ignores arrays" + * + * Test ID: "propertyNames::propertyNames validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3, + 4 + ] + """, + """ + { + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation -> ignores strings" + * + * Test ID: "propertyNames::propertyNames validation::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "foobar" + """, + """ + { + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation -> ignores other non-objects" + * + * Test ID: "propertyNames::propertyNames validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "propertyNames": { + "maxLength": 3 + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation with pattern -> matching property names valid" + * + * Test ID: "propertyNames::propertyNames validation with pattern::matching property names valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + "a": { + }, + "aa": { + }, + "aaa": { + } + } + """, + """ + { + "propertyNames": { + "pattern": "^a+${'$'}" + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation with pattern::matching property names valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation with pattern -> non-matching property name is invalid" + * + * Test ID: "propertyNames::propertyNames validation with pattern::non-matching property name is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "aaA": { + } + } + """, + """ + { + "propertyNames": { + "pattern": "^a+${'$'}" + } + } + """, + false, + """ schemaTestId: "propertyNames::propertyNames validation with pattern::non-matching property name is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames validation with pattern -> object without properties is valid" + * + * Test ID: "propertyNames::propertyNames validation with pattern::object without properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "propertyNames": { + "pattern": "^a+${'$'}" + } + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames validation with pattern::object without properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames with boolean schema true -> object with any properties is valid" + * + * Test ID: "propertyNames::propertyNames with boolean schema true::object with any properties is valid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "propertyNames": true + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames with boolean schema true::object with any properties is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames with boolean schema true -> empty object is valid" + * + * Test ID: "propertyNames::propertyNames with boolean schema true::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "propertyNames": true + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames with boolean schema true::empty object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames with boolean schema false -> object with any properties is invalid" + * + * Test ID: "propertyNames::propertyNames with boolean schema false::object with any properties is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "propertyNames": false + } + """, + false, + """ schemaTestId: "propertyNames::propertyNames with boolean schema false::object with any properties is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: + * "propertyNames with boolean schema false -> empty object is valid" + * + * Test ID: "propertyNames::propertyNames with boolean schema false::empty object is valid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "propertyNames": false + } + """, + true, + """ schemaTestId: "propertyNames::propertyNames with boolean schema false::empty object is valid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_ref.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_ref.kt new file mode 100644 index 00000000..052dfb90 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_ref.kt @@ -0,0 +1,2951 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_ref : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "root pointer ref -> match" + * + * Test ID: "ref::root pointer ref::match" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": false + } + """, + """ + { + "properties": { + "foo": { + "${'$'}ref": "#" + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "ref::root pointer ref::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "root pointer ref -> recursive match" + * + * Test ID: "ref::root pointer ref::recursive match" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + "foo": false + } + } + """, + """ + { + "properties": { + "foo": { + "${'$'}ref": "#" + } + }, + "additionalProperties": false + } + """, + true, + """ schemaTestId: "ref::root pointer ref::recursive match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "root pointer ref -> mismatch" + * + * Test ID: "ref::root pointer ref::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + { + "bar": false + } + """, + """ + { + "properties": { + "foo": { + "${'$'}ref": "#" + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "ref::root pointer ref::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "root pointer ref -> recursive mismatch" + * + * Test ID: "ref::root pointer ref::recursive mismatch" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": false + } + } + """, + """ + { + "properties": { + "foo": { + "${'$'}ref": "#" + } + }, + "additionalProperties": false + } + """, + false, + """ schemaTestId: "ref::root pointer ref::recursive mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "relative pointer ref to object -> match" + * + * Test ID: "ref::relative pointer ref to object::match" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + { + "bar": 3 + } + """, + """ + { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "${'$'}ref": "#/properties/foo" + } + } + } + """, + true, + """ schemaTestId: "ref::relative pointer ref to object::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "relative pointer ref to object -> mismatch" + * + * Test ID: "ref::relative pointer ref to object::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + "bar": true + } + """, + """ + { + "properties": { + "foo": { + "type": "integer" + }, + "bar": { + "${'$'}ref": "#/properties/foo" + } + } + } + """, + false, + """ schemaTestId: "ref::relative pointer ref to object::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "relative pointer ref to array -> match array" + * + * Test ID: "ref::relative pointer ref to array::match array" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "items": [ + { + "type": "integer" + }, + { + "${'$'}ref": "#/items/0" + } + ] + } + """, + true, + """ schemaTestId: "ref::relative pointer ref to array::match array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "relative pointer ref to array -> mismatch array" + * + * Test ID: "ref::relative pointer ref to array::mismatch array" + */ + @Test + fun jsonSchemaSuiteTest_8() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::relative pointer ref to array::mismatch array" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + 1, + "foo" + ] + """, + """ + { + "items": [ + { + "type": "integer" + }, + { + "${'$'}ref": "#/items/0" + } + ] + } + """, + false, + """ schemaTestId: "ref::relative pointer ref to array::mismatch array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "escaped pointer ref -> slash invalid" + * + * Test ID: "ref::escaped pointer ref::slash invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "slash": "aoeu" + } + """, + """ + { + "definitions": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/definitions/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/definitions/slash~1field" + }, + "percent": { + "${'$'}ref": "#/definitions/percent%25field" + } + } + } + """, + false, + """ schemaTestId: "ref::escaped pointer ref::slash invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "escaped pointer ref -> tilde invalid" + * + * Test ID: "ref::escaped pointer ref::tilde invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + { + "tilde": "aoeu" + } + """, + """ + { + "definitions": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/definitions/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/definitions/slash~1field" + }, + "percent": { + "${'$'}ref": "#/definitions/percent%25field" + } + } + } + """, + false, + """ schemaTestId: "ref::escaped pointer ref::tilde invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "escaped pointer ref -> percent invalid" + * + * Test ID: "ref::escaped pointer ref::percent invalid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + { + "percent": "aoeu" + } + """, + """ + { + "definitions": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/definitions/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/definitions/slash~1field" + }, + "percent": { + "${'$'}ref": "#/definitions/percent%25field" + } + } + } + """, + false, + """ schemaTestId: "ref::escaped pointer ref::percent invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "escaped pointer ref -> slash valid" + * + * Test ID: "ref::escaped pointer ref::slash valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + { + "slash": 123 + } + """, + """ + { + "definitions": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/definitions/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/definitions/slash~1field" + }, + "percent": { + "${'$'}ref": "#/definitions/percent%25field" + } + } + } + """, + true, + """ schemaTestId: "ref::escaped pointer ref::slash valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "escaped pointer ref -> tilde valid" + * + * Test ID: "ref::escaped pointer ref::tilde valid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + { + "tilde": 123 + } + """, + """ + { + "definitions": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/definitions/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/definitions/slash~1field" + }, + "percent": { + "${'$'}ref": "#/definitions/percent%25field" + } + } + } + """, + true, + """ schemaTestId: "ref::escaped pointer ref::tilde valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "escaped pointer ref -> percent valid" + * + * Test ID: "ref::escaped pointer ref::percent valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + { + "percent": 123 + } + """, + """ + { + "definitions": { + "tilde~field": { + "type": "integer" + }, + "slash/field": { + "type": "integer" + }, + "percent%field": { + "type": "integer" + } + }, + "properties": { + "tilde": { + "${'$'}ref": "#/definitions/tilde~0field" + }, + "slash": { + "${'$'}ref": "#/definitions/slash~1field" + }, + "percent": { + "${'$'}ref": "#/definitions/percent%25field" + } + } + } + """, + true, + """ schemaTestId: "ref::escaped pointer ref::percent valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "nested refs -> nested ref valid" + * + * Test ID: "ref::nested refs::nested ref valid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + 5 + """, + """ + { + "definitions": { + "a": { + "type": "integer" + }, + "b": { + "${'$'}ref": "#/definitions/a" + }, + "c": { + "${'$'}ref": "#/definitions/b" + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/c" + } + ] + } + """, + true, + """ schemaTestId: "ref::nested refs::nested ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "nested refs -> nested ref invalid" + * + * Test ID: "ref::nested refs::nested ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "definitions": { + "a": { + "type": "integer" + }, + "b": { + "${'$'}ref": "#/definitions/a" + }, + "c": { + "${'$'}ref": "#/definitions/b" + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/c" + } + ] + } + """, + false, + """ schemaTestId: "ref::nested refs::nested ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref overrides any sibling keywords -> ref valid" + * + * Test ID: "ref::ref overrides any sibling keywords::ref valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + ] + } + """, + """ + { + "definitions": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "${'$'}ref": "#/definitions/reffed", + "maxItems": 2 + } + } + } + """, + true, + """ schemaTestId: "ref::ref overrides any sibling keywords::ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref overrides any sibling keywords -> ref valid, maxItems ignored" + * + * Test ID: "ref::ref overrides any sibling keywords::ref valid, maxItems ignored" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + { + "foo": [ + 1, + 2, + 3 + ] + } + """, + """ + { + "definitions": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "${'$'}ref": "#/definitions/reffed", + "maxItems": 2 + } + } + } + """, + true, + """ schemaTestId: "ref::ref overrides any sibling keywords::ref valid, maxItems ignored" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref overrides any sibling keywords -> ref invalid" + * + * Test ID: "ref::ref overrides any sibling keywords::ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + { + "foo": "string" + } + """, + """ + { + "definitions": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "${'$'}ref": "#/definitions/reffed", + "maxItems": 2 + } + } + } + """, + false, + """ schemaTestId: "ref::ref overrides any sibling keywords::ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$ref prevents a sibling $id from changing the base uri -> $ref resolves to /definitions/base_foo, data does not validate" + * + * Test ID: "ref::$ref prevents a sibling $id from changing the base uri::$ref resolves to /definitions/base_foo, data does not validate" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}id": "http://localhost:1234/sibling_id/base/", + "definitions": { + "foo": { + "${'$'}id": "http://localhost:1234/sibling_id/foo.json", + "type": "string" + }, + "base_foo": { + "${'$'}comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", + "${'$'}id": "foo.json", + "type": "number" + } + }, + "allOf": [ + { + "${'$'}comment": "${'$'}ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", + "${'$'}id": "http://localhost:1234/sibling_id/", + "${'$'}ref": "foo.json" + } + ] + } + """, + false, + """ schemaTestId: "ref::${'$'}ref prevents a sibling ${'$'}id from changing the base uri::${'$'}ref resolves to /definitions/base_foo, data does not validate" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$ref prevents a sibling $id from changing the base uri -> $ref resolves to /definitions/base_foo, data validates" + * + * Test ID: "ref::$ref prevents a sibling $id from changing the base uri::$ref resolves to /definitions/base_foo, data validates" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}id": "http://localhost:1234/sibling_id/base/", + "definitions": { + "foo": { + "${'$'}id": "http://localhost:1234/sibling_id/foo.json", + "type": "string" + }, + "base_foo": { + "${'$'}comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", + "${'$'}id": "foo.json", + "type": "number" + } + }, + "allOf": [ + { + "${'$'}comment": "${'$'}ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", + "${'$'}id": "http://localhost:1234/sibling_id/", + "${'$'}ref": "foo.json" + } + ] + } + """, + true, + """ schemaTestId: "ref::${'$'}ref prevents a sibling ${'$'}id from changing the base uri::${'$'}ref resolves to /definitions/base_foo, data validates" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "remote ref, containing refs itself -> remote ref valid" + * + * Test ID: "ref::remote ref, containing refs itself::remote ref valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::remote ref, containing refs itself::remote ref valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "minLength": 1 + } + """, + """ + { + "${'$'}ref": "http://json-schema.org/draft-07/schema#" + } + """, + true, + """ schemaTestId: "ref::remote ref, containing refs itself::remote ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "remote ref, containing refs itself -> remote ref invalid" + * + * Test ID: "ref::remote ref, containing refs itself::remote ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::remote ref, containing refs itself::remote ref invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "minLength": -1 + } + """, + """ + { + "${'$'}ref": "http://json-schema.org/draft-07/schema#" + } + """, + false, + """ schemaTestId: "ref::remote ref, containing refs itself::remote ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "property named $ref that is not a reference -> property named $ref valid" + * + * Test ID: "ref::property named $ref that is not a reference::property named $ref valid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": "a" + } + """, + """ + { + "properties": { + "${'$'}ref": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::property named ${'$'}ref that is not a reference::property named ${'$'}ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "property named $ref that is not a reference -> property named $ref invalid" + * + * Test ID: "ref::property named $ref that is not a reference::property named $ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": 2 + } + """, + """ + { + "properties": { + "${'$'}ref": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::property named ${'$'}ref that is not a reference::property named ${'$'}ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "property named $ref, containing an actual $ref -> property named $ref valid" + * + * Test ID: "ref::property named $ref, containing an actual $ref::property named $ref valid" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": "a" + } + """, + """ + { + "properties": { + "${'$'}ref": { + "${'$'}ref": "#/definitions/is-string" + } + }, + "definitions": { + "is-string": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::property named ${'$'}ref, containing an actual ${'$'}ref::property named ${'$'}ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "property named $ref, containing an actual $ref -> property named $ref invalid" + * + * Test ID: "ref::property named $ref, containing an actual $ref::property named $ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": 2 + } + """, + """ + { + "properties": { + "${'$'}ref": { + "${'$'}ref": "#/definitions/is-string" + } + }, + "definitions": { + "is-string": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::property named ${'$'}ref, containing an actual ${'$'}ref::property named ${'$'}ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$ref to boolean schema true -> any value is valid" + * + * Test ID: "ref::$ref to boolean schema true::any value is valid" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + { + "${'$'}ref": "#/definitions/bool" + } + ], + "definitions": { + "bool": true + } + } + """, + true, + """ schemaTestId: "ref::${'$'}ref to boolean schema true::any value is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$ref to boolean schema false -> any value is invalid" + * + * Test ID: "ref::$ref to boolean schema false::any value is invalid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + { + "${'$'}ref": "#/definitions/bool" + } + ], + "definitions": { + "bool": false + } + } + """, + false, + """ schemaTestId: "ref::${'$'}ref to boolean schema false::any value is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "Recursive references between schemas -> valid tree" + * + * Test ID: "ref::Recursive references between schemas::valid tree" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + { + "meta": "root", + "nodes": [ + { + "value": 1, + "subtree": { + "meta": "child", + "nodes": [ + { + "value": 1.1 + }, + { + "value": 1.2 + } + ] + } + }, + { + "value": 2, + "subtree": { + "meta": "child", + "nodes": [ + { + "value": 2.1 + }, + { + "value": 2.2 + } + ] + } + } + ] + } + """, + """ + { + "${'$'}id": "http://localhost:1234/tree", + "description": "tree of nodes", + "type": "object", + "properties": { + "meta": { + "type": "string" + }, + "nodes": { + "type": "array", + "items": { + "${'$'}ref": "node" + } + } + }, + "required": [ + "meta", + "nodes" + ], + "definitions": { + "node": { + "${'$'}id": "http://localhost:1234/node", + "description": "node", + "type": "object", + "properties": { + "value": { + "type": "number" + }, + "subtree": { + "${'$'}ref": "tree" + } + }, + "required": [ + "value" + ] + } + } + } + """, + true, + """ schemaTestId: "ref::Recursive references between schemas::valid tree" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "Recursive references between schemas -> invalid tree" + * + * Test ID: "ref::Recursive references between schemas::invalid tree" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + { + "meta": "root", + "nodes": [ + { + "value": 1, + "subtree": { + "meta": "child", + "nodes": [ + { + "value": "string is invalid" + }, + { + "value": 1.2 + } + ] + } + }, + { + "value": 2, + "subtree": { + "meta": "child", + "nodes": [ + { + "value": 2.1 + }, + { + "value": 2.2 + } + ] + } + } + ] + } + """, + """ + { + "${'$'}id": "http://localhost:1234/tree", + "description": "tree of nodes", + "type": "object", + "properties": { + "meta": { + "type": "string" + }, + "nodes": { + "type": "array", + "items": { + "${'$'}ref": "node" + } + } + }, + "required": [ + "meta", + "nodes" + ], + "definitions": { + "node": { + "${'$'}id": "http://localhost:1234/node", + "description": "node", + "type": "object", + "properties": { + "value": { + "type": "number" + }, + "subtree": { + "${'$'}ref": "tree" + } + }, + "required": [ + "value" + ] + } + } + } + """, + false, + """ schemaTestId: "ref::Recursive references between schemas::invalid tree" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "refs with quote -> object with numbers is valid" + * + * Test ID: "ref::refs with quote::object with numbers is valid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + { + "foo\"bar": 1 + } + """, + """ + { + "properties": { + "foo\"bar": { + "${'$'}ref": "#/definitions/foo%22bar" + } + }, + "definitions": { + "foo\"bar": { + "type": "number" + } + } + } + """, + true, + """ schemaTestId: "ref::refs with quote::object with numbers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "refs with quote -> object with strings is invalid" + * + * Test ID: "ref::refs with quote::object with strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + { + "foo\"bar": "1" + } + """, + """ + { + "properties": { + "foo\"bar": { + "${'$'}ref": "#/definitions/foo%22bar" + } + }, + "definitions": { + "foo\"bar": { + "type": "number" + } + } + } + """, + false, + """ schemaTestId: "ref::refs with quote::object with strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "Location-independent identifier -> match" + * + * Test ID: "ref::Location-independent identifier::match" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "allOf": [ + { + "${'$'}ref": "#foo" + } + ], + "definitions": { + "A": { + "${'$'}id": "#foo", + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "ref::Location-independent identifier::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "Location-independent identifier -> mismatch" + * + * Test ID: "ref::Location-independent identifier::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "allOf": [ + { + "${'$'}ref": "#foo" + } + ], + "definitions": { + "A": { + "${'$'}id": "#foo", + "type": "integer" + } + } + } + """, + false, + """ schemaTestId: "ref::Location-independent identifier::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "Reference an anchor with a non-relative URI -> match" + * + * Test ID: "ref::Reference an anchor with a non-relative URI::match" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}id": "https://example.com/schema-with-anchor", + "allOf": [ + { + "${'$'}ref": "https://example.com/schema-with-anchor#foo" + } + ], + "definitions": { + "A": { + "${'$'}id": "#foo", + "type": "integer" + } + } + } + """, + true, + """ schemaTestId: "ref::Reference an anchor with a non-relative URI::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "Reference an anchor with a non-relative URI -> mismatch" + * + * Test ID: "ref::Reference an anchor with a non-relative URI::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}id": "https://example.com/schema-with-anchor", + "allOf": [ + { + "${'$'}ref": "https://example.com/schema-with-anchor#foo" + } + ], + "definitions": { + "A": { + "${'$'}id": "#foo", + "type": "integer" + } + } + } + """, + false, + """ schemaTestId: "ref::Reference an anchor with a non-relative URI::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "Location-independent identifier with base URI change in subschema -> match" + * + * Test ID: "ref::Location-independent identifier with base URI change in subschema::match" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}id": "http://localhost:1234/root", + "allOf": [ + { + "${'$'}ref": "http://localhost:1234/nested.json#foo" + } + ], + "definitions": { + "A": { + "${'$'}id": "nested.json", + "definitions": { + "B": { + "${'$'}id": "#foo", + "type": "integer" + } + } + } + } + } + """, + true, + """ schemaTestId: "ref::Location-independent identifier with base URI change in subschema::match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "Location-independent identifier with base URI change in subschema -> mismatch" + * + * Test ID: "ref::Location-independent identifier with base URI change in subschema::mismatch" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}id": "http://localhost:1234/root", + "allOf": [ + { + "${'$'}ref": "http://localhost:1234/nested.json#foo" + } + ], + "definitions": { + "A": { + "${'$'}id": "nested.json", + "definitions": { + "B": { + "${'$'}id": "#foo", + "type": "integer" + } + } + } + } + } + """, + false, + """ schemaTestId: "ref::Location-independent identifier with base URI change in subschema::mismatch" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "naive replacement of $ref with its destination is not correct -> do not evaluate the $ref inside the enum, matching any string" + * + * Test ID: "ref::naive replacement of $ref with its destination is not correct::do not evaluate the $ref inside the enum, matching any string" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + "this is a string" + """, + """ + { + "definitions": { + "a_string": { + "type": "string" + } + }, + "enum": [ + { + "${'$'}ref": "#/definitions/a_string" + } + ] + } + """, + false, + """ schemaTestId: "ref::naive replacement of ${'$'}ref with its destination is not correct::do not evaluate the ${'$'}ref inside the enum, matching any string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "naive replacement of $ref with its destination is not correct -> do not evaluate the $ref inside the enum, definition exact match" + * + * Test ID: "ref::naive replacement of $ref with its destination is not correct::do not evaluate the $ref inside the enum, definition exact match" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + { + "type": "string" + } + """, + """ + { + "definitions": { + "a_string": { + "type": "string" + } + }, + "enum": [ + { + "${'$'}ref": "#/definitions/a_string" + } + ] + } + """, + false, + """ schemaTestId: "ref::naive replacement of ${'$'}ref with its destination is not correct::do not evaluate the ${'$'}ref inside the enum, definition exact match" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "naive replacement of $ref with its destination is not correct -> match the enum exactly" + * + * Test ID: "ref::naive replacement of $ref with its destination is not correct::match the enum exactly" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + { + "${'$'}ref": "#/definitions/a_string" + } + """, + """ + { + "definitions": { + "a_string": { + "type": "string" + } + }, + "enum": [ + { + "${'$'}ref": "#/definitions/a_string" + } + ] + } + """, + true, + """ schemaTestId: "ref::naive replacement of ${'$'}ref with its destination is not correct::match the enum exactly" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "refs with relative uris and defs -> invalid on inner field" + * + * Test ID: "ref::refs with relative uris and defs::invalid on inner field" + */ + @Test + fun jsonSchemaSuiteTest_43() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::refs with relative uris and defs::invalid on inner field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": 1 + }, + "bar": "a" + } + """, + """ + { + "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", + "properties": { + "foo": { + "${'$'}id": "schema-relative-uri-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/inner" + } + ] + } + }, + "allOf": [ + { + "${'$'}ref": "schema-relative-uri-defs2.json" + } + ] + } + """, + false, + """ schemaTestId: "ref::refs with relative uris and defs::invalid on inner field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "refs with relative uris and defs -> invalid on outer field" + * + * Test ID: "ref::refs with relative uris and defs::invalid on outer field" + */ + @Test + fun jsonSchemaSuiteTest_44() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::refs with relative uris and defs::invalid on outer field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "a" + }, + "bar": 1 + } + """, + """ + { + "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", + "properties": { + "foo": { + "${'$'}id": "schema-relative-uri-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/inner" + } + ] + } + }, + "allOf": [ + { + "${'$'}ref": "schema-relative-uri-defs2.json" + } + ] + } + """, + false, + """ schemaTestId: "ref::refs with relative uris and defs::invalid on outer field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "refs with relative uris and defs -> valid on both fields" + * + * Test ID: "ref::refs with relative uris and defs::valid on both fields" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "a" + }, + "bar": "a" + } + """, + """ + { + "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", + "properties": { + "foo": { + "${'$'}id": "schema-relative-uri-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/inner" + } + ] + } + }, + "allOf": [ + { + "${'$'}ref": "schema-relative-uri-defs2.json" + } + ] + } + """, + true, + """ schemaTestId: "ref::refs with relative uris and defs::valid on both fields" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "relative refs with absolute uris and defs -> invalid on inner field" + * + * Test ID: "ref::relative refs with absolute uris and defs::invalid on inner field" + */ + @Test + fun jsonSchemaSuiteTest_46() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::relative refs with absolute uris and defs::invalid on inner field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": 1 + }, + "bar": "a" + } + """, + """ + { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", + "properties": { + "foo": { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/inner" + } + ] + } + }, + "allOf": [ + { + "${'$'}ref": "schema-refs-absolute-uris-defs2.json" + } + ] + } + """, + false, + """ schemaTestId: "ref::relative refs with absolute uris and defs::invalid on inner field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "relative refs with absolute uris and defs -> invalid on outer field" + * + * Test ID: "ref::relative refs with absolute uris and defs::invalid on outer field" + */ + @Test + fun jsonSchemaSuiteTest_47() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::relative refs with absolute uris and defs::invalid on outer field" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "a" + }, + "bar": 1 + } + """, + """ + { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", + "properties": { + "foo": { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/inner" + } + ] + } + }, + "allOf": [ + { + "${'$'}ref": "schema-refs-absolute-uris-defs2.json" + } + ] + } + """, + false, + """ schemaTestId: "ref::relative refs with absolute uris and defs::invalid on outer field" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "relative refs with absolute uris and defs -> valid on both fields" + * + * Test ID: "ref::relative refs with absolute uris and defs::valid on both fields" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + { + "foo": { + "bar": "a" + }, + "bar": "a" + } + """, + """ + { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", + "properties": { + "foo": { + "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { + "type": "string" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/inner" + } + ] + } + }, + "allOf": [ + { + "${'$'}ref": "schema-refs-absolute-uris-defs2.json" + } + ] + } + """, + true, + """ schemaTestId: "ref::relative refs with absolute uris and defs::valid on both fields" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$id must be resolved against nearest parent, not just immediate parent -> number is valid" + * + * Test ID: "ref::$id must be resolved against nearest parent, not just immediate parent::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}id": "http://example.com/a.json", + "definitions": { + "x": { + "${'$'}id": "http://example.com/b/c.json", + "not": { + "definitions": { + "y": { + "${'$'}id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "http://example.com/b/d.json" + } + ] + } + """, + true, + """ schemaTestId: "ref::${'$'}id must be resolved against nearest parent, not just immediate parent::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$id must be resolved against nearest parent, not just immediate parent -> non-number is invalid" + * + * Test ID: "ref::$id must be resolved against nearest parent, not just immediate parent::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}id": "http://example.com/a.json", + "definitions": { + "x": { + "${'$'}id": "http://example.com/b/c.json", + "not": { + "definitions": { + "y": { + "${'$'}id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "http://example.com/b/d.json" + } + ] + } + """, + false, + """ schemaTestId: "ref::${'$'}id must be resolved against nearest parent, not just immediate parent::non-number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "simple URN base URI with $ref via the URN -> valid under the URN IDed schema" + * + * Test ID: "ref::simple URN base URI with $ref via the URN::valid under the URN IDed schema" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + { + "foo": 37 + } + """, + """ + { + "${'$'}comment": "URIs do not have to have HTTP(s) schemes", + "${'$'}id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed", + "minimum": 30, + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed" + } + } + } + """, + true, + """ schemaTestId: "ref::simple URN base URI with ${'$'}ref via the URN::valid under the URN IDed schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "simple URN base URI with $ref via the URN -> invalid under the URN IDed schema" + * + * Test ID: "ref::simple URN base URI with $ref via the URN::invalid under the URN IDed schema" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "URIs do not have to have HTTP(s) schemes", + "${'$'}id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed", + "minimum": 30, + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed" + } + } + } + """, + false, + """ schemaTestId: "ref::simple URN base URI with ${'$'}ref via the URN::invalid under the URN IDed schema" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "simple URN base URI with JSON pointer -> a string is valid" + * + * Test ID: "ref::simple URN base URI with JSON pointer::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}comment": "URIs do not have to have HTTP(s) schemes", + "${'$'}id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::simple URN base URI with JSON pointer::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "simple URN base URI with JSON pointer -> a non-string is invalid" + * + * Test ID: "ref::simple URN base URI with JSON pointer::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "URIs do not have to have HTTP(s) schemes", + "${'$'}id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::simple URN base URI with JSON pointer::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with NSS -> a string is valid" + * + * Test ID: "ref::URN base URI with NSS::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.2", + "${'$'}id": "urn:example:1/406/47452/2", + "properties": { + "foo": { + "${'$'}ref": "#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with NSS::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with NSS -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with NSS::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.2", + "${'$'}id": "urn:example:1/406/47452/2", + "properties": { + "foo": { + "${'$'}ref": "#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with NSS::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with r-component -> a string is valid" + * + * Test ID: "ref::URN base URI with r-component::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_57() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.3.1", + "${'$'}id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk", + "properties": { + "foo": { + "${'$'}ref": "#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with r-component::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with r-component -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with r-component::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.3.1", + "${'$'}id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk", + "properties": { + "foo": { + "${'$'}ref": "#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with r-component::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with q-component -> a string is valid" + * + * Test ID: "ref::URN base URI with q-component::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.3.2", + "${'$'}id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z", + "properties": { + "foo": { + "${'$'}ref": "#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with q-component::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with q-component -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with q-component::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_60() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}comment": "RFC 8141 §2.3.2", + "${'$'}id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z", + "properties": { + "foo": { + "${'$'}ref": "#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with q-component::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with URN and JSON pointer ref -> a string is valid" + * + * Test ID: "ref::URN base URI with URN and JSON pointer ref::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_61() { + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with URN and JSON pointer ref::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with URN and JSON pointer ref -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with URN and JSON pointer ref::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/definitions/bar" + } + }, + "definitions": { + "bar": { + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with URN and JSON pointer ref::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with URN and anchor ref -> a string is valid" + * + * Test ID: "ref::URN base URI with URN and anchor ref::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_63() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::URN base URI with URN and anchor ref::a string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": "bar" + } + """, + """ + { + "${'$'}id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something" + } + }, + "definitions": { + "bar": { + "${'$'}id": "#something", + "type": "string" + } + } + } + """, + true, + """ schemaTestId: "ref::URN base URI with URN and anchor ref::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "URN base URI with URN and anchor ref -> a non-string is invalid" + * + * Test ID: "ref::URN base URI with URN and anchor ref::a non-string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_64() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "ref::URN base URI with URN and anchor ref::a non-string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "foo": 12 + } + """, + """ + { + "${'$'}id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed", + "properties": { + "foo": { + "${'$'}ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something" + } + }, + "definitions": { + "bar": { + "${'$'}id": "#something", + "type": "string" + } + } + } + """, + false, + """ schemaTestId: "ref::URN base URI with URN and anchor ref::a non-string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref to if -> a non-integer is invalid due to the $ref" + * + * Test ID: "ref::ref to if::a non-integer is invalid due to the $ref" + */ + @Test + fun jsonSchemaSuiteTest_65() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + { + "${'$'}ref": "http://example.com/ref/if" + }, + { + "if": { + "${'$'}id": "http://example.com/ref/if", + "type": "integer" + } + } + ] + } + """, + false, + """ schemaTestId: "ref::ref to if::a non-integer is invalid due to the ${'$'}ref" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref to if -> an integer is valid" + * + * Test ID: "ref::ref to if::an integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_66() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "allOf": [ + { + "${'$'}ref": "http://example.com/ref/if" + }, + { + "if": { + "${'$'}id": "http://example.com/ref/if", + "type": "integer" + } + } + ] + } + """, + true, + """ schemaTestId: "ref::ref to if::an integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref to then -> a non-integer is invalid due to the $ref" + * + * Test ID: "ref::ref to then::a non-integer is invalid due to the $ref" + */ + @Test + fun jsonSchemaSuiteTest_67() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + { + "${'$'}ref": "http://example.com/ref/then" + }, + { + "then": { + "${'$'}id": "http://example.com/ref/then", + "type": "integer" + } + } + ] + } + """, + false, + """ schemaTestId: "ref::ref to then::a non-integer is invalid due to the ${'$'}ref" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref to then -> an integer is valid" + * + * Test ID: "ref::ref to then::an integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_68() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "allOf": [ + { + "${'$'}ref": "http://example.com/ref/then" + }, + { + "then": { + "${'$'}id": "http://example.com/ref/then", + "type": "integer" + } + } + ] + } + """, + true, + """ schemaTestId: "ref::ref to then::an integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref to else -> a non-integer is invalid due to the $ref" + * + * Test ID: "ref::ref to else::a non-integer is invalid due to the $ref" + */ + @Test + fun jsonSchemaSuiteTest_69() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "allOf": [ + { + "${'$'}ref": "http://example.com/ref/else" + }, + { + "else": { + "${'$'}id": "http://example.com/ref/else", + "type": "integer" + } + } + ] + } + """, + false, + """ schemaTestId: "ref::ref to else::a non-integer is invalid due to the ${'$'}ref" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref to else -> an integer is valid" + * + * Test ID: "ref::ref to else::an integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_70() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "allOf": [ + { + "${'$'}ref": "http://example.com/ref/else" + }, + { + "else": { + "${'$'}id": "http://example.com/ref/else", + "type": "integer" + } + } + ] + } + """, + true, + """ schemaTestId: "ref::ref to else::an integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref with absolute-path-reference -> a string is valid" + * + * Test ID: "ref::ref with absolute-path-reference::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_71() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}id": "http://example.com/ref/absref.json", + "definitions": { + "a": { + "${'$'}id": "http://example.com/ref/absref/foobar.json", + "type": "number" + }, + "b": { + "${'$'}id": "http://example.com/absref/foobar.json", + "type": "string" + } + }, + "allOf": [ + { + "${'$'}ref": "/absref/foobar.json" + } + ] + } + """, + true, + """ schemaTestId: "ref::ref with absolute-path-reference::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "ref with absolute-path-reference -> an integer is invalid" + * + * Test ID: "ref::ref with absolute-path-reference::an integer is invalid" + */ + @Test + fun jsonSchemaSuiteTest_72() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "${'$'}id": "http://example.com/ref/absref.json", + "definitions": { + "a": { + "${'$'}id": "http://example.com/ref/absref/foobar.json", + "type": "number" + }, + "b": { + "${'$'}id": "http://example.com/absref/foobar.json", + "type": "string" + } + }, + "allOf": [ + { + "${'$'}ref": "/absref/foobar.json" + } + ] + } + """, + false, + """ schemaTestId: "ref::ref with absolute-path-reference::an integer is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$id with file URI still resolves pointers - *nix -> number is valid" + * + * Test ID: "ref::$id with file URI still resolves pointers - *nix::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_73() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}id": "file:///folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/foo" + } + ] + } + """, + true, + """ schemaTestId: "ref::${'$'}id with file URI still resolves pointers - *nix::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$id with file URI still resolves pointers - *nix -> non-number is invalid" + * + * Test ID: "ref::$id with file URI still resolves pointers - *nix::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_74() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}id": "file:///folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/foo" + } + ] + } + """, + false, + """ schemaTestId: "ref::${'$'}id with file URI still resolves pointers - *nix::non-number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$id with file URI still resolves pointers - windows -> number is valid" + * + * Test ID: "ref::$id with file URI still resolves pointers - windows::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_75() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}id": "file:///c:/folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/foo" + } + ] + } + """, + true, + """ schemaTestId: "ref::${'$'}id with file URI still resolves pointers - windows::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "$id with file URI still resolves pointers - windows -> non-number is invalid" + * + * Test ID: "ref::$id with file URI still resolves pointers - windows::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_76() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}id": "file:///c:/folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions/foo" + } + ] + } + """, + false, + """ schemaTestId: "ref::${'$'}id with file URI still resolves pointers - windows::non-number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "empty tokens in $ref json-pointer -> number is valid" + * + * Test ID: "ref::empty tokens in $ref json-pointer::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_77() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "definitions": { + "": { + "definitions": { + "": { + "type": "number" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions//definitions/" + } + ] + } + """, + true, + """ schemaTestId: "ref::empty tokens in ${'$'}ref json-pointer::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: + * "empty tokens in $ref json-pointer -> non-number is invalid" + * + * Test ID: "ref::empty tokens in $ref json-pointer::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_78() { + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "definitions": { + "": { + "definitions": { + "": { + "type": "number" + } + } + } + }, + "allOf": [ + { + "${'$'}ref": "#/definitions//definitions/" + } + ] + } + """, + false, + """ schemaTestId: "ref::empty tokens in ${'$'}ref json-pointer::non-number is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_refRemote.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_refRemote.kt new file mode 100644 index 00000000..957547f3 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_refRemote.kt @@ -0,0 +1,821 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_refRemote : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "remote ref -> remote ref valid" + * + * Test ID: "refRemote::remote ref::remote ref valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote ref::remote ref valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}ref": "http://localhost:1234/integer.json" + } + """, + true, + """ schemaTestId: "refRemote::remote ref::remote ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "remote ref -> remote ref invalid" + * + * Test ID: "refRemote::remote ref::remote ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote ref::remote ref invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}ref": "http://localhost:1234/integer.json" + } + """, + false, + """ schemaTestId: "refRemote::remote ref::remote ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "fragment within remote ref -> remote fragment valid" + * + * Test ID: "refRemote::fragment within remote ref::remote fragment valid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::fragment within remote ref::remote fragment valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}ref": "http://localhost:1234/subSchemas.json#/definitions/integer" + } + """, + true, + """ schemaTestId: "refRemote::fragment within remote ref::remote fragment valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "fragment within remote ref -> remote fragment invalid" + * + * Test ID: "refRemote::fragment within remote ref::remote fragment invalid" + */ + @Test + fun jsonSchemaSuiteTest_4() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::fragment within remote ref::remote fragment invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}ref": "http://localhost:1234/subSchemas.json#/definitions/integer" + } + """, + false, + """ schemaTestId: "refRemote::fragment within remote ref::remote fragment invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "ref within remote ref -> ref within ref valid" + * + * Test ID: "refRemote::ref within remote ref::ref within ref valid" + */ + @Test + fun jsonSchemaSuiteTest_5() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::ref within remote ref::ref within ref valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}ref": "http://localhost:1234/subSchemas.json#/definitions/refToInteger" + } + """, + true, + """ schemaTestId: "refRemote::ref within remote ref::ref within ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "ref within remote ref -> ref within ref invalid" + * + * Test ID: "refRemote::ref within remote ref::ref within ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_6() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::ref within remote ref::ref within ref invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}ref": "http://localhost:1234/subSchemas.json#/definitions/refToInteger" + } + """, + false, + """ schemaTestId: "refRemote::ref within remote ref::ref within ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "base URI change -> base URI change ref valid" + * + * Test ID: "refRemote::base URI change::base URI change ref valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change::base URI change ref valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + [ + 1 + ] + ] + """, + """ + { + "${'$'}id": "http://localhost:1234/", + "items": { + "${'$'}id": "baseUriChange/", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + """, + true, + """ schemaTestId: "refRemote::base URI change::base URI change ref valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "base URI change -> base URI change ref invalid" + * + * Test ID: "refRemote::base URI change::base URI change ref invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change::base URI change ref invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + [ + "a" + ] + ] + """, + """ + { + "${'$'}id": "http://localhost:1234/", + "items": { + "${'$'}id": "baseUriChange/", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + """, + false, + """ schemaTestId: "refRemote::base URI change::base URI change ref invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "base URI change - change folder -> number is valid" + * + * Test ID: "refRemote::base URI change - change folder::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change - change folder::number is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "list": [ + 1 + ] + } + """, + """ + { + "${'$'}id": "http://localhost:1234/scope_change_defs1.json", + "type": "object", + "properties": { + "list": { + "${'$'}ref": "#/definitions/baz" + } + }, + "definitions": { + "baz": { + "${'$'}id": "baseUriChangeFolder/", + "type": "array", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + } + """, + true, + """ schemaTestId: "refRemote::base URI change - change folder::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "base URI change - change folder -> string is invalid" + * + * Test ID: "refRemote::base URI change - change folder::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change - change folder::string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "list": [ + "a" + ] + } + """, + """ + { + "${'$'}id": "http://localhost:1234/scope_change_defs1.json", + "type": "object", + "properties": { + "list": { + "${'$'}ref": "#/definitions/baz" + } + }, + "definitions": { + "baz": { + "${'$'}id": "baseUriChangeFolder/", + "type": "array", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + } + """, + false, + """ schemaTestId: "refRemote::base URI change - change folder::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "base URI change - change folder in subschema -> number is valid" + * + * Test ID: "refRemote::base URI change - change folder in subschema::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_11() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change - change folder in subschema::number is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "list": [ + 1 + ] + } + """, + """ + { + "${'$'}id": "http://localhost:1234/scope_change_defs2.json", + "type": "object", + "properties": { + "list": { + "${'$'}ref": "#/definitions/baz/definitions/bar" + } + }, + "definitions": { + "baz": { + "${'$'}id": "baseUriChangeFolderInSubschema/", + "definitions": { + "bar": { + "type": "array", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + } + } + } + """, + true, + """ schemaTestId: "refRemote::base URI change - change folder in subschema::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "base URI change - change folder in subschema -> string is invalid" + * + * Test ID: "refRemote::base URI change - change folder in subschema::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::base URI change - change folder in subschema::string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "list": [ + "a" + ] + } + """, + """ + { + "${'$'}id": "http://localhost:1234/scope_change_defs2.json", + "type": "object", + "properties": { + "list": { + "${'$'}ref": "#/definitions/baz/definitions/bar" + } + }, + "definitions": { + "baz": { + "${'$'}id": "baseUriChangeFolderInSubschema/", + "definitions": { + "bar": { + "type": "array", + "items": { + "${'$'}ref": "folderInteger.json" + } + } + } + } + } + } + """, + false, + """ schemaTestId: "refRemote::base URI change - change folder in subschema::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "root ref in remote ref -> string is valid" + * + * Test ID: "refRemote::root ref in remote ref::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::root ref in remote ref::string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": "foo" + } + """, + """ + { + "${'$'}id": "http://localhost:1234/object", + "type": "object", + "properties": { + "name": { + "${'$'}ref": "name.json#/definitions/orNull" + } + } + } + """, + true, + """ schemaTestId: "refRemote::root ref in remote ref::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "root ref in remote ref -> null is valid" + * + * Test ID: "refRemote::root ref in remote ref::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::root ref in remote ref::null is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": null + } + """, + """ + { + "${'$'}id": "http://localhost:1234/object", + "type": "object", + "properties": { + "name": { + "${'$'}ref": "name.json#/definitions/orNull" + } + } + } + """, + true, + """ schemaTestId: "refRemote::root ref in remote ref::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "root ref in remote ref -> object is invalid" + * + * Test ID: "refRemote::root ref in remote ref::object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::root ref in remote ref::object is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": { + "name": null + } + } + """, + """ + { + "${'$'}id": "http://localhost:1234/object", + "type": "object", + "properties": { + "name": { + "${'$'}ref": "name.json#/definitions/orNull" + } + } + } + """, + false, + """ schemaTestId: "refRemote::root ref in remote ref::object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "remote ref with ref to definitions -> invalid" + * + * Test ID: "refRemote::remote ref with ref to definitions::invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote ref with ref to definitions::invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "${'$'}id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", + "allOf": [ + { + "${'$'}ref": "ref-and-definitions.json" + } + ] + } + """, + false, + """ schemaTestId: "refRemote::remote ref with ref to definitions::invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "remote ref with ref to definitions -> valid" + * + * Test ID: "refRemote::remote ref with ref to definitions::valid" + */ + @Test + fun jsonSchemaSuiteTest_17() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::remote ref with ref to definitions::valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "bar": "a" + } + """, + """ + { + "${'$'}id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", + "allOf": [ + { + "${'$'}ref": "ref-and-definitions.json" + } + ] + } + """, + true, + """ schemaTestId: "refRemote::remote ref with ref to definitions::valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "Location-independent identifier in remote ref -> integer is valid" + * + * Test ID: "refRemote::Location-independent identifier in remote ref::integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_18() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::Location-independent identifier in remote ref::integer is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}ref": "http://localhost:1234/locationIndependentIdentifierPre2019.json#/definitions/refToInteger" + } + """, + true, + """ schemaTestId: "refRemote::Location-independent identifier in remote ref::integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "Location-independent identifier in remote ref -> string is invalid" + * + * Test ID: "refRemote::Location-independent identifier in remote ref::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_19() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::Location-independent identifier in remote ref::string is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "${'$'}ref": "http://localhost:1234/locationIndependentIdentifierPre2019.json#/definitions/refToInteger" + } + """, + false, + """ schemaTestId: "refRemote::Location-independent identifier in remote ref::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "retrieved nested refs resolve relative to their URI not $id -> number is invalid" + * + * Test ID: "refRemote::retrieved nested refs resolve relative to their URI not $id::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_20() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::retrieved nested refs resolve relative to their URI not $id::number is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": { + "foo": 1 + } + } + """, + """ + { + "${'$'}id": "http://localhost:1234/some-id", + "properties": { + "name": { + "${'$'}ref": "nested/foo-ref-string.json" + } + } + } + """, + false, + """ schemaTestId: "refRemote::retrieved nested refs resolve relative to their URI not ${'$'}id::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "retrieved nested refs resolve relative to their URI not $id -> string is valid" + * + * Test ID: "refRemote::retrieved nested refs resolve relative to their URI not $id::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_21() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::retrieved nested refs resolve relative to their URI not $id::string is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + { + "name": { + "foo": "a" + } + } + """, + """ + { + "${'$'}id": "http://localhost:1234/some-id", + "properties": { + "name": { + "${'$'}ref": "nested/foo-ref-string.json" + } + } + } + """, + true, + """ schemaTestId: "refRemote::retrieved nested refs resolve relative to their URI not ${'$'}id::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "$ref to $ref finds location-independent $id -> number is valid" + * + * Test ID: "refRemote::$ref to $ref finds location-independent $id::number is valid" + */ + @Test + fun jsonSchemaSuiteTest_22() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::$ref to $ref finds location-independent $id::number is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "${'$'}ref": "http://localhost:1234/draft7/detached-ref.json#/definitions/foo" + } + """, + true, + """ schemaTestId: "refRemote::${'$'}ref to ${'$'}ref finds location-independent ${'$'}id::number is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: + * "$ref to $ref finds location-independent $id -> non-number is invalid" + * + * Test ID: "refRemote::$ref to $ref finds location-independent $id::non-number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "refRemote::$ref to $ref finds location-independent $id::non-number is invalid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + "a" + """, + """ + { + "${'$'}ref": "http://localhost:1234/draft7/detached-ref.json#/definitions/foo" + } + """, + false, + """ schemaTestId: "refRemote::${'$'}ref to ${'$'}ref finds location-independent ${'$'}id::non-number is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_required.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_required.kt new file mode 100644 index 00000000..4d804970 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_required.kt @@ -0,0 +1,492 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_required : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required validation -> present required property is valid" + * + * Test ID: "required::required validation::present required property is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + { + "foo": 1 + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + true, + """ schemaTestId: "required::required validation::present required property is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required validation -> non-present required property is invalid" + * + * Test ID: "required::required validation::non-present required property is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + { + "bar": 1 + } + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + false, + """ schemaTestId: "required::required validation::non-present required property is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required validation -> ignores arrays" + * + * Test ID: "required::required validation::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + true, + """ schemaTestId: "required::required validation::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required validation -> ignores strings" + * + * Test ID: "required::required validation::ignores strings" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + true, + """ schemaTestId: "required::required validation::ignores strings" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required validation -> ignores other non-objects" + * + * Test ID: "required::required validation::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "properties": { + "foo": { + }, + "bar": { + } + }, + "required": [ + "foo" + ] + } + """, + true, + """ schemaTestId: "required::required validation::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required default validation -> not required by default" + * + * Test ID: "required::required default validation::not required by default" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "properties": { + "foo": { + } + } + } + """, + true, + """ schemaTestId: "required::required default validation::not required by default" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required with empty array -> property not required" + * + * Test ID: "required::required with empty array::property not required" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "properties": { + "foo": { + } + }, + "required": [ + ] + } + """, + true, + """ schemaTestId: "required::required with empty array::property not required" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required with escaped characters -> object with all properties present is valid" + * + * Test ID: "required::required with escaped characters::object with all properties present is valid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": 1, + "foo\"bar": 1, + "foo\\bar": 1, + "foo\rbar": 1, + "foo\tbar": 1, + "foo\fbar": 1 + } + """, + """ + { + "required": [ + "foo\nbar", + "foo\"bar", + "foo\\bar", + "foo\rbar", + "foo\tbar", + "foo\fbar" + ] + } + """, + true, + """ schemaTestId: "required::required with escaped characters::object with all properties present is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required with escaped characters -> object with some properties missing is invalid" + * + * Test ID: "required::required with escaped characters::object with some properties missing is invalid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + { + "foo\nbar": "1", + "foo\"bar": "1" + } + """, + """ + { + "required": [ + "foo\nbar", + "foo\"bar", + "foo\\bar", + "foo\rbar", + "foo\tbar", + "foo\fbar" + ] + } + """, + false, + """ schemaTestId: "required::required with escaped characters::object with some properties missing is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required properties whose names are Javascript object property names -> ignores arrays" + * + * Test ID: "required::required properties whose names are Javascript object property names::ignores arrays" + */ + @Test + fun jsonSchemaSuiteTest_10() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + true, + """ schemaTestId: "required::required properties whose names are Javascript object property names::ignores arrays" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required properties whose names are Javascript object property names -> ignores other non-objects" + * + * Test ID: "required::required properties whose names are Javascript object property names::ignores other non-objects" + */ + @Test + fun jsonSchemaSuiteTest_11() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + 12 + """, + """ + { + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + true, + """ schemaTestId: "required::required properties whose names are Javascript object property names::ignores other non-objects" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required properties whose names are Javascript object property names -> none of the properties mentioned" + * + * Test ID: "required::required properties whose names are Javascript object property names::none of the properties mentioned" + */ + @Test + fun jsonSchemaSuiteTest_12() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + false, + """ schemaTestId: "required::required properties whose names are Javascript object property names::none of the properties mentioned" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required properties whose names are Javascript object property names -> __proto__ present" + * + * Test ID: "required::required properties whose names are Javascript object property names::__proto__ present" + */ + @Test + fun jsonSchemaSuiteTest_13() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "__proto__": "foo" + } + """, + """ + { + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + false, + """ schemaTestId: "required::required properties whose names are Javascript object property names::__proto__ present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required properties whose names are Javascript object property names -> toString present" + * + * Test ID: "required::required properties whose names are Javascript object property names::toString present" + */ + @Test + fun jsonSchemaSuiteTest_14() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "toString": { + "length": 37 + } + } + """, + """ + { + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + false, + """ schemaTestId: "required::required properties whose names are Javascript object property names::toString present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required properties whose names are Javascript object property names -> constructor present" + * + * Test ID: "required::required properties whose names are Javascript object property names::constructor present" + */ + @Test + fun jsonSchemaSuiteTest_15() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "constructor": { + "length": 37 + } + } + """, + """ + { + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + false, + """ schemaTestId: "required::required properties whose names are Javascript object property names::constructor present" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: + * "required properties whose names are Javascript object property names -> all present" + * + * Test ID: "required::required properties whose names are Javascript object property names::all present" + */ + @Test + fun jsonSchemaSuiteTest_16() { + // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. + assertKsonEnforcesSchema( + """ + { + "__proto__": 12, + "toString": { + "length": "foo" + }, + "constructor": 37 + } + """, + """ + { + "required": [ + "__proto__", + "toString", + "constructor" + ] + } + """, + true, + """ schemaTestId: "required::required properties whose names are Javascript object property names::all present" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_type.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_type.kt new file mode 100644 index 00000000..e5629ab4 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_type.kt @@ -0,0 +1,1863 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_type : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> an integer is an integer" + * + * Test ID: "type::integer type matches integers::an integer is an integer" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "type": "integer" + } + """, + true, + """ schemaTestId: "type::integer type matches integers::an integer is an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> a float with zero fractional part is an integer" + * + * Test ID: "type::integer type matches integers::a float with zero fractional part is an integer" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "type": "integer" + } + """, + true, + """ schemaTestId: "type::integer type matches integers::a float with zero fractional part is an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> a float is not an integer" + * + * Test ID: "type::integer type matches integers::a float is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::a float is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> a string is not an integer" + * + * Test ID: "type::integer type matches integers::a string is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::a string is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> a string is still not an integer, even if it looks like one" + * + * Test ID: "type::integer type matches integers::a string is still not an integer, even if it looks like one" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + "1" + """, + """ + { + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::a string is still not an integer, even if it looks like one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> an object is not an integer" + * + * Test ID: "type::integer type matches integers::an object is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::an object is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> an array is not an integer" + * + * Test ID: "type::integer type matches integers::an array is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::an array is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> a boolean is not an integer" + * + * Test ID: "type::integer type matches integers::a boolean is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::a boolean is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "integer type matches integers -> null is not an integer" + * + * Test ID: "type::integer type matches integers::null is not an integer" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": "integer" + } + """, + false, + """ schemaTestId: "type::integer type matches integers::null is not an integer" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> an integer is a number" + * + * Test ID: "type::number type matches numbers::an integer is a number" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "type": "number" + } + """, + true, + """ schemaTestId: "type::number type matches numbers::an integer is a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> a float with zero fractional part is a number (and an integer)" + * + * Test ID: "type::number type matches numbers::a float with zero fractional part is a number (and an integer)" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + 1.0 + """, + """ + { + "type": "number" + } + """, + true, + """ schemaTestId: "type::number type matches numbers::a float with zero fractional part is a number (and an integer)" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> a float is a number" + * + * Test ID: "type::number type matches numbers::a float is a number" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "type": "number" + } + """, + true, + """ schemaTestId: "type::number type matches numbers::a float is a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> a string is not a number" + * + * Test ID: "type::number type matches numbers::a string is not a number" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::a string is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> a string is still not a number, even if it looks like one" + * + * Test ID: "type::number type matches numbers::a string is still not a number, even if it looks like one" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + "1" + """, + """ + { + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::a string is still not a number, even if it looks like one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> an object is not a number" + * + * Test ID: "type::number type matches numbers::an object is not a number" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::an object is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> an array is not a number" + * + * Test ID: "type::number type matches numbers::an array is not a number" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::an array is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> a boolean is not a number" + * + * Test ID: "type::number type matches numbers::a boolean is not a number" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::a boolean is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "number type matches numbers -> null is not a number" + * + * Test ID: "type::number type matches numbers::null is not a number" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": "number" + } + """, + false, + """ schemaTestId: "type::number type matches numbers::null is not a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> 1 is not a string" + * + * Test ID: "type::string type matches strings::1 is not a string" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::1 is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> a float is not a string" + * + * Test ID: "type::string type matches strings::a float is not a string" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::a float is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> a string is a string" + * + * Test ID: "type::string type matches strings::a string is a string" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "string" + } + """, + true, + """ schemaTestId: "type::string type matches strings::a string is a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> a string is still a string, even if it looks like a number" + * + * Test ID: "type::string type matches strings::a string is still a string, even if it looks like a number" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + "1" + """, + """ + { + "type": "string" + } + """, + true, + """ schemaTestId: "type::string type matches strings::a string is still a string, even if it looks like a number" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> an empty string is still a string" + * + * Test ID: "type::string type matches strings::an empty string is still a string" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "type": "string" + } + """, + true, + """ schemaTestId: "type::string type matches strings::an empty string is still a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> an object is not a string" + * + * Test ID: "type::string type matches strings::an object is not a string" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::an object is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> an array is not a string" + * + * Test ID: "type::string type matches strings::an array is not a string" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::an array is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> a boolean is not a string" + * + * Test ID: "type::string type matches strings::a boolean is not a string" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::a boolean is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "string type matches strings -> null is not a string" + * + * Test ID: "type::string type matches strings::null is not a string" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": "string" + } + """, + false, + """ schemaTestId: "type::string type matches strings::null is not a string" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "object type matches objects -> an integer is not an object" + * + * Test ID: "type::object type matches objects::an integer is not an object" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::an integer is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "object type matches objects -> a float is not an object" + * + * Test ID: "type::object type matches objects::a float is not an object" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::a float is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "object type matches objects -> a string is not an object" + * + * Test ID: "type::object type matches objects::a string is not an object" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::a string is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "object type matches objects -> an object is an object" + * + * Test ID: "type::object type matches objects::an object is an object" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "object" + } + """, + true, + """ schemaTestId: "type::object type matches objects::an object is an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "object type matches objects -> an array is not an object" + * + * Test ID: "type::object type matches objects::an array is not an object" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::an array is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "object type matches objects -> a boolean is not an object" + * + * Test ID: "type::object type matches objects::a boolean is not an object" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::a boolean is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "object type matches objects -> null is not an object" + * + * Test ID: "type::object type matches objects::null is not an object" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": "object" + } + """, + false, + """ schemaTestId: "type::object type matches objects::null is not an object" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "array type matches arrays -> an integer is not an array" + * + * Test ID: "type::array type matches arrays::an integer is not an array" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::an integer is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "array type matches arrays -> a float is not an array" + * + * Test ID: "type::array type matches arrays::a float is not an array" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::a float is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "array type matches arrays -> a string is not an array" + * + * Test ID: "type::array type matches arrays::a string is not an array" + */ + @Test + fun jsonSchemaSuiteTest_37() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::a string is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "array type matches arrays -> an object is not an array" + * + * Test ID: "type::array type matches arrays::an object is not an array" + */ + @Test + fun jsonSchemaSuiteTest_38() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::an object is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "array type matches arrays -> an array is an array" + * + * Test ID: "type::array type matches arrays::an array is an array" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "type": "array" + } + """, + true, + """ schemaTestId: "type::array type matches arrays::an array is an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "array type matches arrays -> a boolean is not an array" + * + * Test ID: "type::array type matches arrays::a boolean is not an array" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::a boolean is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "array type matches arrays -> null is not an array" + * + * Test ID: "type::array type matches arrays::null is not an array" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": "array" + } + """, + false, + """ schemaTestId: "type::array type matches arrays::null is not an array" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> an integer is not a boolean" + * + * Test ID: "type::boolean type matches booleans::an integer is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::an integer is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> zero is not a boolean" + * + * Test ID: "type::boolean type matches booleans::zero is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::zero is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> a float is not a boolean" + * + * Test ID: "type::boolean type matches booleans::a float is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::a float is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> a string is not a boolean" + * + * Test ID: "type::boolean type matches booleans::a string is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::a string is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> an empty string is not a boolean" + * + * Test ID: "type::boolean type matches booleans::an empty string is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::an empty string is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> an object is not a boolean" + * + * Test ID: "type::boolean type matches booleans::an object is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::an object is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> an array is not a boolean" + * + * Test ID: "type::boolean type matches booleans::an array is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::an array is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> true is a boolean" + * + * Test ID: "type::boolean type matches booleans::true is a boolean" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "type": "boolean" + } + """, + true, + """ schemaTestId: "type::boolean type matches booleans::true is a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> false is a boolean" + * + * Test ID: "type::boolean type matches booleans::false is a boolean" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "type": "boolean" + } + """, + true, + """ schemaTestId: "type::boolean type matches booleans::false is a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "boolean type matches booleans -> null is not a boolean" + * + * Test ID: "type::boolean type matches booleans::null is not a boolean" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": "boolean" + } + """, + false, + """ schemaTestId: "type::boolean type matches booleans::null is not a boolean" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> an integer is not null" + * + * Test ID: "type::null type matches only the null object::an integer is not null" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::an integer is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> a float is not null" + * + * Test ID: "type::null type matches only the null object::a float is not null" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::a float is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> zero is not null" + * + * Test ID: "type::null type matches only the null object::zero is not null" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + 0 + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::zero is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> a string is not null" + * + * Test ID: "type::null type matches only the null object::a string is not null" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::a string is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> an empty string is not null" + * + * Test ID: "type::null type matches only the null object::an empty string is not null" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + "" + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::an empty string is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> an object is not null" + * + * Test ID: "type::null type matches only the null object::an object is not null" + */ + @Test + fun jsonSchemaSuiteTest_57() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::an object is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> an array is not null" + * + * Test ID: "type::null type matches only the null object::an array is not null" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::an array is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> true is not null" + * + * Test ID: "type::null type matches only the null object::true is not null" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::true is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> false is not null" + * + * Test ID: "type::null type matches only the null object::false is not null" + */ + @Test + fun jsonSchemaSuiteTest_60() { + + assertKsonEnforcesSchema( + """ + false + """, + """ + { + "type": "null" + } + """, + false, + """ schemaTestId: "type::null type matches only the null object::false is not null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "null type matches only the null object -> null is null" + * + * Test ID: "type::null type matches only the null object::null is null" + */ + @Test + fun jsonSchemaSuiteTest_61() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": "null" + } + """, + true, + """ schemaTestId: "type::null type matches only the null object::null is null" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "multiple types can be specified in an array -> an integer is valid" + * + * Test ID: "type::multiple types can be specified in an array::an integer is valid" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + 1 + """, + """ + { + "type": [ + "integer", + "string" + ] + } + """, + true, + """ schemaTestId: "type::multiple types can be specified in an array::an integer is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "multiple types can be specified in an array -> a string is valid" + * + * Test ID: "type::multiple types can be specified in an array::a string is valid" + */ + @Test + fun jsonSchemaSuiteTest_63() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": [ + "integer", + "string" + ] + } + """, + true, + """ schemaTestId: "type::multiple types can be specified in an array::a string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "multiple types can be specified in an array -> a float is invalid" + * + * Test ID: "type::multiple types can be specified in an array::a float is invalid" + */ + @Test + fun jsonSchemaSuiteTest_64() { + + assertKsonEnforcesSchema( + """ + 1.1 + """, + """ + { + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::a float is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "multiple types can be specified in an array -> an object is invalid" + * + * Test ID: "type::multiple types can be specified in an array::an object is invalid" + */ + @Test + fun jsonSchemaSuiteTest_65() { + + assertKsonEnforcesSchema( + """ + { + } + """, + """ + { + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::an object is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "multiple types can be specified in an array -> an array is invalid" + * + * Test ID: "type::multiple types can be specified in an array::an array is invalid" + */ + @Test + fun jsonSchemaSuiteTest_66() { + + assertKsonEnforcesSchema( + """ + [ + ] + """, + """ + { + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::an array is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "multiple types can be specified in an array -> a boolean is invalid" + * + * Test ID: "type::multiple types can be specified in an array::a boolean is invalid" + */ + @Test + fun jsonSchemaSuiteTest_67() { + + assertKsonEnforcesSchema( + """ + true + """, + """ + { + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::a boolean is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "multiple types can be specified in an array -> null is invalid" + * + * Test ID: "type::multiple types can be specified in an array::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_68() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": [ + "integer", + "string" + ] + } + """, + false, + """ schemaTestId: "type::multiple types can be specified in an array::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type as array with one item -> string is valid" + * + * Test ID: "type::type as array with one item::string is valid" + */ + @Test + fun jsonSchemaSuiteTest_69() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": [ + "string" + ] + } + """, + true, + """ schemaTestId: "type::type as array with one item::string is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type as array with one item -> number is invalid" + * + * Test ID: "type::type as array with one item::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_70() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "type": [ + "string" + ] + } + """, + false, + """ schemaTestId: "type::type as array with one item::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array or object -> array is valid" + * + * Test ID: "type::type: array or object::array is valid" + */ + @Test + fun jsonSchemaSuiteTest_71() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "type": [ + "array", + "object" + ] + } + """, + true, + """ schemaTestId: "type::type: array or object::array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array or object -> object is valid" + * + * Test ID: "type::type: array or object::object is valid" + */ + @Test + fun jsonSchemaSuiteTest_72() { + + assertKsonEnforcesSchema( + """ + { + "foo": 123 + } + """, + """ + { + "type": [ + "array", + "object" + ] + } + """, + true, + """ schemaTestId: "type::type: array or object::object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array or object -> number is invalid" + * + * Test ID: "type::type: array or object::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_73() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "type": [ + "array", + "object" + ] + } + """, + false, + """ schemaTestId: "type::type: array or object::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array or object -> string is invalid" + * + * Test ID: "type::type: array or object::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_74() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": [ + "array", + "object" + ] + } + """, + false, + """ schemaTestId: "type::type: array or object::string is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array or object -> null is invalid" + * + * Test ID: "type::type: array or object::null is invalid" + */ + @Test + fun jsonSchemaSuiteTest_75() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": [ + "array", + "object" + ] + } + """, + false, + """ schemaTestId: "type::type: array or object::null is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array, object or null -> array is valid" + * + * Test ID: "type::type: array, object or null::array is valid" + */ + @Test + fun jsonSchemaSuiteTest_76() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 3 + ] + """, + """ + { + "type": [ + "array", + "object", + "null" + ] + } + """, + true, + """ schemaTestId: "type::type: array, object or null::array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array, object or null -> object is valid" + * + * Test ID: "type::type: array, object or null::object is valid" + */ + @Test + fun jsonSchemaSuiteTest_77() { + + assertKsonEnforcesSchema( + """ + { + "foo": 123 + } + """, + """ + { + "type": [ + "array", + "object", + "null" + ] + } + """, + true, + """ schemaTestId: "type::type: array, object or null::object is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array, object or null -> null is valid" + * + * Test ID: "type::type: array, object or null::null is valid" + */ + @Test + fun jsonSchemaSuiteTest_78() { + + assertKsonEnforcesSchema( + """ + null + """, + """ + { + "type": [ + "array", + "object", + "null" + ] + } + """, + true, + """ schemaTestId: "type::type: array, object or null::null is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array, object or null -> number is invalid" + * + * Test ID: "type::type: array, object or null::number is invalid" + */ + @Test + fun jsonSchemaSuiteTest_79() { + + assertKsonEnforcesSchema( + """ + 123 + """, + """ + { + "type": [ + "array", + "object", + "null" + ] + } + """, + false, + """ schemaTestId: "type::type: array, object or null::number is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: + * "type: array, object or null -> string is invalid" + * + * Test ID: "type::type: array, object or null::string is invalid" + */ + @Test + fun jsonSchemaSuiteTest_80() { + + assertKsonEnforcesSchema( + """ + "foo" + """, + """ + { + "type": [ + "array", + "object", + "null" + ] + } + """, + false, + """ schemaTestId: "type::type: array, object or null::string is invalid" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_uniqueItems.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_uniqueItems.kt new file mode 100644 index 00000000..b5fd9638 --- /dev/null +++ b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaDraft7SuiteTest_uniqueItems.kt @@ -0,0 +1,2187 @@ +package org.kson.parser.json.generated + +import org.kson.schema.JsonSchemaTest +import kotlin.test.Test + +/** + * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task + * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. + * + * TODO expand the testing here as we implement Json Schema support by + * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ +@Suppress("UNREACHABLE_CODE", "ClassName") // unreachable code is okay here until we complete the above TODO +class SchemaDraft7SuiteTest_uniqueItems : JsonSchemaTest { + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> unique array of integers is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of integers is valid" + */ + @Test + fun jsonSchemaSuiteTest_1() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of integers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of integers is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of integers is invalid" + */ + @Test + fun jsonSchemaSuiteTest_2() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of integers is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of more than two integers is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of more than two integers is invalid" + */ + @Test + fun jsonSchemaSuiteTest_3() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2, + 1 + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of more than two integers is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> numbers are unique if mathematically unequal" + * + * Test ID: "uniqueItems::uniqueItems validation::numbers are unique if mathematically unequal" + */ + @Test + fun jsonSchemaSuiteTest_4() { + + assertKsonEnforcesSchema( + """ + [ + 1.0, + 1.0, + 1 + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::numbers are unique if mathematically unequal" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> false is not equal to zero" + * + * Test ID: "uniqueItems::uniqueItems validation::false is not equal to zero" + */ + @Test + fun jsonSchemaSuiteTest_5() { + + assertKsonEnforcesSchema( + """ + [ + 0, + false + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::false is not equal to zero" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> true is not equal to one" + * + * Test ID: "uniqueItems::uniqueItems validation::true is not equal to one" + */ + @Test + fun jsonSchemaSuiteTest_6() { + + assertKsonEnforcesSchema( + """ + [ + 1, + true + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::true is not equal to one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> unique array of strings is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of strings is valid" + */ + @Test + fun jsonSchemaSuiteTest_7() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "baz" + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of strings is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of strings is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of strings is invalid" + */ + @Test + fun jsonSchemaSuiteTest_8() { + + assertKsonEnforcesSchema( + """ + [ + "foo", + "bar", + "foo" + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of strings is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> unique array of objects is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_9() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + }, + { + "foo": "baz" + } + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of objects is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of objects is invalid" + */ + @Test + fun jsonSchemaSuiteTest_10() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + }, + { + "foo": "bar" + } + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of objects is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> property order of array of objects is ignored" + * + * Test ID: "uniqueItems::uniqueItems validation::property order of array of objects is ignored" + */ + @Test + fun jsonSchemaSuiteTest_11() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar", + "bar": "foo" + }, + { + "bar": "foo", + "foo": "bar" + } + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::property order of array of objects is ignored" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> unique array of nested objects is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of nested objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_12() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": { + "bar": { + "baz": true + } + } + }, + { + "foo": { + "bar": { + "baz": false + } + } + } + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of nested objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of nested objects is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of nested objects is invalid" + */ + @Test + fun jsonSchemaSuiteTest_13() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": { + "bar": { + "baz": true + } + } + }, + { + "foo": { + "bar": { + "baz": true + } + } + } + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of nested objects is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> unique array of arrays is valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique array of arrays is valid" + */ + @Test + fun jsonSchemaSuiteTest_14() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "bar" + ] + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique array of arrays is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of arrays is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of arrays is invalid" + */ + @Test + fun jsonSchemaSuiteTest_15() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "foo" + ] + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of arrays is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> non-unique array of more than two arrays is invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique array of more than two arrays is invalid" + */ + @Test + fun jsonSchemaSuiteTest_16() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "bar" + ], + [ + "foo" + ] + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique array of more than two arrays is invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> 1 and true are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::1 and true are unique" + */ + @Test + fun jsonSchemaSuiteTest_17() { + + assertKsonEnforcesSchema( + """ + [ + 1, + true + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::1 and true are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> 0 and false are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::0 and false are unique" + */ + @Test + fun jsonSchemaSuiteTest_18() { + + assertKsonEnforcesSchema( + """ + [ + 0, + false + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::0 and false are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> [1] and [true] are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::[1] and [true] are unique" + */ + @Test + fun jsonSchemaSuiteTest_19() { + + assertKsonEnforcesSchema( + """ + [ + [ + 1 + ], + [ + true + ] + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::[1] and [true] are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> [0] and [false] are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::[0] and [false] are unique" + */ + @Test + fun jsonSchemaSuiteTest_20() { + + assertKsonEnforcesSchema( + """ + [ + [ + 0 + ], + [ + false + ] + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::[0] and [false] are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> nested [1] and [true] are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::nested [1] and [true] are unique" + */ + @Test + fun jsonSchemaSuiteTest_21() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + 1 + ], + "foo" + ], + [ + [ + true + ], + "foo" + ] + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::nested [1] and [true] are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> nested [0] and [false] are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::nested [0] and [false] are unique" + */ + @Test + fun jsonSchemaSuiteTest_22() { + + assertKsonEnforcesSchema( + """ + [ + [ + [ + 0 + ], + "foo" + ], + [ + [ + false + ], + "foo" + ] + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::nested [0] and [false] are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> unique heterogeneous types are valid" + * + * Test ID: "uniqueItems::uniqueItems validation::unique heterogeneous types are valid" + */ + @Test + fun jsonSchemaSuiteTest_23() { + + assertKsonEnforcesSchema( + """ + [ + { + }, + [ + 1 + ], + true, + null, + 1, + "{}" + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::unique heterogeneous types are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> non-unique heterogeneous types are invalid" + * + * Test ID: "uniqueItems::uniqueItems validation::non-unique heterogeneous types are invalid" + */ + @Test + fun jsonSchemaSuiteTest_24() { + + assertKsonEnforcesSchema( + """ + [ + { + }, + [ + 1 + ], + true, + null, + { + }, + 1 + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::non-unique heterogeneous types are invalid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> different objects are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::different objects are unique" + */ + @Test + fun jsonSchemaSuiteTest_25() { + + assertKsonEnforcesSchema( + """ + [ + { + "a": 1, + "b": 2 + }, + { + "a": 2, + "b": 1 + } + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::different objects are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> objects are non-unique despite key order" + * + * Test ID: "uniqueItems::uniqueItems validation::objects are non-unique despite key order" + */ + @Test + fun jsonSchemaSuiteTest_26() { + + assertKsonEnforcesSchema( + """ + [ + { + "a": 1, + "b": 2 + }, + { + "b": 2, + "a": 1 + } + ] + """, + """ + { + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems validation::objects are non-unique despite key order" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> {"a": false} and {"a": 0} are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::{"a": false} and {"a": 0} are unique" + */ + @Test + fun jsonSchemaSuiteTest_27() { + + assertKsonEnforcesSchema( + """ + [ + { + "a": false + }, + { + "a": 0 + } + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::{"a": false} and {"a": 0} are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems validation -> {"a": true} and {"a": 1} are unique" + * + * Test ID: "uniqueItems::uniqueItems validation::{"a": true} and {"a": 1} are unique" + */ + @Test + fun jsonSchemaSuiteTest_28() { + + assertKsonEnforcesSchema( + """ + [ + { + "a": true + }, + { + "a": 1 + } + ] + """, + """ + { + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems validation::{"a": true} and {"a": 1} are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items -> [false, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::[false, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_29() { + + assertKsonEnforcesSchema( + """ + [ + false, + true + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::[false, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items -> [true, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::[true, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_30() { + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::[true, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items -> [false, false] from items array is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::[false, false] from items array is not valid" + */ + @Test + fun jsonSchemaSuiteTest_31() { + + assertKsonEnforcesSchema( + """ + [ + false, + false + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::[false, false] from items array is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items -> [true, true] from items array is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::[true, true] from items array is not valid" + */ + @Test + fun jsonSchemaSuiteTest_32() { + + assertKsonEnforcesSchema( + """ + [ + true, + true + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::[true, true] from items array is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items -> unique array extended from [false, true] is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::unique array extended from [false, true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_33() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + "foo", + "bar" + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::unique array extended from [false, true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items -> unique array extended from [true, false] is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::unique array extended from [true, false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_34() { + + assertKsonEnforcesSchema( + """ + [ + true, + false, + "foo", + "bar" + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::unique array extended from [true, false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items -> non-unique array extended from [false, true] is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::non-unique array extended from [false, true] is not valid" + */ + @Test + fun jsonSchemaSuiteTest_35() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + "foo", + "foo" + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::non-unique array extended from [false, true] is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items -> non-unique array extended from [true, false] is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items::non-unique array extended from [true, false] is not valid" + */ + @Test + fun jsonSchemaSuiteTest_36() { + + assertKsonEnforcesSchema( + """ + [ + true, + false, + "foo", + "foo" + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items::non-unique array extended from [true, false] is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> [false, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_37() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, true] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + false, + true + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "additionalItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> [true, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_38() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, false] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "additionalItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> [false, false] from items array is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, false] from items array is not valid" + */ + @Test + fun jsonSchemaSuiteTest_39() { + + assertKsonEnforcesSchema( + """ + [ + false, + false + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "additionalItems": false + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[false, false] from items array is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> [true, true] from items array is not valid" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, true] from items array is not valid" + */ + @Test + fun jsonSchemaSuiteTest_40() { + + assertKsonEnforcesSchema( + """ + [ + true, + true + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "additionalItems": false + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::[true, true] from items array is not valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems with an array of items and additionalItems=false -> extra items are invalid even if unique" + * + * Test ID: "uniqueItems::uniqueItems with an array of items and additionalItems=false::extra items are invalid even if unique" + */ + @Test + fun jsonSchemaSuiteTest_41() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + null + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": true, + "additionalItems": false + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems with an array of items and additionalItems=false::extra items are invalid even if unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> unique array of integers is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique array of integers is valid" + */ + @Test + fun jsonSchemaSuiteTest_42() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 2 + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique array of integers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique array of integers is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique array of integers is valid" + */ + @Test + fun jsonSchemaSuiteTest_43() { + + assertKsonEnforcesSchema( + """ + [ + 1, + 1 + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique array of integers is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> numbers are unique if mathematically unequal" + * + * Test ID: "uniqueItems::uniqueItems=false validation::numbers are unique if mathematically unequal" + */ + @Test + fun jsonSchemaSuiteTest_44() { + + assertKsonEnforcesSchema( + """ + [ + 1.0, + 1.0, + 1 + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::numbers are unique if mathematically unequal" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> false is not equal to zero" + * + * Test ID: "uniqueItems::uniqueItems=false validation::false is not equal to zero" + */ + @Test + fun jsonSchemaSuiteTest_45() { + + assertKsonEnforcesSchema( + """ + [ + 0, + false + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::false is not equal to zero" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> true is not equal to one" + * + * Test ID: "uniqueItems::uniqueItems=false validation::true is not equal to one" + */ + @Test + fun jsonSchemaSuiteTest_46() { + + assertKsonEnforcesSchema( + """ + [ + 1, + true + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::true is not equal to one" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> unique array of objects is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique array of objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_47() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + }, + { + "foo": "baz" + } + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique array of objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique array of objects is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique array of objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_48() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": "bar" + }, + { + "foo": "bar" + } + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique array of objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> unique array of nested objects is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique array of nested objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_49() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": { + "bar": { + "baz": true + } + } + }, + { + "foo": { + "bar": { + "baz": false + } + } + } + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique array of nested objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique array of nested objects is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique array of nested objects is valid" + */ + @Test + fun jsonSchemaSuiteTest_50() { + + assertKsonEnforcesSchema( + """ + [ + { + "foo": { + "bar": { + "baz": true + } + } + }, + { + "foo": { + "bar": { + "baz": true + } + } + } + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique array of nested objects is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> unique array of arrays is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique array of arrays is valid" + */ + @Test + fun jsonSchemaSuiteTest_51() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "bar" + ] + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique array of arrays is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique array of arrays is valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique array of arrays is valid" + */ + @Test + fun jsonSchemaSuiteTest_52() { + + assertKsonEnforcesSchema( + """ + [ + [ + "foo" + ], + [ + "foo" + ] + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique array of arrays is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> 1 and true are unique" + * + * Test ID: "uniqueItems::uniqueItems=false validation::1 and true are unique" + */ + @Test + fun jsonSchemaSuiteTest_53() { + + assertKsonEnforcesSchema( + """ + [ + 1, + true + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::1 and true are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> 0 and false are unique" + * + * Test ID: "uniqueItems::uniqueItems=false validation::0 and false are unique" + */ + @Test + fun jsonSchemaSuiteTest_54() { + + assertKsonEnforcesSchema( + """ + [ + 0, + false + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::0 and false are unique" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> unique heterogeneous types are valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::unique heterogeneous types are valid" + */ + @Test + fun jsonSchemaSuiteTest_55() { + + assertKsonEnforcesSchema( + """ + [ + { + }, + [ + 1 + ], + true, + null, + 1 + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::unique heterogeneous types are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false validation -> non-unique heterogeneous types are valid" + * + * Test ID: "uniqueItems::uniqueItems=false validation::non-unique heterogeneous types are valid" + */ + @Test + fun jsonSchemaSuiteTest_56() { + + assertKsonEnforcesSchema( + """ + [ + { + }, + [ + 1 + ], + true, + null, + { + }, + 1 + ] + """, + """ + { + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false validation::non-unique heterogeneous types are valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items -> [false, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::[false, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_57() { + + assertKsonEnforcesSchema( + """ + [ + false, + true + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::[false, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items -> [true, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::[true, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_58() { + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::[true, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items -> [false, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::[false, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_59() { + + assertKsonEnforcesSchema( + """ + [ + false, + false + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::[false, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items -> [true, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::[true, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_60() { + + assertKsonEnforcesSchema( + """ + [ + true, + true + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::[true, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items -> unique array extended from [false, true] is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::unique array extended from [false, true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_61() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + "foo", + "bar" + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::unique array extended from [false, true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items -> unique array extended from [true, false] is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::unique array extended from [true, false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_62() { + + assertKsonEnforcesSchema( + """ + [ + true, + false, + "foo", + "bar" + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::unique array extended from [true, false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items -> non-unique array extended from [false, true] is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::non-unique array extended from [false, true] is valid" + */ + @Test + fun jsonSchemaSuiteTest_63() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + "foo", + "foo" + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::non-unique array extended from [false, true] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items -> non-unique array extended from [true, false] is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items::non-unique array extended from [true, false] is valid" + */ + @Test + fun jsonSchemaSuiteTest_64() { + + assertKsonEnforcesSchema( + """ + [ + true, + false, + "foo", + "foo" + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items::non-unique array extended from [true, false] is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> [false, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_65() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, true] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + false, + true + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "additionalItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> [true, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_66() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, false] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + true, + false + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "additionalItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> [false, false] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, false] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_67() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, false] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + false, + false + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "additionalItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[false, false] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> [true, true] from items array is valid" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, true] from items array is valid" + */ + @Test + fun jsonSchemaSuiteTest_68() { + /** + * TODO implement the schema functionality under test here and remove the exclusion entry + * "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, true] from items array is valid" from + * [org.kson.jsonsuite.schemaTestSuiteExclusions] + */ + return + + assertKsonEnforcesSchema( + """ + [ + true, + true + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "additionalItems": false + } + """, + true, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::[true, true] from items array is valid" """) + } + + /** + * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: + * "uniqueItems=false with an array of items and additionalItems=false -> extra items are invalid even if unique" + * + * Test ID: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::extra items are invalid even if unique" + */ + @Test + fun jsonSchemaSuiteTest_69() { + + assertKsonEnforcesSchema( + """ + [ + false, + true, + null + ] + """, + """ + { + "items": [ + { + "type": "boolean" + }, + { + "type": "boolean" + } + ], + "uniqueItems": false, + "additionalItems": false + } + """, + false, + """ schemaTestId: "uniqueItems::uniqueItems=false with an array of items and additionalItems=false::extra items are invalid even if unique" """) + } +} diff --git a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaSuiteTest.kt b/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaSuiteTest.kt deleted file mode 100644 index d1016cf3..00000000 --- a/src/commonTest/kotlin/org/kson/parser/json/generated/SchemaSuiteTest.kt +++ /dev/null @@ -1,24185 +0,0 @@ -package org.kson.parser.json.generated - -import org.kson.schema.JsonSchemaTest -import kotlin.test.Test - -/** - * DO NOT MANUALLY EDIT. This class is GENERATED by `./gradlew generateJsonTestSuite` task - * which calls [org.kson.jsonsuite.JsonTestSuiteGenerator]---see that class for more info. - * - * TODO expand the testing here as we implement Json Schema support by - * removing exclusions from [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ -@Suppress("UNREACHABLE_CODE") // unreachable code is okay here until we complete the above TODO -class SchemaSuiteTest : JsonSchemaTest { - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems as schema -> additional items match schema" - */ - @Test - fun additionalItems_additionalItemsAsSchema_additionalItemsMatchSchema() { - - assertKsonEnforcesSchema( - """ - [ - null, - 2, - 3, - 4 - ] - """, - """ - { - "items": [ - { - } - ], - "additionalItems": { - "type": "integer" - } - } - """, - true, - """additionalItems as schema -> additional items match schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems as schema -> additional items do not match schema" - */ - @Test - fun additionalItems_additionalItemsAsSchema_additionalItemsDoNotMatchSchema() { - - assertKsonEnforcesSchema( - """ - [ - null, - 2, - 3, - "foo" - ] - """, - """ - { - "items": [ - { - } - ], - "additionalItems": { - "type": "integer" - } - } - """, - false, - """additionalItems as schema -> additional items do not match schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "when items is schema, additionalItems does nothing -> valid with a array of type integers" - */ - @Test - fun additionalItems_whenItemsIsSchema_AdditionalItemsDoesNothing_validWithAArrayOfTypeIntegers() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "items": { - "type": "integer" - }, - "additionalItems": { - "type": "string" - } - } - """, - true, - """when items is schema, additionalItems does nothing -> valid with a array of type integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "when items is schema, additionalItems does nothing -> invalid with a array of mixed types" - */ - @Test - fun additionalItems_whenItemsIsSchema_AdditionalItemsDoesNothing_invalidWithAArrayOfMixedTypes() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "2", - "3" - ] - """, - """ - { - "items": { - "type": "integer" - }, - "additionalItems": { - "type": "string" - } - } - """, - false, - """when items is schema, additionalItems does nothing -> invalid with a array of mixed types""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "when items is schema, boolean additionalItems does nothing -> all items match schema" - */ - @Test - fun additionalItems_whenItemsIsSchema_BooleanAdditionalItemsDoesNothing_allItemsMatchSchema() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3, - 4, - 5 - ] - """, - """ - { - "items": { - }, - "additionalItems": false - } - """, - true, - """when items is schema, boolean additionalItems does nothing -> all items match schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "array of items with no additionalItems permitted -> empty array" - */ - @Test - fun additionalItems_arrayOfItemsWithNoAdditionalItemsPermitted_emptyArray() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "items": [ - { - }, - { - }, - { - } - ], - "additionalItems": false - } - """, - true, - """array of items with no additionalItems permitted -> empty array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "array of items with no additionalItems permitted -> fewer number of items present (1)" - */ - @Test - fun additionalItems_arrayOfItemsWithNoAdditionalItemsPermitted_fewerNumberOfItemsPresent_1_() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "items": [ - { - }, - { - }, - { - } - ], - "additionalItems": false - } - """, - true, - """array of items with no additionalItems permitted -> fewer number of items present (1)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "array of items with no additionalItems permitted -> fewer number of items present (2)" - */ - @Test - fun additionalItems_arrayOfItemsWithNoAdditionalItemsPermitted_fewerNumberOfItemsPresent_2_() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2 - ] - """, - """ - { - "items": [ - { - }, - { - }, - { - } - ], - "additionalItems": false - } - """, - true, - """array of items with no additionalItems permitted -> fewer number of items present (2)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "array of items with no additionalItems permitted -> equal number of items present" - */ - @Test - fun additionalItems_arrayOfItemsWithNoAdditionalItemsPermitted_equalNumberOfItemsPresent() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "items": [ - { - }, - { - }, - { - } - ], - "additionalItems": false - } - """, - true, - """array of items with no additionalItems permitted -> equal number of items present""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "array of items with no additionalItems permitted -> additional items are not permitted" - */ - @Test - fun additionalItems_arrayOfItemsWithNoAdditionalItemsPermitted_additionalItemsAreNotPermitted() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3, - 4 - ] - """, - """ - { - "items": [ - { - }, - { - }, - { - } - ], - "additionalItems": false - } - """, - false, - """array of items with no additionalItems permitted -> additional items are not permitted""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems as false without items -> items defaults to empty schema so everything is valid" - */ - @Test - fun additionalItems_additionalItemsAsFalseWithoutItems_itemsDefaultsToEmptySchemaSoEverythingIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3, - 4, - 5 - ] - """, - """ - { - "additionalItems": false - } - """, - true, - """additionalItems as false without items -> items defaults to empty schema so everything is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems as false without items -> ignores non-arrays" - */ - @Test - fun additionalItems_additionalItemsAsFalseWithoutItems_ignoresNon_arrays() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "additionalItems": false - } - """, - true, - """additionalItems as false without items -> ignores non-arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems are allowed by default -> only the first item is validated" - */ - @Test - fun additionalItems_additionalItemsAreAllowedByDefault_onlyTheFirstItemIsValidated() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "foo", - false - ] - """, - """ - { - "items": [ - { - "type": "integer" - } - ] - } - """, - true, - """additionalItems are allowed by default -> only the first item is validated""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems does not look in applicators, valid case -> items defined in allOf are not examined" - */ - @Test - fun additionalItems_additionalItemsDoesNotLookInApplicators_ValidCase_itemsDefinedInAllOfAreNotExamined() { - - assertKsonEnforcesSchema( - """ - [ - 1, - null - ] - """, - """ - { - "allOf": [ - { - "items": [ - { - "type": "integer" - } - ] - } - ], - "additionalItems": { - "type": "boolean" - } - } - """, - true, - """additionalItems does not look in applicators, valid case -> items defined in allOf are not examined""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems does not look in applicators, invalid case -> items defined in allOf are not examined" - */ - @Test - fun additionalItems_additionalItemsDoesNotLookInApplicators_InvalidCase_itemsDefinedInAllOfAreNotExamined() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "hello" - ] - """, - """ - { - "allOf": [ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - ], - "items": [ - { - "type": "integer" - } - ], - "additionalItems": { - "type": "boolean" - } - } - """, - false, - """additionalItems does not look in applicators, invalid case -> items defined in allOf are not examined""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "items validation adjusts the starting index for additionalItems -> valid items" - */ - @Test - fun additionalItems_itemsValidationAdjustsTheStartingIndexForAdditionalItems_validItems() { - - assertKsonEnforcesSchema( - """ - [ - "x", - 2, - 3 - ] - """, - """ - { - "items": [ - { - "type": "string" - } - ], - "additionalItems": { - "type": "integer" - } - } - """, - true, - """items validation adjusts the starting index for additionalItems -> valid items""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "items validation adjusts the starting index for additionalItems -> wrong type of second item" - */ - @Test - fun additionalItems_itemsValidationAdjustsTheStartingIndexForAdditionalItems_wrongTypeOfSecondItem() { - - assertKsonEnforcesSchema( - """ - [ - "x", - "y" - ] - """, - """ - { - "items": [ - { - "type": "string" - } - ], - "additionalItems": { - "type": "integer" - } - } - """, - false, - """items validation adjusts the starting index for additionalItems -> wrong type of second item""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems with heterogeneous array -> heterogeneous invalid instance" - */ - @Test - fun additionalItems_additionalItemsWithHeterogeneousArray_heterogeneousInvalidInstance() { - - assertKsonEnforcesSchema( - """ - [ - "foo", - "bar", - 37 - ] - """, - """ - { - "items": [ - { - } - ], - "additionalItems": false - } - """, - false, - """additionalItems with heterogeneous array -> heterogeneous invalid instance""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems with heterogeneous array -> valid instance" - */ - @Test - fun additionalItems_additionalItemsWithHeterogeneousArray_validInstance() { - - assertKsonEnforcesSchema( - """ - [ - null - ] - """, - """ - { - "items": [ - { - } - ], - "additionalItems": false - } - """, - true, - """additionalItems with heterogeneous array -> valid instance""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json`: - * "additionalItems with null instance elements -> allows null elements" - */ - @Test - fun additionalItems_additionalItemsWithNullInstanceElements_allowsNullElements() { - - assertKsonEnforcesSchema( - """ - [ - null - ] - """, - """ - { - "additionalItems": { - "type": "null" - } - } - """, - true, - """additionalItems with null instance elements -> allows null elements""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties being false does not allow other properties -> no additional properties is valid" - */ - @Test - fun additionalProperties_additionalPropertiesBeingFalseDoesNotAllowOtherProperties_noAdditionalPropertiesIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "patternProperties": { - "^v": { - } - }, - "additionalProperties": false - } - """, - true, - """additionalProperties being false does not allow other properties -> no additional properties is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties being false does not allow other properties -> an additional property is invalid" - */ - @Test - fun additionalProperties_additionalPropertiesBeingFalseDoesNotAllowOtherProperties_anAdditionalPropertyIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2, - "quux": "boom" - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "patternProperties": { - "^v": { - } - }, - "additionalProperties": false - } - """, - false, - """additionalProperties being false does not allow other properties -> an additional property is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties being false does not allow other properties -> ignores arrays" - */ - @Test - fun additionalProperties_additionalPropertiesBeingFalseDoesNotAllowOtherProperties_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "patternProperties": { - "^v": { - } - }, - "additionalProperties": false - } - """, - true, - """additionalProperties being false does not allow other properties -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties being false does not allow other properties -> ignores strings" - */ - @Test - fun additionalProperties_additionalPropertiesBeingFalseDoesNotAllowOtherProperties_ignoresStrings() { - - assertKsonEnforcesSchema( - """ - "foobarbaz" - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "patternProperties": { - "^v": { - } - }, - "additionalProperties": false - } - """, - true, - """additionalProperties being false does not allow other properties -> ignores strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties being false does not allow other properties -> ignores other non-objects" - */ - @Test - fun additionalProperties_additionalPropertiesBeingFalseDoesNotAllowOtherProperties_ignoresOtherNon_objects() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "patternProperties": { - "^v": { - } - }, - "additionalProperties": false - } - """, - true, - """additionalProperties being false does not allow other properties -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties being false does not allow other properties -> patternProperties are not additional properties" - */ - @Test - fun additionalProperties_additionalPropertiesBeingFalseDoesNotAllowOtherProperties_patternPropertiesAreNotAdditionalProperties() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "vroom": 2 - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "patternProperties": { - "^v": { - } - }, - "additionalProperties": false - } - """, - true, - """additionalProperties being false does not allow other properties -> patternProperties are not additional properties""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "non-ASCII pattern with additionalProperties -> matching the pattern is valid" - */ - @Test - fun additionalProperties_non_ASCIIPatternWithAdditionalProperties_matchingThePatternIsValid() { - - assertKsonEnforcesSchema( - """ - { - "ármányos": 2 - } - """, - """ - { - "patternProperties": { - "^á": { - } - }, - "additionalProperties": false - } - """, - true, - """non-ASCII pattern with additionalProperties -> matching the pattern is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "non-ASCII pattern with additionalProperties -> not matching the pattern is invalid" - */ - @Test - fun additionalProperties_non_ASCIIPatternWithAdditionalProperties_notMatchingThePatternIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "élmény": 2 - } - """, - """ - { - "patternProperties": { - "^á": { - } - }, - "additionalProperties": false - } - """, - false, - """non-ASCII pattern with additionalProperties -> not matching the pattern is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties with schema -> no additional properties is valid" - */ - @Test - fun additionalProperties_additionalPropertiesWithSchema_noAdditionalPropertiesIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "additionalProperties": { - "type": "boolean" - } - } - """, - true, - """additionalProperties with schema -> no additional properties is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties with schema -> an additional valid property is valid" - */ - @Test - fun additionalProperties_additionalPropertiesWithSchema_anAdditionalValidPropertyIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2, - "quux": true - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "additionalProperties": { - "type": "boolean" - } - } - """, - true, - """additionalProperties with schema -> an additional valid property is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties with schema -> an additional invalid property is invalid" - */ - @Test - fun additionalProperties_additionalPropertiesWithSchema_anAdditionalInvalidPropertyIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2, - "quux": 12 - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "additionalProperties": { - "type": "boolean" - } - } - """, - false, - """additionalProperties with schema -> an additional invalid property is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties can exist by itself -> an additional valid property is valid" - */ - @Test - fun additionalProperties_additionalPropertiesCanExistByItself_anAdditionalValidPropertyIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": true - } - """, - """ - { - "additionalProperties": { - "type": "boolean" - } - } - """, - true, - """additionalProperties can exist by itself -> an additional valid property is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties can exist by itself -> an additional invalid property is invalid" - */ - @Test - fun additionalProperties_additionalPropertiesCanExistByItself_anAdditionalInvalidPropertyIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "additionalProperties": { - "type": "boolean" - } - } - """, - false, - """additionalProperties can exist by itself -> an additional invalid property is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties are allowed by default -> additional properties are allowed" - */ - @Test - fun additionalProperties_additionalPropertiesAreAllowedByDefault_additionalPropertiesAreAllowed() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2, - "quux": true - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - } - } - """, - true, - """additionalProperties are allowed by default -> additional properties are allowed""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties does not look in applicators -> properties defined in allOf are not examined" - */ - @Test - fun additionalProperties_additionalPropertiesDoesNotLookInApplicators_propertiesDefinedInAllOfAreNotExamined() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": true - } - """, - """ - { - "allOf": [ - { - "properties": { - "foo": { - } - } - } - ], - "additionalProperties": { - "type": "boolean" - } - } - """, - false, - """additionalProperties does not look in applicators -> properties defined in allOf are not examined""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json`: - * "additionalProperties with null valued instance properties -> allows null values" - */ - @Test - fun additionalProperties_additionalPropertiesWithNullValuedInstanceProperties_allowsNullValues() { - - assertKsonEnforcesSchema( - """ - { - "foo": null - } - """, - """ - { - "additionalProperties": { - "type": "null" - } - } - """, - true, - """additionalProperties with null valued instance properties -> allows null values""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf -> allOf" - */ - @Test - fun allOf_allOf_allOf() { - - assertKsonEnforcesSchema( - """ - { - "foo": "baz", - "bar": 2 - } - """, - """ - { - "allOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - true, - """allOf -> allOf""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf -> mismatch second" - */ - @Test - fun allOf_allOf_mismatchSecond() { - - assertKsonEnforcesSchema( - """ - { - "foo": "baz" - } - """, - """ - { - "allOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - false, - """allOf -> mismatch second""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf -> mismatch first" - */ - @Test - fun allOf_allOf_mismatchFirst() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "allOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - false, - """allOf -> mismatch first""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf -> wrong type" - */ - @Test - fun allOf_allOf_wrongType() { - - assertKsonEnforcesSchema( - """ - { - "foo": "baz", - "bar": "quux" - } - """, - """ - { - "allOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - false, - """allOf -> wrong type""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with base schema -> valid" - */ - @Test - fun allOf_allOfWithBaseSchema_valid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "quux", - "bar": 2, - "baz": null - } - """, - """ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ], - "allOf": [ - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - }, - { - "properties": { - "baz": { - "type": "null" - } - }, - "required": [ - "baz" - ] - } - ] - } - """, - true, - """allOf with base schema -> valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with base schema -> mismatch base schema" - */ - @Test - fun allOf_allOfWithBaseSchema_mismatchBaseSchema() { - - assertKsonEnforcesSchema( - """ - { - "foo": "quux", - "baz": null - } - """, - """ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ], - "allOf": [ - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - }, - { - "properties": { - "baz": { - "type": "null" - } - }, - "required": [ - "baz" - ] - } - ] - } - """, - false, - """allOf with base schema -> mismatch base schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with base schema -> mismatch first allOf" - */ - @Test - fun allOf_allOfWithBaseSchema_mismatchFirstAllOf() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2, - "baz": null - } - """, - """ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ], - "allOf": [ - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - }, - { - "properties": { - "baz": { - "type": "null" - } - }, - "required": [ - "baz" - ] - } - ] - } - """, - false, - """allOf with base schema -> mismatch first allOf""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with base schema -> mismatch second allOf" - */ - @Test - fun allOf_allOfWithBaseSchema_mismatchSecondAllOf() { - - assertKsonEnforcesSchema( - """ - { - "foo": "quux", - "bar": 2 - } - """, - """ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ], - "allOf": [ - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - }, - { - "properties": { - "baz": { - "type": "null" - } - }, - "required": [ - "baz" - ] - } - ] - } - """, - false, - """allOf with base schema -> mismatch second allOf""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with base schema -> mismatch both" - */ - @Test - fun allOf_allOfWithBaseSchema_mismatchBoth() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ], - "allOf": [ - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - }, - { - "properties": { - "baz": { - "type": "null" - } - }, - "required": [ - "baz" - ] - } - ] - } - """, - false, - """allOf with base schema -> mismatch both""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf simple types -> valid" - */ - @Test - fun allOf_allOfSimpleTypes_valid() { - - assertKsonEnforcesSchema( - """ - 25 - """, - """ - { - "allOf": [ - { - "maximum": 30 - }, - { - "minimum": 20 - } - ] - } - """, - true, - """allOf simple types -> valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf simple types -> mismatch one" - */ - @Test - fun allOf_allOfSimpleTypes_mismatchOne() { - - assertKsonEnforcesSchema( - """ - 35 - """, - """ - { - "allOf": [ - { - "maximum": 30 - }, - { - "minimum": 20 - } - ] - } - """, - false, - """allOf simple types -> mismatch one""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with boolean schemas, all true -> any value is valid" - */ - @Test - fun allOf_allOfWithBooleanSchemas_AllTrue_anyValueIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - true, - true - ] - } - """, - true, - """allOf with boolean schemas, all true -> any value is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with boolean schemas, some false -> any value is invalid" - */ - @Test - fun allOf_allOfWithBooleanSchemas_SomeFalse_anyValueIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - true, - false - ] - } - """, - false, - """allOf with boolean schemas, some false -> any value is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with boolean schemas, all false -> any value is invalid" - */ - @Test - fun allOf_allOfWithBooleanSchemas_AllFalse_anyValueIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - false, - false - ] - } - """, - false, - """allOf with boolean schemas, all false -> any value is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with one empty schema -> any data is valid" - */ - @Test - fun allOf_allOfWithOneEmptySchema_anyDataIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "allOf": [ - { - } - ] - } - """, - true, - """allOf with one empty schema -> any data is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with two empty schemas -> any data is valid" - */ - @Test - fun allOf_allOfWithTwoEmptySchemas_anyDataIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "allOf": [ - { - }, - { - } - ] - } - """, - true, - """allOf with two empty schemas -> any data is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with the first empty schema -> number is valid" - */ - @Test - fun allOf_allOfWithTheFirstEmptySchema_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "allOf": [ - { - }, - { - "type": "number" - } - ] - } - """, - true, - """allOf with the first empty schema -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with the first empty schema -> string is invalid" - */ - @Test - fun allOf_allOfWithTheFirstEmptySchema_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - { - }, - { - "type": "number" - } - ] - } - """, - false, - """allOf with the first empty schema -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with the last empty schema -> number is valid" - */ - @Test - fun allOf_allOfWithTheLastEmptySchema_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "allOf": [ - { - "type": "number" - }, - { - } - ] - } - """, - true, - """allOf with the last empty schema -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf with the last empty schema -> string is invalid" - */ - @Test - fun allOf_allOfWithTheLastEmptySchema_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - { - "type": "number" - }, - { - } - ] - } - """, - false, - """allOf with the last empty schema -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "nested allOf, to check validation semantics -> null is valid" - */ - @Test - fun allOf_nestedAllOf_ToCheckValidationSemantics_nullIsValid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "allOf": [ - { - "allOf": [ - { - "type": "null" - } - ] - } - ] - } - """, - true, - """nested allOf, to check validation semantics -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "nested allOf, to check validation semantics -> anything non-null is invalid" - */ - @Test - fun allOf_nestedAllOf_ToCheckValidationSemantics_anythingNon_nullIsInvalid() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "allOf": [ - { - "allOf": [ - { - "type": "null" - } - ] - } - ] - } - """, - false, - """nested allOf, to check validation semantics -> anything non-null is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: false, oneOf: false" - */ - @Test - fun allOf_allOfCombinedWithAnyOf_OneOf_allOf_False_AnyOf_False_OneOf_False() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - } - """, - false, - """allOf combined with anyOf, oneOf -> allOf: false, anyOf: false, oneOf: false""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: false, oneOf: true" - */ - @Test - fun allOf_allOfCombinedWithAnyOf_OneOf_allOf_False_AnyOf_False_OneOf_True() { - - assertKsonEnforcesSchema( - """ - 5 - """, - """ - { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - } - """, - false, - """allOf combined with anyOf, oneOf -> allOf: false, anyOf: false, oneOf: true""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: true, oneOf: false" - */ - @Test - fun allOf_allOfCombinedWithAnyOf_OneOf_allOf_False_AnyOf_True_OneOf_False() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - } - """, - false, - """allOf combined with anyOf, oneOf -> allOf: false, anyOf: true, oneOf: false""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf combined with anyOf, oneOf -> allOf: false, anyOf: true, oneOf: true" - */ - @Test - fun allOf_allOfCombinedWithAnyOf_OneOf_allOf_False_AnyOf_True_OneOf_True() { - - assertKsonEnforcesSchema( - """ - 15 - """, - """ - { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - } - """, - false, - """allOf combined with anyOf, oneOf -> allOf: false, anyOf: true, oneOf: true""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: false, oneOf: false" - */ - @Test - fun allOf_allOfCombinedWithAnyOf_OneOf_allOf_True_AnyOf_False_OneOf_False() { - - assertKsonEnforcesSchema( - """ - 2 - """, - """ - { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - } - """, - false, - """allOf combined with anyOf, oneOf -> allOf: true, anyOf: false, oneOf: false""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: false, oneOf: true" - */ - @Test - fun allOf_allOfCombinedWithAnyOf_OneOf_allOf_True_AnyOf_False_OneOf_True() { - - assertKsonEnforcesSchema( - """ - 10 - """, - """ - { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - } - """, - false, - """allOf combined with anyOf, oneOf -> allOf: true, anyOf: false, oneOf: true""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: true, oneOf: false" - */ - @Test - fun allOf_allOfCombinedWithAnyOf_OneOf_allOf_True_AnyOf_True_OneOf_False() { - - assertKsonEnforcesSchema( - """ - 6 - """, - """ - { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - } - """, - false, - """allOf combined with anyOf, oneOf -> allOf: true, anyOf: true, oneOf: false""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/allOf.json`: - * "allOf combined with anyOf, oneOf -> allOf: true, anyOf: true, oneOf: true" - */ - @Test - fun allOf_allOfCombinedWithAnyOf_OneOf_allOf_True_AnyOf_True_OneOf_True() { - - assertKsonEnforcesSchema( - """ - 30 - """, - """ - { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - } - """, - true, - """allOf combined with anyOf, oneOf -> allOf: true, anyOf: true, oneOf: true""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf -> first anyOf valid" - */ - @Test - fun anyOf_anyOf_firstAnyOfValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "anyOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - } - """, - true, - """anyOf -> first anyOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf -> second anyOf valid" - */ - @Test - fun anyOf_anyOf_secondAnyOfValid() { - - assertKsonEnforcesSchema( - """ - 2.5 - """, - """ - { - "anyOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - } - """, - true, - """anyOf -> second anyOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf -> both anyOf valid" - */ - @Test - fun anyOf_anyOf_bothAnyOfValid() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "anyOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - } - """, - true, - """anyOf -> both anyOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf -> neither anyOf valid" - */ - @Test - fun anyOf_anyOf_neitherAnyOfValid() { - - assertKsonEnforcesSchema( - """ - 1.5 - """, - """ - { - "anyOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - } - """, - false, - """anyOf -> neither anyOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf with base schema -> mismatch base schema" - */ - @Test - fun anyOf_anyOfWithBaseSchema_mismatchBaseSchema() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "type": "string", - "anyOf": [ - { - "maxLength": 2 - }, - { - "minLength": 4 - } - ] - } - """, - false, - """anyOf with base schema -> mismatch base schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf with base schema -> one anyOf valid" - */ - @Test - fun anyOf_anyOfWithBaseSchema_oneAnyOfValid() { - - assertKsonEnforcesSchema( - """ - "foobar" - """, - """ - { - "type": "string", - "anyOf": [ - { - "maxLength": 2 - }, - { - "minLength": 4 - } - ] - } - """, - true, - """anyOf with base schema -> one anyOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf with base schema -> both anyOf invalid" - */ - @Test - fun anyOf_anyOfWithBaseSchema_bothAnyOfInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "string", - "anyOf": [ - { - "maxLength": 2 - }, - { - "minLength": 4 - } - ] - } - """, - false, - """anyOf with base schema -> both anyOf invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf with boolean schemas, all true -> any value is valid" - */ - @Test - fun anyOf_anyOfWithBooleanSchemas_AllTrue_anyValueIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "anyOf": [ - true, - true - ] - } - """, - true, - """anyOf with boolean schemas, all true -> any value is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf with boolean schemas, some true -> any value is valid" - */ - @Test - fun anyOf_anyOfWithBooleanSchemas_SomeTrue_anyValueIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "anyOf": [ - true, - false - ] - } - """, - true, - """anyOf with boolean schemas, some true -> any value is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf with boolean schemas, all false -> any value is invalid" - */ - @Test - fun anyOf_anyOfWithBooleanSchemas_AllFalse_anyValueIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "anyOf": [ - false, - false - ] - } - """, - false, - """anyOf with boolean schemas, all false -> any value is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf complex types -> first anyOf valid (complex)" - */ - @Test - fun anyOf_anyOfComplexTypes_firstAnyOfValid_complex_() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "anyOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - true, - """anyOf complex types -> first anyOf valid (complex)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf complex types -> second anyOf valid (complex)" - */ - @Test - fun anyOf_anyOfComplexTypes_secondAnyOfValid_complex_() { - - assertKsonEnforcesSchema( - """ - { - "foo": "baz" - } - """, - """ - { - "anyOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - true, - """anyOf complex types -> second anyOf valid (complex)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf complex types -> both anyOf valid (complex)" - */ - @Test - fun anyOf_anyOfComplexTypes_bothAnyOfValid_complex_() { - - assertKsonEnforcesSchema( - """ - { - "foo": "baz", - "bar": 2 - } - """, - """ - { - "anyOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - true, - """anyOf complex types -> both anyOf valid (complex)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf complex types -> neither anyOf valid (complex)" - */ - @Test - fun anyOf_anyOfComplexTypes_neitherAnyOfValid_complex_() { - - assertKsonEnforcesSchema( - """ - { - "foo": 2, - "bar": "quux" - } - """, - """ - { - "anyOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - false, - """anyOf complex types -> neither anyOf valid (complex)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf with one empty schema -> string is valid" - */ - @Test - fun anyOf_anyOfWithOneEmptySchema_stringIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "anyOf": [ - { - "type": "number" - }, - { - } - ] - } - """, - true, - """anyOf with one empty schema -> string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "anyOf with one empty schema -> number is valid" - */ - @Test - fun anyOf_anyOfWithOneEmptySchema_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "anyOf": [ - { - "type": "number" - }, - { - } - ] - } - """, - true, - """anyOf with one empty schema -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "nested anyOf, to check validation semantics -> null is valid" - */ - @Test - fun anyOf_nestedAnyOf_ToCheckValidationSemantics_nullIsValid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "anyOf": [ - { - "anyOf": [ - { - "type": "null" - } - ] - } - ] - } - """, - true, - """nested anyOf, to check validation semantics -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/anyOf.json`: - * "nested anyOf, to check validation semantics -> anything non-null is invalid" - */ - @Test - fun anyOf_nestedAnyOf_ToCheckValidationSemantics_anythingNon_nullIsInvalid() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "anyOf": [ - { - "anyOf": [ - { - "type": "null" - } - ] - } - ] - } - """, - false, - """nested anyOf, to check validation semantics -> anything non-null is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> number is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__numberIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - true - """, - true, - """boolean schema 'true' -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> string is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__stringIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - true - """, - true, - """boolean schema 'true' -> string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> boolean true is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__booleanTrueIsValid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - true - """, - true, - """boolean schema 'true' -> boolean true is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> boolean false is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__booleanFalseIsValid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - true - """, - true, - """boolean schema 'true' -> boolean false is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> null is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__nullIsValid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - true - """, - true, - """boolean schema 'true' -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> object is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__objectIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - true - """, - true, - """boolean schema 'true' -> object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> empty object is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__emptyObjectIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - true - """, - true, - """boolean schema 'true' -> empty object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> array is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__arrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - true - """, - true, - """boolean schema 'true' -> array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'true' -> empty array is valid" - */ - @Test - fun boolean_schema_booleanSchema_true__emptyArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - true - """, - true, - """boolean schema 'true' -> empty array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> number is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - false - """, - false, - """boolean schema 'false' -> number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> string is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - false - """, - false, - """boolean schema 'false' -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> boolean true is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__booleanTrueIsInvalid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - false - """, - false, - """boolean schema 'false' -> boolean true is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> boolean false is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__booleanFalseIsInvalid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - false - """, - false, - """boolean schema 'false' -> boolean false is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> null is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__nullIsInvalid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - false - """, - false, - """boolean schema 'false' -> null is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> object is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__objectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - false - """, - false, - """boolean schema 'false' -> object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> empty object is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__emptyObjectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - false - """, - false, - """boolean schema 'false' -> empty object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> array is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__arrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - false - """, - false, - """boolean schema 'false' -> array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json`: - * "boolean schema 'false' -> empty array is invalid" - */ - @Test - fun boolean_schema_booleanSchema_false__emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - false - """, - false, - """boolean schema 'false' -> empty array is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const validation -> same value is valid" - */ - @Test - fun const_constValidation_sameValueIsValid() { - - assertKsonEnforcesSchema( - """ - 2 - """, - """ - { - "const": 2 - } - """, - true, - """const validation -> same value is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const validation -> another value is invalid" - */ - @Test - fun const_constValidation_anotherValueIsInvalid() { - - assertKsonEnforcesSchema( - """ - 5 - """, - """ - { - "const": 2 - } - """, - false, - """const validation -> another value is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const validation -> another type is invalid" - */ - @Test - fun const_constValidation_anotherTypeIsInvalid() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "const": 2 - } - """, - false, - """const validation -> another type is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with object -> same object is valid" - */ - @Test - fun const_constWithObject_sameObjectIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar", - "baz": "bax" - } - """, - """ - { - "const": { - "foo": "bar", - "baz": "bax" - } - } - """, - true, - """const with object -> same object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with object -> same object with different property order is valid" - */ - @Test - fun const_constWithObject_sameObjectWithDifferentPropertyOrderIsValid() { - - assertKsonEnforcesSchema( - """ - { - "baz": "bax", - "foo": "bar" - } - """, - """ - { - "const": { - "foo": "bar", - "baz": "bax" - } - } - """, - true, - """const with object -> same object with different property order is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with object -> another object is invalid" - */ - @Test - fun const_constWithObject_anotherObjectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "const": { - "foo": "bar", - "baz": "bax" - } - } - """, - false, - """const with object -> another object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with object -> another type is invalid" - */ - @Test - fun const_constWithObject_anotherTypeIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2 - ] - """, - """ - { - "const": { - "foo": "bar", - "baz": "bax" - } - } - """, - false, - """const with object -> another type is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with array -> same array is valid" - */ - @Test - fun const_constWithArray_sameArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": "bar" - } - ] - """, - """ - { - "const": [ - { - "foo": "bar" - } - ] - } - """, - true, - """const with array -> same array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with array -> another array item is invalid" - */ - @Test - fun const_constWithArray_anotherArrayItemIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 2 - ] - """, - """ - { - "const": [ - { - "foo": "bar" - } - ] - } - """, - false, - """const with array -> another array item is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with array -> array with additional items is invalid" - */ - @Test - fun const_constWithArray_arrayWithAdditionalItemsIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "const": [ - { - "foo": "bar" - } - ] - } - """, - false, - """const with array -> array with additional items is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with null -> null is valid" - */ - @Test - fun const_constWithNull_nullIsValid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "const": null - } - """, - true, - """const with null -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with null -> not null is invalid" - */ - @Test - fun const_constWithNull_notNullIsInvalid() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "const": null - } - """, - false, - """const with null -> not null is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with false does not match 0 -> false is valid" - */ - @Test - fun const_constWithFalseDoesNotMatch0_falseIsValid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "const": false - } - """, - true, - """const with false does not match 0 -> false is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with false does not match 0 -> integer zero is invalid" - */ - @Test - fun const_constWithFalseDoesNotMatch0_integerZeroIsInvalid() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "const": false - } - """, - false, - """const with false does not match 0 -> integer zero is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with false does not match 0 -> float zero is invalid" - */ - @Test - fun const_constWithFalseDoesNotMatch0_floatZeroIsInvalid() { - - assertKsonEnforcesSchema( - """ - 0.0 - """, - """ - { - "const": false - } - """, - false, - """const with false does not match 0 -> float zero is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with true does not match 1 -> true is valid" - */ - @Test - fun const_constWithTrueDoesNotMatch1_trueIsValid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "const": true - } - """, - true, - """const with true does not match 1 -> true is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with true does not match 1 -> integer one is invalid" - */ - @Test - fun const_constWithTrueDoesNotMatch1_integerOneIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "const": true - } - """, - false, - """const with true does not match 1 -> integer one is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with true does not match 1 -> float one is invalid" - */ - @Test - fun const_constWithTrueDoesNotMatch1_floatOneIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1.0 - """, - """ - { - "const": true - } - """, - false, - """const with true does not match 1 -> float one is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with [false] does not match [0] -> [false] is valid" - */ - @Test - fun const_constWith_false_DoesNotMatch_0___false_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - false - ] - """, - """ - { - "const": [ - false - ] - } - """, - true, - """const with [false] does not match [0] -> [false] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with [false] does not match [0] -> [0] is invalid" - */ - @Test - fun const_constWith_false_DoesNotMatch_0___0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 0 - ] - """, - """ - { - "const": [ - false - ] - } - """, - false, - """const with [false] does not match [0] -> [0] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with [false] does not match [0] -> [0.0] is invalid" - */ - @Test - fun const_constWith_false_DoesNotMatch_0___0_0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 0.0 - ] - """, - """ - { - "const": [ - false - ] - } - """, - false, - """const with [false] does not match [0] -> [0.0] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with [true] does not match [1] -> [true] is valid" - */ - @Test - fun const_constWith_true_DoesNotMatch_1___true_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - true - ] - """, - """ - { - "const": [ - true - ] - } - """, - true, - """const with [true] does not match [1] -> [true] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with [true] does not match [1] -> [1] is invalid" - */ - @Test - fun const_constWith_true_DoesNotMatch_1___1_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "const": [ - true - ] - } - """, - false, - """const with [true] does not match [1] -> [1] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with [true] does not match [1] -> [1.0] is invalid" - */ - @Test - fun const_constWith_true_DoesNotMatch_1___1_0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1.0 - ] - """, - """ - { - "const": [ - true - ] - } - """, - false, - """const with [true] does not match [1] -> [1.0] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with {"a": false} does not match {"a": 0} -> {"a": false} is valid" - */ - @Test - fun const_constWith__a__False_DoesNotMatch__a__0____a__False_IsValid() { - - assertKsonEnforcesSchema( - """ - { - "a": false - } - """, - """ - { - "const": { - "a": false - } - } - """, - true, - """const with {"a": false} does not match {"a": 0} -> {"a": false} is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with {"a": false} does not match {"a": 0} -> {"a": 0} is invalid" - */ - @Test - fun const_constWith__a__False_DoesNotMatch__a__0____a__0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "a": 0 - } - """, - """ - { - "const": { - "a": false - } - } - """, - false, - """const with {"a": false} does not match {"a": 0} -> {"a": 0} is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with {"a": false} does not match {"a": 0} -> {"a": 0.0} is invalid" - */ - @Test - fun const_constWith__a__False_DoesNotMatch__a__0____a__0_0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "a": 0.0 - } - """, - """ - { - "const": { - "a": false - } - } - """, - false, - """const with {"a": false} does not match {"a": 0} -> {"a": 0.0} is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with {"a": true} does not match {"a": 1} -> {"a": true} is valid" - */ - @Test - fun const_constWith__a__True_DoesNotMatch__a__1____a__True_IsValid() { - - assertKsonEnforcesSchema( - """ - { - "a": true - } - """, - """ - { - "const": { - "a": true - } - } - """, - true, - """const with {"a": true} does not match {"a": 1} -> {"a": true} is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with {"a": true} does not match {"a": 1} -> {"a": 1} is invalid" - */ - @Test - fun const_constWith__a__True_DoesNotMatch__a__1____a__1_IsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "a": 1 - } - """, - """ - { - "const": { - "a": true - } - } - """, - false, - """const with {"a": true} does not match {"a": 1} -> {"a": 1} is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with {"a": true} does not match {"a": 1} -> {"a": 1.0} is invalid" - */ - @Test - fun const_constWith__a__True_DoesNotMatch__a__1____a__1_0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "a": 1.0 - } - """, - """ - { - "const": { - "a": true - } - } - """, - false, - """const with {"a": true} does not match {"a": 1} -> {"a": 1.0} is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 0 does not match other zero-like types -> false is invalid" - */ - @Test - fun const_constWith0DoesNotMatchOtherZero_likeTypes_falseIsInvalid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "const": 0 - } - """, - false, - """const with 0 does not match other zero-like types -> false is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 0 does not match other zero-like types -> integer zero is valid" - */ - @Test - fun const_constWith0DoesNotMatchOtherZero_likeTypes_integerZeroIsValid() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "const": 0 - } - """, - true, - """const with 0 does not match other zero-like types -> integer zero is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 0 does not match other zero-like types -> float zero is valid" - */ - @Test - fun const_constWith0DoesNotMatchOtherZero_likeTypes_floatZeroIsValid() { - - assertKsonEnforcesSchema( - """ - 0.0 - """, - """ - { - "const": 0 - } - """, - true, - """const with 0 does not match other zero-like types -> float zero is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 0 does not match other zero-like types -> empty object is invalid" - */ - @Test - fun const_constWith0DoesNotMatchOtherZero_likeTypes_emptyObjectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "const": 0 - } - """, - false, - """const with 0 does not match other zero-like types -> empty object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 0 does not match other zero-like types -> empty array is invalid" - */ - @Test - fun const_constWith0DoesNotMatchOtherZero_likeTypes_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "const": 0 - } - """, - false, - """const with 0 does not match other zero-like types -> empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 0 does not match other zero-like types -> empty string is invalid" - */ - @Test - fun const_constWith0DoesNotMatchOtherZero_likeTypes_emptyStringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "" - """, - """ - { - "const": 0 - } - """, - false, - """const with 0 does not match other zero-like types -> empty string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 1 does not match true -> true is invalid" - */ - @Test - fun const_constWith1DoesNotMatchTrue_trueIsInvalid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "const": 1 - } - """, - false, - """const with 1 does not match true -> true is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 1 does not match true -> integer one is valid" - */ - @Test - fun const_constWith1DoesNotMatchTrue_integerOneIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "const": 1 - } - """, - true, - """const with 1 does not match true -> integer one is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with 1 does not match true -> float one is valid" - */ - @Test - fun const_constWith1DoesNotMatchTrue_floatOneIsValid() { - - assertKsonEnforcesSchema( - """ - 1.0 - """, - """ - { - "const": 1 - } - """, - true, - """const with 1 does not match true -> float one is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with -2.0 matches integer and float types -> integer -2 is valid" - */ - @Test - fun const_constWith_2_0MatchesIntegerAndFloatTypes_integer_2IsValid() { - - assertKsonEnforcesSchema( - """ - -2 - """, - """ - { - "const": -2.0 - } - """, - true, - """const with -2.0 matches integer and float types -> integer -2 is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with -2.0 matches integer and float types -> integer 2 is invalid" - */ - @Test - fun const_constWith_2_0MatchesIntegerAndFloatTypes_integer2IsInvalid() { - - assertKsonEnforcesSchema( - """ - 2 - """, - """ - { - "const": -2.0 - } - """, - false, - """const with -2.0 matches integer and float types -> integer 2 is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with -2.0 matches integer and float types -> float -2.0 is valid" - */ - @Test - fun const_constWith_2_0MatchesIntegerAndFloatTypes_float_2_0IsValid() { - - assertKsonEnforcesSchema( - """ - -2.0 - """, - """ - { - "const": -2.0 - } - """, - true, - """const with -2.0 matches integer and float types -> float -2.0 is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with -2.0 matches integer and float types -> float 2.0 is invalid" - */ - @Test - fun const_constWith_2_0MatchesIntegerAndFloatTypes_float2_0IsInvalid() { - - assertKsonEnforcesSchema( - """ - 2.0 - """, - """ - { - "const": -2.0 - } - """, - false, - """const with -2.0 matches integer and float types -> float 2.0 is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "const with -2.0 matches integer and float types -> float -2.00001 is invalid" - */ - @Test - fun const_constWith_2_0MatchesIntegerAndFloatTypes_float_2_00001IsInvalid() { - - assertKsonEnforcesSchema( - """ - -2.00001 - """, - """ - { - "const": -2.0 - } - """, - false, - """const with -2.0 matches integer and float types -> float -2.00001 is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "float and integers are equal up to 64-bit representation limits -> integer is valid" - */ - @Test - fun const_floatAndIntegersAreEqualUpTo64_bitRepresentationLimits_integerIsValid() { - - assertKsonEnforcesSchema( - """ - 9007199254740992 - """, - """ - { - "const": 9007199254740992 - } - """, - true, - """float and integers are equal up to 64-bit representation limits -> integer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "float and integers are equal up to 64-bit representation limits -> integer minus one is invalid" - */ - @Test - fun const_floatAndIntegersAreEqualUpTo64_bitRepresentationLimits_integerMinusOneIsInvalid() { - - assertKsonEnforcesSchema( - """ - 9007199254740991 - """, - """ - { - "const": 9007199254740992 - } - """, - false, - """float and integers are equal up to 64-bit representation limits -> integer minus one is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "float and integers are equal up to 64-bit representation limits -> float is valid" - */ - @Test - fun const_floatAndIntegersAreEqualUpTo64_bitRepresentationLimits_floatIsValid() { - - assertKsonEnforcesSchema( - """ - 9.007199254740992E15 - """, - """ - { - "const": 9007199254740992 - } - """, - true, - """float and integers are equal up to 64-bit representation limits -> float is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "float and integers are equal up to 64-bit representation limits -> float minus one is invalid" - */ - @Test - fun const_floatAndIntegersAreEqualUpTo64_bitRepresentationLimits_floatMinusOneIsInvalid() { - - assertKsonEnforcesSchema( - """ - 9.007199254740991E15 - """, - """ - { - "const": 9007199254740992 - } - """, - false, - """float and integers are equal up to 64-bit representation limits -> float minus one is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "nul characters in strings -> match string with nul" - */ - @Test - fun const_nulCharactersInStrings_matchStringWithNul() { - - assertKsonEnforcesSchema( - """ - "hello\u0000there" - """, - """ - { - "const": "hello\u0000there" - } - """, - true, - """nul characters in strings -> match string with nul""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/const.json`: - * "nul characters in strings -> do not match string lacking nul" - */ - @Test - fun const_nulCharactersInStrings_doNotMatchStringLackingNul() { - - assertKsonEnforcesSchema( - """ - "hellothere" - """, - """ - { - "const": "hello\u0000there" - } - """, - false, - """nul characters in strings -> do not match string lacking nul""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword validation -> array with item matching schema (5) is valid" - */ - @Test - fun contains_containsKeywordValidation_arrayWithItemMatchingSchema_5_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 3, - 4, - 5 - ] - """, - """ - { - "contains": { - "minimum": 5 - } - } - """, - true, - """contains keyword validation -> array with item matching schema (5) is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword validation -> array with item matching schema (6) is valid" - */ - @Test - fun contains_containsKeywordValidation_arrayWithItemMatchingSchema_6_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 3, - 4, - 6 - ] - """, - """ - { - "contains": { - "minimum": 5 - } - } - """, - true, - """contains keyword validation -> array with item matching schema (6) is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword validation -> array with two items matching schema (5, 6) is valid" - */ - @Test - fun contains_containsKeywordValidation_arrayWithTwoItemsMatchingSchema_5_6_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 3, - 4, - 5, - 6 - ] - """, - """ - { - "contains": { - "minimum": 5 - } - } - """, - true, - """contains keyword validation -> array with two items matching schema (5, 6) is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword validation -> array without items matching schema is invalid" - */ - @Test - fun contains_containsKeywordValidation_arrayWithoutItemsMatchingSchemaIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 2, - 3, - 4 - ] - """, - """ - { - "contains": { - "minimum": 5 - } - } - """, - false, - """contains keyword validation -> array without items matching schema is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword validation -> empty array is invalid" - */ - @Test - fun contains_containsKeywordValidation_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "contains": { - "minimum": 5 - } - } - """, - false, - """contains keyword validation -> empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword validation -> not array is valid" - */ - @Test - fun contains_containsKeywordValidation_notArrayIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "contains": { - "minimum": 5 - } - } - """, - true, - """contains keyword validation -> not array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword with const keyword -> array with item 5 is valid" - */ - @Test - fun contains_containsKeywordWithConstKeyword_arrayWithItem5IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 3, - 4, - 5 - ] - """, - """ - { - "contains": { - "const": 5 - } - } - """, - true, - """contains keyword with const keyword -> array with item 5 is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword with const keyword -> array with two items 5 is valid" - */ - @Test - fun contains_containsKeywordWithConstKeyword_arrayWithTwoItems5IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 3, - 4, - 5, - 5 - ] - """, - """ - { - "contains": { - "const": 5 - } - } - """, - true, - """contains keyword with const keyword -> array with two items 5 is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword with const keyword -> array without item 5 is invalid" - */ - @Test - fun contains_containsKeywordWithConstKeyword_arrayWithoutItem5IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3, - 4 - ] - """, - """ - { - "contains": { - "const": 5 - } - } - """, - false, - """contains keyword with const keyword -> array without item 5 is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword with boolean schema true -> any non-empty array is valid" - */ - @Test - fun contains_containsKeywordWithBooleanSchemaTrue_anyNon_emptyArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - { - "contains": true - } - """, - true, - """contains keyword with boolean schema true -> any non-empty array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword with boolean schema true -> empty array is invalid" - */ - @Test - fun contains_containsKeywordWithBooleanSchemaTrue_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "contains": true - } - """, - false, - """contains keyword with boolean schema true -> empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword with boolean schema false -> any non-empty array is invalid" - */ - @Test - fun contains_containsKeywordWithBooleanSchemaFalse_anyNon_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - { - "contains": false - } - """, - false, - """contains keyword with boolean schema false -> any non-empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword with boolean schema false -> empty array is invalid" - */ - @Test - fun contains_containsKeywordWithBooleanSchemaFalse_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "contains": false - } - """, - false, - """contains keyword with boolean schema false -> empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains keyword with boolean schema false -> non-arrays are valid" - */ - @Test - fun contains_containsKeywordWithBooleanSchemaFalse_non_arraysAreValid() { - - assertKsonEnforcesSchema( - """ - "contains does not apply to strings" - """, - """ - { - "contains": false - } - """, - true, - """contains keyword with boolean schema false -> non-arrays are valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "items + contains -> matches items, does not match contains" - */ - @Test - fun contains_items_Contains_matchesItems_DoesNotMatchContains() { - - assertKsonEnforcesSchema( - """ - [ - 2, - 4, - 8 - ] - """, - """ - { - "items": { - "multipleOf": 2 - }, - "contains": { - "multipleOf": 3 - } - } - """, - false, - """items + contains -> matches items, does not match contains""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "items + contains -> does not match items, matches contains" - */ - @Test - fun contains_items_Contains_doesNotMatchItems_MatchesContains() { - - assertKsonEnforcesSchema( - """ - [ - 3, - 6, - 9 - ] - """, - """ - { - "items": { - "multipleOf": 2 - }, - "contains": { - "multipleOf": 3 - } - } - """, - false, - """items + contains -> does not match items, matches contains""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "items + contains -> matches both items and contains" - */ - @Test - fun contains_items_Contains_matchesBothItemsAndContains() { - - assertKsonEnforcesSchema( - """ - [ - 6, - 12 - ] - """, - """ - { - "items": { - "multipleOf": 2 - }, - "contains": { - "multipleOf": 3 - } - } - """, - true, - """items + contains -> matches both items and contains""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "items + contains -> matches neither items nor contains" - */ - @Test - fun contains_items_Contains_matchesNeitherItemsNorContains() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 5 - ] - """, - """ - { - "items": { - "multipleOf": 2 - }, - "contains": { - "multipleOf": 3 - } - } - """, - false, - """items + contains -> matches neither items nor contains""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains with false if subschema -> any non-empty array is valid" - */ - @Test - fun contains_containsWithFalseIfSubschema_anyNon_emptyArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - { - "contains": { - "if": false, - "else": true - } - } - """, - true, - """contains with false if subschema -> any non-empty array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains with false if subschema -> empty array is invalid" - */ - @Test - fun contains_containsWithFalseIfSubschema_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "contains": { - "if": false, - "else": true - } - } - """, - false, - """contains with false if subschema -> empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/contains.json`: - * "contains with null instance elements -> allows null items" - */ - @Test - fun contains_containsWithNullInstanceElements_allowsNullItems() { - - assertKsonEnforcesSchema( - """ - [ - null - ] - """, - """ - { - "contains": { - "type": "null" - } - } - """, - true, - """contains with null instance elements -> allows null items""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: - * "invalid type for default -> valid when property is specified" - */ - @Test - fun default_invalidTypeForDefault_validWhenPropertyIsSpecified() { - - assertKsonEnforcesSchema( - """ - { - "foo": 13 - } - """, - """ - { - "properties": { - "foo": { - "type": "integer", - "default": [ - ] - } - } - } - """, - true, - """invalid type for default -> valid when property is specified""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: - * "invalid type for default -> still valid when the invalid default is used" - */ - @Test - fun default_invalidTypeForDefault_stillValidWhenTheInvalidDefaultIsUsed() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "properties": { - "foo": { - "type": "integer", - "default": [ - ] - } - } - } - """, - true, - """invalid type for default -> still valid when the invalid default is used""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: - * "invalid string value for default -> valid when property is specified" - */ - @Test - fun default_invalidStringValueForDefault_validWhenPropertyIsSpecified() { - - assertKsonEnforcesSchema( - """ - { - "bar": "good" - } - """, - """ - { - "properties": { - "bar": { - "type": "string", - "minLength": 4, - "default": "bad" - } - } - } - """, - true, - """invalid string value for default -> valid when property is specified""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: - * "invalid string value for default -> still valid when the invalid default is used" - */ - @Test - fun default_invalidStringValueForDefault_stillValidWhenTheInvalidDefaultIsUsed() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "properties": { - "bar": { - "type": "string", - "minLength": 4, - "default": "bad" - } - } - } - """, - true, - """invalid string value for default -> still valid when the invalid default is used""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: - * "the default keyword does not do anything if the property is missing -> an explicit property value is checked against maximum (passing)" - */ - @Test - fun default_theDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing_anExplicitPropertyValueIsCheckedAgainstMaximum_passing_() { - - assertKsonEnforcesSchema( - """ - { - "alpha": 1 - } - """, - """ - { - "type": "object", - "properties": { - "alpha": { - "type": "number", - "maximum": 3, - "default": 5 - } - } - } - """, - true, - """the default keyword does not do anything if the property is missing -> an explicit property value is checked against maximum (passing)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: - * "the default keyword does not do anything if the property is missing -> an explicit property value is checked against maximum (failing)" - */ - @Test - fun default_theDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing_anExplicitPropertyValueIsCheckedAgainstMaximum_failing_() { - - assertKsonEnforcesSchema( - """ - { - "alpha": 5 - } - """, - """ - { - "type": "object", - "properties": { - "alpha": { - "type": "number", - "maximum": 3, - "default": 5 - } - } - } - """, - false, - """the default keyword does not do anything if the property is missing -> an explicit property value is checked against maximum (failing)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/default.json`: - * "the default keyword does not do anything if the property is missing -> missing properties are not filled in with the default" - */ - @Test - fun default_theDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing_missingPropertiesAreNotFilledInWithTheDefault() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "object", - "properties": { - "alpha": { - "type": "number", - "maximum": 3, - "default": 5 - } - } - } - """, - true, - """the default keyword does not do anything if the property is missing -> missing properties are not filled in with the default""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/definitions.json`: - * "validate definition against metaschema -> valid definition schema" - */ - @Test - fun definitions_validateDefinitionAgainstMetaschema_validDefinitionSchema() { - - assertKsonEnforcesSchema( - """ - { - "definitions": { - "foo": { - "type": "integer" - } - } - } - """, - """ - { - "${'$'}ref": "http://json-schema.org/draft-07/schema#" - } - """, - true, - """validate definition against metaschema -> valid definition schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/definitions.json`: - * "validate definition against metaschema -> invalid definition schema" - */ - @Test - fun definitions_validateDefinitionAgainstMetaschema_invalidDefinitionSchema() { - - assertKsonEnforcesSchema( - """ - { - "definitions": { - "foo": { - "type": 1 - } - } - } - """, - """ - { - "${'$'}ref": "http://json-schema.org/draft-07/schema#" - } - """, - false, - """validate definition against metaschema -> invalid definition schema""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies -> neither" - */ - @Test - fun dependencies_dependencies_neither() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "dependencies": { - "bar": [ - "foo" - ] - } - } - """, - true, - """dependencies -> neither""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies -> nondependant" - */ - @Test - fun dependencies_dependencies_nondependant() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "dependencies": { - "bar": [ - "foo" - ] - } - } - """, - true, - """dependencies -> nondependant""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies -> with dependency" - */ - @Test - fun dependencies_dependencies_withDependency() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "dependencies": { - "bar": [ - "foo" - ] - } - } - """, - true, - """dependencies -> with dependency""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies -> missing dependency" - */ - @Test - fun dependencies_dependencies_missingDependency() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "dependencies": { - "bar": [ - "foo" - ] - } - } - """, - false, - """dependencies -> missing dependency""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies -> ignores arrays" - */ - @Test - fun dependencies_dependencies_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - "bar" - ] - """, - """ - { - "dependencies": { - "bar": [ - "foo" - ] - } - } - """, - true, - """dependencies -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies -> ignores strings" - */ - @Test - fun dependencies_dependencies_ignoresStrings() { - - assertKsonEnforcesSchema( - """ - "foobar" - """, - """ - { - "dependencies": { - "bar": [ - "foo" - ] - } - } - """, - true, - """dependencies -> ignores strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies -> ignores other non-objects" - */ - @Test - fun dependencies_dependencies_ignoresOtherNon_objects() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "dependencies": { - "bar": [ - "foo" - ] - } - } - """, - true, - """dependencies -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with empty array -> empty object" - */ - @Test - fun dependencies_dependenciesWithEmptyArray_emptyObject() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "dependencies": { - "bar": [ - ] - } - } - """, - true, - """dependencies with empty array -> empty object""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with empty array -> object with one property" - */ - @Test - fun dependencies_dependenciesWithEmptyArray_objectWithOneProperty() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "dependencies": { - "bar": [ - ] - } - } - """, - true, - """dependencies with empty array -> object with one property""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with empty array -> non-object is valid" - */ - @Test - fun dependencies_dependenciesWithEmptyArray_non_objectIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "dependencies": { - "bar": [ - ] - } - } - """, - true, - """dependencies with empty array -> non-object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies -> neither" - */ - @Test - fun dependencies_multipleDependencies_neither() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "dependencies": { - "quux": [ - "foo", - "bar" - ] - } - } - """, - true, - """multiple dependencies -> neither""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies -> nondependants" - */ - @Test - fun dependencies_multipleDependencies_nondependants() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "dependencies": { - "quux": [ - "foo", - "bar" - ] - } - } - """, - true, - """multiple dependencies -> nondependants""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies -> with dependencies" - */ - @Test - fun dependencies_multipleDependencies_withDependencies() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2, - "quux": 3 - } - """, - """ - { - "dependencies": { - "quux": [ - "foo", - "bar" - ] - } - } - """, - true, - """multiple dependencies -> with dependencies""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies -> missing dependency" - */ - @Test - fun dependencies_multipleDependencies_missingDependency() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "quux": 2 - } - """, - """ - { - "dependencies": { - "quux": [ - "foo", - "bar" - ] - } - } - """, - false, - """multiple dependencies -> missing dependency""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies -> missing other dependency" - */ - @Test - fun dependencies_multipleDependencies_missingOtherDependency() { - - assertKsonEnforcesSchema( - """ - { - "bar": 1, - "quux": 2 - } - """, - """ - { - "dependencies": { - "quux": [ - "foo", - "bar" - ] - } - } - """, - false, - """multiple dependencies -> missing other dependency""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies -> missing both dependencies" - */ - @Test - fun dependencies_multipleDependencies_missingBothDependencies() { - - assertKsonEnforcesSchema( - """ - { - "quux": 1 - } - """, - """ - { - "dependencies": { - "quux": [ - "foo", - "bar" - ] - } - } - """, - false, - """multiple dependencies -> missing both dependencies""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies subschema -> valid" - */ - @Test - fun dependencies_multipleDependenciesSubschema_valid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "dependencies": { - "bar": { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "integer" - } - } - } - } - } - """, - true, - """multiple dependencies subschema -> valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies subschema -> no dependency" - */ - @Test - fun dependencies_multipleDependenciesSubschema_noDependency() { - - assertKsonEnforcesSchema( - """ - { - "foo": "quux" - } - """, - """ - { - "dependencies": { - "bar": { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "integer" - } - } - } - } - } - """, - true, - """multiple dependencies subschema -> no dependency""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies subschema -> wrong type" - */ - @Test - fun dependencies_multipleDependenciesSubschema_wrongType() { - - assertKsonEnforcesSchema( - """ - { - "foo": "quux", - "bar": 2 - } - """, - """ - { - "dependencies": { - "bar": { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "integer" - } - } - } - } - } - """, - false, - """multiple dependencies subschema -> wrong type""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies subschema -> wrong type other" - */ - @Test - fun dependencies_multipleDependenciesSubschema_wrongTypeOther() { - - assertKsonEnforcesSchema( - """ - { - "foo": 2, - "bar": "quux" - } - """, - """ - { - "dependencies": { - "bar": { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "integer" - } - } - } - } - } - """, - false, - """multiple dependencies subschema -> wrong type other""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "multiple dependencies subschema -> wrong type both" - */ - @Test - fun dependencies_multipleDependenciesSubschema_wrongTypeBoth() { - - assertKsonEnforcesSchema( - """ - { - "foo": "quux", - "bar": "quux" - } - """, - """ - { - "dependencies": { - "bar": { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "integer" - } - } - } - } - } - """, - false, - """multiple dependencies subschema -> wrong type both""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with boolean subschemas -> object with property having schema true is valid" - */ - @Test - fun dependencies_dependenciesWithBooleanSubschemas_objectWithPropertyHavingSchemaTrueIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "dependencies": { - "foo": true, - "bar": false - } - } - """, - true, - """dependencies with boolean subschemas -> object with property having schema true is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with boolean subschemas -> object with property having schema false is invalid" - */ - @Test - fun dependencies_dependenciesWithBooleanSubschemas_objectWithPropertyHavingSchemaFalseIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "dependencies": { - "foo": true, - "bar": false - } - } - """, - false, - """dependencies with boolean subschemas -> object with property having schema false is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with boolean subschemas -> object with both properties is invalid" - */ - @Test - fun dependencies_dependenciesWithBooleanSubschemas_objectWithBothPropertiesIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "dependencies": { - "foo": true, - "bar": false - } - } - """, - false, - """dependencies with boolean subschemas -> object with both properties is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with boolean subschemas -> empty object is valid" - */ - @Test - fun dependencies_dependenciesWithBooleanSubschemas_emptyObjectIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "dependencies": { - "foo": true, - "bar": false - } - } - """, - true, - """dependencies with boolean subschemas -> empty object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with escaped characters -> valid object 1" - */ - @Test - fun dependencies_dependenciesWithEscapedCharacters_validObject1() { - - assertKsonEnforcesSchema( - """ - { - "foo\nbar": 1, - "foo\rbar": 2 - } - """, - """ - { - "dependencies": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - }, - "foo\"bar": [ - "foo'bar" - ] - } - } - """, - true, - """dependencies with escaped characters -> valid object 1""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with escaped characters -> valid object 2" - */ - @Test - fun dependencies_dependenciesWithEscapedCharacters_validObject2() { - - assertKsonEnforcesSchema( - """ - { - "foo\tbar": 1, - "a": 2, - "b": 3, - "c": 4 - } - """, - """ - { - "dependencies": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - }, - "foo\"bar": [ - "foo'bar" - ] - } - } - """, - true, - """dependencies with escaped characters -> valid object 2""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with escaped characters -> valid object 3" - */ - @Test - fun dependencies_dependenciesWithEscapedCharacters_validObject3() { - - assertKsonEnforcesSchema( - """ - { - "foo'bar": 1, - "foo\"bar": 2 - } - """, - """ - { - "dependencies": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - }, - "foo\"bar": [ - "foo'bar" - ] - } - } - """, - true, - """dependencies with escaped characters -> valid object 3""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with escaped characters -> invalid object 1" - */ - @Test - fun dependencies_dependenciesWithEscapedCharacters_invalidObject1() { - - assertKsonEnforcesSchema( - """ - { - "foo\nbar": 1, - "foo": 2 - } - """, - """ - { - "dependencies": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - }, - "foo\"bar": [ - "foo'bar" - ] - } - } - """, - false, - """dependencies with escaped characters -> invalid object 1""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with escaped characters -> invalid object 2" - */ - @Test - fun dependencies_dependenciesWithEscapedCharacters_invalidObject2() { - - assertKsonEnforcesSchema( - """ - { - "foo\tbar": 1, - "a": 2 - } - """, - """ - { - "dependencies": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - }, - "foo\"bar": [ - "foo'bar" - ] - } - } - """, - false, - """dependencies with escaped characters -> invalid object 2""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with escaped characters -> invalid object 3" - */ - @Test - fun dependencies_dependenciesWithEscapedCharacters_invalidObject3() { - - assertKsonEnforcesSchema( - """ - { - "foo'bar": 1 - } - """, - """ - { - "dependencies": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - }, - "foo\"bar": [ - "foo'bar" - ] - } - } - """, - false, - """dependencies with escaped characters -> invalid object 3""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependencies with escaped characters -> invalid object 4" - */ - @Test - fun dependencies_dependenciesWithEscapedCharacters_invalidObject4() { - - assertKsonEnforcesSchema( - """ - { - "foo\"bar": 2 - } - """, - """ - { - "dependencies": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - }, - "foo\"bar": [ - "foo'bar" - ] - } - } - """, - false, - """dependencies with escaped characters -> invalid object 4""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependent subschema incompatible with root -> matches root" - */ - @Test - fun dependencies_dependentSubschemaIncompatibleWithRoot_matchesRoot() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "properties": { - "foo": { - } - }, - "dependencies": { - "foo": { - "properties": { - "bar": { - } - }, - "additionalProperties": false - } - } - } - """, - false, - """dependent subschema incompatible with root -> matches root""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependent subschema incompatible with root -> matches dependency" - */ - @Test - fun dependencies_dependentSubschemaIncompatibleWithRoot_matchesDependency() { - - assertKsonEnforcesSchema( - """ - { - "bar": 1 - } - """, - """ - { - "properties": { - "foo": { - } - }, - "dependencies": { - "foo": { - "properties": { - "bar": { - } - }, - "additionalProperties": false - } - } - } - """, - true, - """dependent subschema incompatible with root -> matches dependency""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependent subschema incompatible with root -> matches both" - */ - @Test - fun dependencies_dependentSubschemaIncompatibleWithRoot_matchesBoth() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "properties": { - "foo": { - } - }, - "dependencies": { - "foo": { - "properties": { - "bar": { - } - }, - "additionalProperties": false - } - } - } - """, - false, - """dependent subschema incompatible with root -> matches both""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/dependencies.json`: - * "dependent subschema incompatible with root -> no dependency" - */ - @Test - fun dependencies_dependentSubschemaIncompatibleWithRoot_noDependency() { - - assertKsonEnforcesSchema( - """ - { - "baz": 1 - } - """, - """ - { - "properties": { - "foo": { - } - }, - "dependencies": { - "foo": { - "properties": { - "bar": { - } - }, - "additionalProperties": false - } - } - } - """, - true, - """dependent subschema incompatible with root -> no dependency""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "simple enum validation -> one of the enum is valid" - */ - @Test - fun enum_simpleEnumValidation_oneOfTheEnumIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "enum": [ - 1, - 2, - 3 - ] - } - """, - true, - """simple enum validation -> one of the enum is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "simple enum validation -> something else is invalid" - */ - @Test - fun enum_simpleEnumValidation_somethingElseIsInvalid() { - - assertKsonEnforcesSchema( - """ - 4 - """, - """ - { - "enum": [ - 1, - 2, - 3 - ] - } - """, - false, - """simple enum validation -> something else is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "heterogeneous enum validation -> one of the enum is valid" - */ - @Test - fun enum_heterogeneousEnumValidation_oneOfTheEnumIsValid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "enum": [ - 6, - "foo", - [ - ], - true, - { - "foo": 12 - } - ] - } - """, - true, - """heterogeneous enum validation -> one of the enum is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "heterogeneous enum validation -> something else is invalid" - */ - @Test - fun enum_heterogeneousEnumValidation_somethingElseIsInvalid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "enum": [ - 6, - "foo", - [ - ], - true, - { - "foo": 12 - } - ] - } - """, - false, - """heterogeneous enum validation -> something else is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "heterogeneous enum validation -> objects are deep compared" - */ - @Test - fun enum_heterogeneousEnumValidation_objectsAreDeepCompared() { - - assertKsonEnforcesSchema( - """ - { - "foo": false - } - """, - """ - { - "enum": [ - 6, - "foo", - [ - ], - true, - { - "foo": 12 - } - ] - } - """, - false, - """heterogeneous enum validation -> objects are deep compared""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "heterogeneous enum validation -> valid object matches" - */ - @Test - fun enum_heterogeneousEnumValidation_validObjectMatches() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12 - } - """, - """ - { - "enum": [ - 6, - "foo", - [ - ], - true, - { - "foo": 12 - } - ] - } - """, - true, - """heterogeneous enum validation -> valid object matches""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "heterogeneous enum validation -> extra properties in object is invalid" - */ - @Test - fun enum_heterogeneousEnumValidation_extraPropertiesInObjectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12, - "boo": 42 - } - """, - """ - { - "enum": [ - 6, - "foo", - [ - ], - true, - { - "foo": 12 - } - ] - } - """, - false, - """heterogeneous enum validation -> extra properties in object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "heterogeneous enum-with-null validation -> null is valid" - */ - @Test - fun enum_heterogeneousEnum_with_nullValidation_nullIsValid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "enum": [ - 6, - null - ] - } - """, - true, - """heterogeneous enum-with-null validation -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "heterogeneous enum-with-null validation -> number is valid" - */ - @Test - fun enum_heterogeneousEnum_with_nullValidation_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 6 - """, - """ - { - "enum": [ - 6, - null - ] - } - """, - true, - """heterogeneous enum-with-null validation -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "heterogeneous enum-with-null validation -> something else is invalid" - */ - @Test - fun enum_heterogeneousEnum_with_nullValidation_somethingElseIsInvalid() { - - assertKsonEnforcesSchema( - """ - "test" - """, - """ - { - "enum": [ - 6, - null - ] - } - """, - false, - """heterogeneous enum-with-null validation -> something else is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enums in properties -> both properties are valid" - */ - @Test - fun enum_enumsInProperties_bothPropertiesAreValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "foo", - "bar": "bar" - } - """, - """ - { - "type": "object", - "properties": { - "foo": { - "enum": [ - "foo" - ] - }, - "bar": { - "enum": [ - "bar" - ] - } - }, - "required": [ - "bar" - ] - } - """, - true, - """enums in properties -> both properties are valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enums in properties -> wrong foo value" - */ - @Test - fun enum_enumsInProperties_wrongFooValue() { - - assertKsonEnforcesSchema( - """ - { - "foo": "foot", - "bar": "bar" - } - """, - """ - { - "type": "object", - "properties": { - "foo": { - "enum": [ - "foo" - ] - }, - "bar": { - "enum": [ - "bar" - ] - } - }, - "required": [ - "bar" - ] - } - """, - false, - """enums in properties -> wrong foo value""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enums in properties -> wrong bar value" - */ - @Test - fun enum_enumsInProperties_wrongBarValue() { - - assertKsonEnforcesSchema( - """ - { - "foo": "foo", - "bar": "bart" - } - """, - """ - { - "type": "object", - "properties": { - "foo": { - "enum": [ - "foo" - ] - }, - "bar": { - "enum": [ - "bar" - ] - } - }, - "required": [ - "bar" - ] - } - """, - false, - """enums in properties -> wrong bar value""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enums in properties -> missing optional property is valid" - */ - @Test - fun enum_enumsInProperties_missingOptionalPropertyIsValid() { - - assertKsonEnforcesSchema( - """ - { - "bar": "bar" - } - """, - """ - { - "type": "object", - "properties": { - "foo": { - "enum": [ - "foo" - ] - }, - "bar": { - "enum": [ - "bar" - ] - } - }, - "required": [ - "bar" - ] - } - """, - true, - """enums in properties -> missing optional property is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enums in properties -> missing required property is invalid" - */ - @Test - fun enum_enumsInProperties_missingRequiredPropertyIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "foo" - } - """, - """ - { - "type": "object", - "properties": { - "foo": { - "enum": [ - "foo" - ] - }, - "bar": { - "enum": [ - "bar" - ] - } - }, - "required": [ - "bar" - ] - } - """, - false, - """enums in properties -> missing required property is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enums in properties -> missing all properties is invalid" - */ - @Test - fun enum_enumsInProperties_missingAllPropertiesIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "object", - "properties": { - "foo": { - "enum": [ - "foo" - ] - }, - "bar": { - "enum": [ - "bar" - ] - } - }, - "required": [ - "bar" - ] - } - """, - false, - """enums in properties -> missing all properties is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with escaped characters -> member 1 is valid" - */ - @Test - fun enum_enumWithEscapedCharacters_member1IsValid() { - - assertKsonEnforcesSchema( - """ - "foo\nbar" - """, - """ - { - "enum": [ - "foo\nbar", - "foo\rbar" - ] - } - """, - true, - """enum with escaped characters -> member 1 is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with escaped characters -> member 2 is valid" - */ - @Test - fun enum_enumWithEscapedCharacters_member2IsValid() { - - assertKsonEnforcesSchema( - """ - "foo\rbar" - """, - """ - { - "enum": [ - "foo\nbar", - "foo\rbar" - ] - } - """, - true, - """enum with escaped characters -> member 2 is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with escaped characters -> another string is invalid" - */ - @Test - fun enum_enumWithEscapedCharacters_anotherStringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "abc" - """, - """ - { - "enum": [ - "foo\nbar", - "foo\rbar" - ] - } - """, - false, - """enum with escaped characters -> another string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with false does not match 0 -> false is valid" - */ - @Test - fun enum_enumWithFalseDoesNotMatch0_falseIsValid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "enum": [ - false - ] - } - """, - true, - """enum with false does not match 0 -> false is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with false does not match 0 -> integer zero is invalid" - */ - @Test - fun enum_enumWithFalseDoesNotMatch0_integerZeroIsInvalid() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "enum": [ - false - ] - } - """, - false, - """enum with false does not match 0 -> integer zero is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with false does not match 0 -> float zero is invalid" - */ - @Test - fun enum_enumWithFalseDoesNotMatch0_floatZeroIsInvalid() { - - assertKsonEnforcesSchema( - """ - 0.0 - """, - """ - { - "enum": [ - false - ] - } - """, - false, - """enum with false does not match 0 -> float zero is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [false] does not match [0] -> [false] is valid" - */ - @Test - fun enum_enumWith_false_DoesNotMatch_0___false_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - false - ] - """, - """ - { - "enum": [ - [ - false - ] - ] - } - """, - true, - """enum with [false] does not match [0] -> [false] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [false] does not match [0] -> [0] is invalid" - */ - @Test - fun enum_enumWith_false_DoesNotMatch_0___0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 0 - ] - """, - """ - { - "enum": [ - [ - false - ] - ] - } - """, - false, - """enum with [false] does not match [0] -> [0] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [false] does not match [0] -> [0.0] is invalid" - */ - @Test - fun enum_enumWith_false_DoesNotMatch_0___0_0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 0.0 - ] - """, - """ - { - "enum": [ - [ - false - ] - ] - } - """, - false, - """enum with [false] does not match [0] -> [0.0] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with true does not match 1 -> true is valid" - */ - @Test - fun enum_enumWithTrueDoesNotMatch1_trueIsValid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "enum": [ - true - ] - } - """, - true, - """enum with true does not match 1 -> true is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with true does not match 1 -> integer one is invalid" - */ - @Test - fun enum_enumWithTrueDoesNotMatch1_integerOneIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "enum": [ - true - ] - } - """, - false, - """enum with true does not match 1 -> integer one is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with true does not match 1 -> float one is invalid" - */ - @Test - fun enum_enumWithTrueDoesNotMatch1_floatOneIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1.0 - """, - """ - { - "enum": [ - true - ] - } - """, - false, - """enum with true does not match 1 -> float one is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [true] does not match [1] -> [true] is valid" - */ - @Test - fun enum_enumWith_true_DoesNotMatch_1___true_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - true - ] - """, - """ - { - "enum": [ - [ - true - ] - ] - } - """, - true, - """enum with [true] does not match [1] -> [true] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [true] does not match [1] -> [1] is invalid" - */ - @Test - fun enum_enumWith_true_DoesNotMatch_1___1_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "enum": [ - [ - true - ] - ] - } - """, - false, - """enum with [true] does not match [1] -> [1] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [true] does not match [1] -> [1.0] is invalid" - */ - @Test - fun enum_enumWith_true_DoesNotMatch_1___1_0_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1.0 - ] - """, - """ - { - "enum": [ - [ - true - ] - ] - } - """, - false, - """enum with [true] does not match [1] -> [1.0] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with 0 does not match false -> false is invalid" - */ - @Test - fun enum_enumWith0DoesNotMatchFalse_falseIsInvalid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "enum": [ - 0 - ] - } - """, - false, - """enum with 0 does not match false -> false is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with 0 does not match false -> integer zero is valid" - */ - @Test - fun enum_enumWith0DoesNotMatchFalse_integerZeroIsValid() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "enum": [ - 0 - ] - } - """, - true, - """enum with 0 does not match false -> integer zero is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with 0 does not match false -> float zero is valid" - */ - @Test - fun enum_enumWith0DoesNotMatchFalse_floatZeroIsValid() { - - assertKsonEnforcesSchema( - """ - 0.0 - """, - """ - { - "enum": [ - 0 - ] - } - """, - true, - """enum with 0 does not match false -> float zero is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [0] does not match [false] -> [false] is invalid" - */ - @Test - fun enum_enumWith_0_DoesNotMatch_false___false_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - false - ] - """, - """ - { - "enum": [ - [ - 0 - ] - ] - } - """, - false, - """enum with [0] does not match [false] -> [false] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [0] does not match [false] -> [0] is valid" - */ - @Test - fun enum_enumWith_0_DoesNotMatch_false___0_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 0 - ] - """, - """ - { - "enum": [ - [ - 0 - ] - ] - } - """, - true, - """enum with [0] does not match [false] -> [0] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [0] does not match [false] -> [0.0] is valid" - */ - @Test - fun enum_enumWith_0_DoesNotMatch_false___0_0_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 0.0 - ] - """, - """ - { - "enum": [ - [ - 0 - ] - ] - } - """, - true, - """enum with [0] does not match [false] -> [0.0] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with 1 does not match true -> true is invalid" - */ - @Test - fun enum_enumWith1DoesNotMatchTrue_trueIsInvalid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "enum": [ - 1 - ] - } - """, - false, - """enum with 1 does not match true -> true is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with 1 does not match true -> integer one is valid" - */ - @Test - fun enum_enumWith1DoesNotMatchTrue_integerOneIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "enum": [ - 1 - ] - } - """, - true, - """enum with 1 does not match true -> integer one is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with 1 does not match true -> float one is valid" - */ - @Test - fun enum_enumWith1DoesNotMatchTrue_floatOneIsValid() { - - assertKsonEnforcesSchema( - """ - 1.0 - """, - """ - { - "enum": [ - 1 - ] - } - """, - true, - """enum with 1 does not match true -> float one is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [1] does not match [true] -> [true] is invalid" - */ - @Test - fun enum_enumWith_1_DoesNotMatch_true___true_IsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - true - ] - """, - """ - { - "enum": [ - [ - 1 - ] - ] - } - """, - false, - """enum with [1] does not match [true] -> [true] is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [1] does not match [true] -> [1] is valid" - */ - @Test - fun enum_enumWith_1_DoesNotMatch_true___1_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "enum": [ - [ - 1 - ] - ] - } - """, - true, - """enum with [1] does not match [true] -> [1] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "enum with [1] does not match [true] -> [1.0] is valid" - */ - @Test - fun enum_enumWith_1_DoesNotMatch_true___1_0_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1.0 - ] - """, - """ - { - "enum": [ - [ - 1 - ] - ] - } - """, - true, - """enum with [1] does not match [true] -> [1.0] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "nul characters in strings -> match string with nul" - */ - @Test - fun enum_nulCharactersInStrings_matchStringWithNul() { - - assertKsonEnforcesSchema( - """ - "hello\u0000there" - """, - """ - { - "enum": [ - "hello\u0000there" - ] - } - """, - true, - """nul characters in strings -> match string with nul""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/enum.json`: - * "nul characters in strings -> do not match string lacking nul" - */ - @Test - fun enum_nulCharactersInStrings_doNotMatchStringLackingNul() { - - assertKsonEnforcesSchema( - """ - "hellothere" - """, - """ - { - "enum": [ - "hello\u0000there" - ] - } - """, - false, - """nul characters in strings -> do not match string lacking nul""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json`: - * "exclusiveMaximum validation -> below the exclusiveMaximum is valid" - */ - @Test - fun exclusiveMaximum_exclusiveMaximumValidation_belowTheExclusiveMaximumIsValid() { - - assertKsonEnforcesSchema( - """ - 2.2 - """, - """ - { - "exclusiveMaximum": 3.0 - } - """, - true, - """exclusiveMaximum validation -> below the exclusiveMaximum is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json`: - * "exclusiveMaximum validation -> boundary point is invalid" - */ - @Test - fun exclusiveMaximum_exclusiveMaximumValidation_boundaryPointIsInvalid() { - - assertKsonEnforcesSchema( - """ - 3.0 - """, - """ - { - "exclusiveMaximum": 3.0 - } - """, - false, - """exclusiveMaximum validation -> boundary point is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json`: - * "exclusiveMaximum validation -> above the exclusiveMaximum is invalid" - */ - @Test - fun exclusiveMaximum_exclusiveMaximumValidation_aboveTheExclusiveMaximumIsInvalid() { - - assertKsonEnforcesSchema( - """ - 3.5 - """, - """ - { - "exclusiveMaximum": 3.0 - } - """, - false, - """exclusiveMaximum validation -> above the exclusiveMaximum is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json`: - * "exclusiveMaximum validation -> ignores non-numbers" - */ - @Test - fun exclusiveMaximum_exclusiveMaximumValidation_ignoresNon_numbers() { - - assertKsonEnforcesSchema( - """ - "x" - """, - """ - { - "exclusiveMaximum": 3.0 - } - """, - true, - """exclusiveMaximum validation -> ignores non-numbers""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json`: - * "exclusiveMinimum validation -> above the exclusiveMinimum is valid" - */ - @Test - fun exclusiveMinimum_exclusiveMinimumValidation_aboveTheExclusiveMinimumIsValid() { - - assertKsonEnforcesSchema( - """ - 1.2 - """, - """ - { - "exclusiveMinimum": 1.1 - } - """, - true, - """exclusiveMinimum validation -> above the exclusiveMinimum is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json`: - * "exclusiveMinimum validation -> boundary point is invalid" - */ - @Test - fun exclusiveMinimum_exclusiveMinimumValidation_boundaryPointIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "exclusiveMinimum": 1.1 - } - """, - false, - """exclusiveMinimum validation -> boundary point is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json`: - * "exclusiveMinimum validation -> below the exclusiveMinimum is invalid" - */ - @Test - fun exclusiveMinimum_exclusiveMinimumValidation_belowTheExclusiveMinimumIsInvalid() { - - assertKsonEnforcesSchema( - """ - 0.6 - """, - """ - { - "exclusiveMinimum": 1.1 - } - """, - false, - """exclusiveMinimum validation -> below the exclusiveMinimum is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json`: - * "exclusiveMinimum validation -> ignores non-numbers" - */ - @Test - fun exclusiveMinimum_exclusiveMinimumValidation_ignoresNon_numbers() { - - assertKsonEnforcesSchema( - """ - "x" - """, - """ - { - "exclusiveMinimum": 1.1 - } - """, - true, - """exclusiveMinimum validation -> ignores non-numbers""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "email format -> all string formats ignore integers" - */ - @Test - fun format_emailFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "email" - } - """, - true, - """email format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "email format -> all string formats ignore floats" - */ - @Test - fun format_emailFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "email" - } - """, - true, - """email format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "email format -> all string formats ignore objects" - */ - @Test - fun format_emailFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "email" - } - """, - true, - """email format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "email format -> all string formats ignore arrays" - */ - @Test - fun format_emailFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "email" - } - """, - true, - """email format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "email format -> all string formats ignore booleans" - */ - @Test - fun format_emailFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "email" - } - """, - true, - """email format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "email format -> all string formats ignore nulls" - */ - @Test - fun format_emailFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "email" - } - """, - true, - """email format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-email format -> all string formats ignore integers" - */ - @Test - fun format_idn_emailFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "idn-email" - } - """, - true, - """idn-email format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-email format -> all string formats ignore floats" - */ - @Test - fun format_idn_emailFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "idn-email" - } - """, - true, - """idn-email format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-email format -> all string formats ignore objects" - */ - @Test - fun format_idn_emailFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "idn-email" - } - """, - true, - """idn-email format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-email format -> all string formats ignore arrays" - */ - @Test - fun format_idn_emailFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "idn-email" - } - """, - true, - """idn-email format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-email format -> all string formats ignore booleans" - */ - @Test - fun format_idn_emailFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "idn-email" - } - """, - true, - """idn-email format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-email format -> all string formats ignore nulls" - */ - @Test - fun format_idn_emailFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "idn-email" - } - """, - true, - """idn-email format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "regex format -> all string formats ignore integers" - */ - @Test - fun format_regexFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "regex" - } - """, - true, - """regex format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "regex format -> all string formats ignore floats" - */ - @Test - fun format_regexFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "regex" - } - """, - true, - """regex format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "regex format -> all string formats ignore objects" - */ - @Test - fun format_regexFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "regex" - } - """, - true, - """regex format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "regex format -> all string formats ignore arrays" - */ - @Test - fun format_regexFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "regex" - } - """, - true, - """regex format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "regex format -> all string formats ignore booleans" - */ - @Test - fun format_regexFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "regex" - } - """, - true, - """regex format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "regex format -> all string formats ignore nulls" - */ - @Test - fun format_regexFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "regex" - } - """, - true, - """regex format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv4 format -> all string formats ignore integers" - */ - @Test - fun format_ipv4Format_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "ipv4" - } - """, - true, - """ipv4 format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv4 format -> all string formats ignore floats" - */ - @Test - fun format_ipv4Format_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "ipv4" - } - """, - true, - """ipv4 format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv4 format -> all string formats ignore objects" - */ - @Test - fun format_ipv4Format_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "ipv4" - } - """, - true, - """ipv4 format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv4 format -> all string formats ignore arrays" - */ - @Test - fun format_ipv4Format_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "ipv4" - } - """, - true, - """ipv4 format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv4 format -> all string formats ignore booleans" - */ - @Test - fun format_ipv4Format_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "ipv4" - } - """, - true, - """ipv4 format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv4 format -> all string formats ignore nulls" - */ - @Test - fun format_ipv4Format_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "ipv4" - } - """, - true, - """ipv4 format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv6 format -> all string formats ignore integers" - */ - @Test - fun format_ipv6Format_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "ipv6" - } - """, - true, - """ipv6 format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv6 format -> all string formats ignore floats" - */ - @Test - fun format_ipv6Format_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "ipv6" - } - """, - true, - """ipv6 format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv6 format -> all string formats ignore objects" - */ - @Test - fun format_ipv6Format_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "ipv6" - } - """, - true, - """ipv6 format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv6 format -> all string formats ignore arrays" - */ - @Test - fun format_ipv6Format_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "ipv6" - } - """, - true, - """ipv6 format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv6 format -> all string formats ignore booleans" - */ - @Test - fun format_ipv6Format_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "ipv6" - } - """, - true, - """ipv6 format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "ipv6 format -> all string formats ignore nulls" - */ - @Test - fun format_ipv6Format_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "ipv6" - } - """, - true, - """ipv6 format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-hostname format -> all string formats ignore integers" - */ - @Test - fun format_idn_hostnameFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "idn-hostname" - } - """, - true, - """idn-hostname format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-hostname format -> all string formats ignore floats" - */ - @Test - fun format_idn_hostnameFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "idn-hostname" - } - """, - true, - """idn-hostname format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-hostname format -> all string formats ignore objects" - */ - @Test - fun format_idn_hostnameFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "idn-hostname" - } - """, - true, - """idn-hostname format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-hostname format -> all string formats ignore arrays" - */ - @Test - fun format_idn_hostnameFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "idn-hostname" - } - """, - true, - """idn-hostname format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-hostname format -> all string formats ignore booleans" - */ - @Test - fun format_idn_hostnameFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "idn-hostname" - } - """, - true, - """idn-hostname format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "idn-hostname format -> all string formats ignore nulls" - */ - @Test - fun format_idn_hostnameFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "idn-hostname" - } - """, - true, - """idn-hostname format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "hostname format -> all string formats ignore integers" - */ - @Test - fun format_hostnameFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "hostname" - } - """, - true, - """hostname format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "hostname format -> all string formats ignore floats" - */ - @Test - fun format_hostnameFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "hostname" - } - """, - true, - """hostname format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "hostname format -> all string formats ignore objects" - */ - @Test - fun format_hostnameFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "hostname" - } - """, - true, - """hostname format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "hostname format -> all string formats ignore arrays" - */ - @Test - fun format_hostnameFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "hostname" - } - """, - true, - """hostname format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "hostname format -> all string formats ignore booleans" - */ - @Test - fun format_hostnameFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "hostname" - } - """, - true, - """hostname format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "hostname format -> all string formats ignore nulls" - */ - @Test - fun format_hostnameFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "hostname" - } - """, - true, - """hostname format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date format -> all string formats ignore integers" - */ - @Test - fun format_dateFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "date" - } - """, - true, - """date format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date format -> all string formats ignore floats" - */ - @Test - fun format_dateFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "date" - } - """, - true, - """date format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date format -> all string formats ignore objects" - */ - @Test - fun format_dateFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "date" - } - """, - true, - """date format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date format -> all string formats ignore arrays" - */ - @Test - fun format_dateFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "date" - } - """, - true, - """date format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date format -> all string formats ignore booleans" - */ - @Test - fun format_dateFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "date" - } - """, - true, - """date format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date format -> all string formats ignore nulls" - */ - @Test - fun format_dateFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "date" - } - """, - true, - """date format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date-time format -> all string formats ignore integers" - */ - @Test - fun format_date_timeFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "date-time" - } - """, - true, - """date-time format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date-time format -> all string formats ignore floats" - */ - @Test - fun format_date_timeFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "date-time" - } - """, - true, - """date-time format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date-time format -> all string formats ignore objects" - */ - @Test - fun format_date_timeFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "date-time" - } - """, - true, - """date-time format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date-time format -> all string formats ignore arrays" - */ - @Test - fun format_date_timeFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "date-time" - } - """, - true, - """date-time format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date-time format -> all string formats ignore booleans" - */ - @Test - fun format_date_timeFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "date-time" - } - """, - true, - """date-time format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "date-time format -> all string formats ignore nulls" - */ - @Test - fun format_date_timeFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "date-time" - } - """, - true, - """date-time format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "time format -> all string formats ignore integers" - */ - @Test - fun format_timeFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "time" - } - """, - true, - """time format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "time format -> all string formats ignore floats" - */ - @Test - fun format_timeFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "time" - } - """, - true, - """time format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "time format -> all string formats ignore objects" - */ - @Test - fun format_timeFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "time" - } - """, - true, - """time format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "time format -> all string formats ignore arrays" - */ - @Test - fun format_timeFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "time" - } - """, - true, - """time format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "time format -> all string formats ignore booleans" - */ - @Test - fun format_timeFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "time" - } - """, - true, - """time format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "time format -> all string formats ignore nulls" - */ - @Test - fun format_timeFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "time" - } - """, - true, - """time format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "json-pointer format -> all string formats ignore integers" - */ - @Test - fun format_json_pointerFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "json-pointer" - } - """, - true, - """json-pointer format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "json-pointer format -> all string formats ignore floats" - */ - @Test - fun format_json_pointerFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "json-pointer" - } - """, - true, - """json-pointer format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "json-pointer format -> all string formats ignore objects" - */ - @Test - fun format_json_pointerFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "json-pointer" - } - """, - true, - """json-pointer format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "json-pointer format -> all string formats ignore arrays" - */ - @Test - fun format_json_pointerFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "json-pointer" - } - """, - true, - """json-pointer format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "json-pointer format -> all string formats ignore booleans" - */ - @Test - fun format_json_pointerFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "json-pointer" - } - """, - true, - """json-pointer format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "json-pointer format -> all string formats ignore nulls" - */ - @Test - fun format_json_pointerFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "json-pointer" - } - """, - true, - """json-pointer format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "relative-json-pointer format -> all string formats ignore integers" - */ - @Test - fun format_relative_json_pointerFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "relative-json-pointer" - } - """, - true, - """relative-json-pointer format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "relative-json-pointer format -> all string formats ignore floats" - */ - @Test - fun format_relative_json_pointerFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "relative-json-pointer" - } - """, - true, - """relative-json-pointer format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "relative-json-pointer format -> all string formats ignore objects" - */ - @Test - fun format_relative_json_pointerFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "relative-json-pointer" - } - """, - true, - """relative-json-pointer format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "relative-json-pointer format -> all string formats ignore arrays" - */ - @Test - fun format_relative_json_pointerFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "relative-json-pointer" - } - """, - true, - """relative-json-pointer format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "relative-json-pointer format -> all string formats ignore booleans" - */ - @Test - fun format_relative_json_pointerFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "relative-json-pointer" - } - """, - true, - """relative-json-pointer format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "relative-json-pointer format -> all string formats ignore nulls" - */ - @Test - fun format_relative_json_pointerFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "relative-json-pointer" - } - """, - true, - """relative-json-pointer format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri format -> all string formats ignore integers" - */ - @Test - fun format_iriFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "iri" - } - """, - true, - """iri format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri format -> all string formats ignore floats" - */ - @Test - fun format_iriFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "iri" - } - """, - true, - """iri format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri format -> all string formats ignore objects" - */ - @Test - fun format_iriFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "iri" - } - """, - true, - """iri format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri format -> all string formats ignore arrays" - */ - @Test - fun format_iriFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "iri" - } - """, - true, - """iri format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri format -> all string formats ignore booleans" - */ - @Test - fun format_iriFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "iri" - } - """, - true, - """iri format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri format -> all string formats ignore nulls" - */ - @Test - fun format_iriFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "iri" - } - """, - true, - """iri format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri-reference format -> all string formats ignore integers" - */ - @Test - fun format_iri_referenceFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "iri-reference" - } - """, - true, - """iri-reference format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri-reference format -> all string formats ignore floats" - */ - @Test - fun format_iri_referenceFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "iri-reference" - } - """, - true, - """iri-reference format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri-reference format -> all string formats ignore objects" - */ - @Test - fun format_iri_referenceFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "iri-reference" - } - """, - true, - """iri-reference format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri-reference format -> all string formats ignore arrays" - */ - @Test - fun format_iri_referenceFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "iri-reference" - } - """, - true, - """iri-reference format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri-reference format -> all string formats ignore booleans" - */ - @Test - fun format_iri_referenceFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "iri-reference" - } - """, - true, - """iri-reference format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "iri-reference format -> all string formats ignore nulls" - */ - @Test - fun format_iri_referenceFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "iri-reference" - } - """, - true, - """iri-reference format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri format -> all string formats ignore integers" - */ - @Test - fun format_uriFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "uri" - } - """, - true, - """uri format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri format -> all string formats ignore floats" - */ - @Test - fun format_uriFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "uri" - } - """, - true, - """uri format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri format -> all string formats ignore objects" - */ - @Test - fun format_uriFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "uri" - } - """, - true, - """uri format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri format -> all string formats ignore arrays" - */ - @Test - fun format_uriFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "uri" - } - """, - true, - """uri format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri format -> all string formats ignore booleans" - */ - @Test - fun format_uriFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "uri" - } - """, - true, - """uri format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri format -> all string formats ignore nulls" - */ - @Test - fun format_uriFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "uri" - } - """, - true, - """uri format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-reference format -> all string formats ignore integers" - */ - @Test - fun format_uri_referenceFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "uri-reference" - } - """, - true, - """uri-reference format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-reference format -> all string formats ignore floats" - */ - @Test - fun format_uri_referenceFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "uri-reference" - } - """, - true, - """uri-reference format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-reference format -> all string formats ignore objects" - */ - @Test - fun format_uri_referenceFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "uri-reference" - } - """, - true, - """uri-reference format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-reference format -> all string formats ignore arrays" - */ - @Test - fun format_uri_referenceFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "uri-reference" - } - """, - true, - """uri-reference format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-reference format -> all string formats ignore booleans" - */ - @Test - fun format_uri_referenceFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "uri-reference" - } - """, - true, - """uri-reference format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-reference format -> all string formats ignore nulls" - */ - @Test - fun format_uri_referenceFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "uri-reference" - } - """, - true, - """uri-reference format -> all string formats ignore nulls""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-template format -> all string formats ignore integers" - */ - @Test - fun format_uri_templateFormat_allStringFormatsIgnoreIntegers() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "format": "uri-template" - } - """, - true, - """uri-template format -> all string formats ignore integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-template format -> all string formats ignore floats" - */ - @Test - fun format_uri_templateFormat_allStringFormatsIgnoreFloats() { - - assertKsonEnforcesSchema( - """ - 13.7 - """, - """ - { - "format": "uri-template" - } - """, - true, - """uri-template format -> all string formats ignore floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-template format -> all string formats ignore objects" - */ - @Test - fun format_uri_templateFormat_allStringFormatsIgnoreObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "format": "uri-template" - } - """, - true, - """uri-template format -> all string formats ignore objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-template format -> all string formats ignore arrays" - */ - @Test - fun format_uri_templateFormat_allStringFormatsIgnoreArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "format": "uri-template" - } - """, - true, - """uri-template format -> all string formats ignore arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-template format -> all string formats ignore booleans" - */ - @Test - fun format_uri_templateFormat_allStringFormatsIgnoreBooleans() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "format": "uri-template" - } - """, - true, - """uri-template format -> all string formats ignore booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/format.json`: - * "uri-template format -> all string formats ignore nulls" - */ - @Test - fun format_uri_templateFormat_allStringFormatsIgnoreNulls() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "format": "uri-template" - } - """, - true, - """uri-template format -> all string formats ignore nulls""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "ignore if without then or else -> valid when valid against lone if" - */ - @Test - fun if_then_else_ignoreIfWithoutThenOrElse_validWhenValidAgainstLoneIf() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "if": { - "const": 0 - } - } - """, - true, - """ignore if without then or else -> valid when valid against lone if""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "ignore if without then or else -> valid when invalid against lone if" - */ - @Test - fun if_then_else_ignoreIfWithoutThenOrElse_validWhenInvalidAgainstLoneIf() { - - assertKsonEnforcesSchema( - """ - "hello" - """, - """ - { - "if": { - "const": 0 - } - } - """, - true, - """ignore if without then or else -> valid when invalid against lone if""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "ignore then without if -> valid when valid against lone then" - */ - @Test - fun if_then_else_ignoreThenWithoutIf_validWhenValidAgainstLoneThen() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "then": { - "const": 0 - } - } - """, - true, - """ignore then without if -> valid when valid against lone then""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "ignore then without if -> valid when invalid against lone then" - */ - @Test - fun if_then_else_ignoreThenWithoutIf_validWhenInvalidAgainstLoneThen() { - - assertKsonEnforcesSchema( - """ - "hello" - """, - """ - { - "then": { - "const": 0 - } - } - """, - true, - """ignore then without if -> valid when invalid against lone then""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "ignore else without if -> valid when valid against lone else" - */ - @Test - fun if_then_else_ignoreElseWithoutIf_validWhenValidAgainstLoneElse() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "else": { - "const": 0 - } - } - """, - true, - """ignore else without if -> valid when valid against lone else""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "ignore else without if -> valid when invalid against lone else" - */ - @Test - fun if_then_else_ignoreElseWithoutIf_validWhenInvalidAgainstLoneElse() { - - assertKsonEnforcesSchema( - """ - "hello" - """, - """ - { - "else": { - "const": 0 - } - } - """, - true, - """ignore else without if -> valid when invalid against lone else""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if and then without else -> valid through then" - */ - @Test - fun if_then_else_ifAndThenWithoutElse_validThroughThen() { - - assertKsonEnforcesSchema( - """ - -1 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - } - } - """, - true, - """if and then without else -> valid through then""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if and then without else -> invalid through then" - */ - @Test - fun if_then_else_ifAndThenWithoutElse_invalidThroughThen() { - - assertKsonEnforcesSchema( - """ - -100 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - } - } - """, - false, - """if and then without else -> invalid through then""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if and then without else -> valid when if test fails" - */ - @Test - fun if_then_else_ifAndThenWithoutElse_validWhenIfTestFails() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - } - } - """, - true, - """if and then without else -> valid when if test fails""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if and else without then -> valid when if test passes" - */ - @Test - fun if_then_else_ifAndElseWithoutThen_validWhenIfTestPasses() { - - assertKsonEnforcesSchema( - """ - -1 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "else": { - "multipleOf": 2 - } - } - """, - true, - """if and else without then -> valid when if test passes""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if and else without then -> valid through else" - */ - @Test - fun if_then_else_ifAndElseWithoutThen_validThroughElse() { - - assertKsonEnforcesSchema( - """ - 4 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "else": { - "multipleOf": 2 - } - } - """, - true, - """if and else without then -> valid through else""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if and else without then -> invalid through else" - */ - @Test - fun if_then_else_ifAndElseWithoutThen_invalidThroughElse() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "else": { - "multipleOf": 2 - } - } - """, - false, - """if and else without then -> invalid through else""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "validate against correct branch, then vs else -> valid through then" - */ - @Test - fun if_then_else_validateAgainstCorrectBranch_ThenVsElse_validThroughThen() { - - assertKsonEnforcesSchema( - """ - -1 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - }, - "else": { - "multipleOf": 2 - } - } - """, - true, - """validate against correct branch, then vs else -> valid through then""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "validate against correct branch, then vs else -> invalid through then" - */ - @Test - fun if_then_else_validateAgainstCorrectBranch_ThenVsElse_invalidThroughThen() { - - assertKsonEnforcesSchema( - """ - -100 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - }, - "else": { - "multipleOf": 2 - } - } - """, - false, - """validate against correct branch, then vs else -> invalid through then""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "validate against correct branch, then vs else -> valid through else" - */ - @Test - fun if_then_else_validateAgainstCorrectBranch_ThenVsElse_validThroughElse() { - - assertKsonEnforcesSchema( - """ - 4 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - }, - "else": { - "multipleOf": 2 - } - } - """, - true, - """validate against correct branch, then vs else -> valid through else""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "validate against correct branch, then vs else -> invalid through else" - */ - @Test - fun if_then_else_validateAgainstCorrectBranch_ThenVsElse_invalidThroughElse() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - }, - "else": { - "multipleOf": 2 - } - } - """, - false, - """validate against correct branch, then vs else -> invalid through else""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "non-interference across combined schemas -> valid, but would have been invalid through then" - */ - @Test - fun if_then_else_non_interferenceAcrossCombinedSchemas_valid_ButWouldHaveBeenInvalidThroughThen() { - - assertKsonEnforcesSchema( - """ - -100 - """, - """ - { - "allOf": [ - { - "if": { - "exclusiveMaximum": 0 - } - }, - { - "then": { - "minimum": -10 - } - }, - { - "else": { - "multipleOf": 2 - } - } - ] - } - """, - true, - """non-interference across combined schemas -> valid, but would have been invalid through then""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "non-interference across combined schemas -> valid, but would have been invalid through else" - */ - @Test - fun if_then_else_non_interferenceAcrossCombinedSchemas_valid_ButWouldHaveBeenInvalidThroughElse() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "allOf": [ - { - "if": { - "exclusiveMaximum": 0 - } - }, - { - "then": { - "minimum": -10 - } - }, - { - "else": { - "multipleOf": 2 - } - } - ] - } - """, - true, - """non-interference across combined schemas -> valid, but would have been invalid through else""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if with boolean schema true -> boolean schema true in if always chooses the then path (valid)" - */ - @Test - fun if_then_else_ifWithBooleanSchemaTrue_booleanSchemaTrueInIfAlwaysChoosesTheThenPath_valid_() { - - assertKsonEnforcesSchema( - """ - "then" - """, - """ - { - "if": true, - "then": { - "const": "then" - }, - "else": { - "const": "else" - } - } - """, - true, - """if with boolean schema true -> boolean schema true in if always chooses the then path (valid)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if with boolean schema true -> boolean schema true in if always chooses the then path (invalid)" - */ - @Test - fun if_then_else_ifWithBooleanSchemaTrue_booleanSchemaTrueInIfAlwaysChoosesTheThenPath_invalid_() { - - assertKsonEnforcesSchema( - """ - "else" - """, - """ - { - "if": true, - "then": { - "const": "then" - }, - "else": { - "const": "else" - } - } - """, - false, - """if with boolean schema true -> boolean schema true in if always chooses the then path (invalid)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if with boolean schema false -> boolean schema false in if always chooses the else path (invalid)" - */ - @Test - fun if_then_else_ifWithBooleanSchemaFalse_booleanSchemaFalseInIfAlwaysChoosesTheElsePath_invalid_() { - - assertKsonEnforcesSchema( - """ - "then" - """, - """ - { - "if": false, - "then": { - "const": "then" - }, - "else": { - "const": "else" - } - } - """, - false, - """if with boolean schema false -> boolean schema false in if always chooses the else path (invalid)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if with boolean schema false -> boolean schema false in if always chooses the else path (valid)" - */ - @Test - fun if_then_else_ifWithBooleanSchemaFalse_booleanSchemaFalseInIfAlwaysChoosesTheElsePath_valid_() { - - assertKsonEnforcesSchema( - """ - "else" - """, - """ - { - "if": false, - "then": { - "const": "then" - }, - "else": { - "const": "else" - } - } - """, - true, - """if with boolean schema false -> boolean schema false in if always chooses the else path (valid)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if appears at the end when serialized (keyword processing sequence) -> yes redirects to then and passes" - */ - @Test - fun if_then_else_ifAppearsAtTheEndWhenSerialized_keywordProcessingSequence__yesRedirectsToThenAndPasses() { - - assertKsonEnforcesSchema( - """ - "yes" - """, - """ - { - "then": { - "const": "yes" - }, - "else": { - "const": "other" - }, - "if": { - "maxLength": 4 - } - } - """, - true, - """if appears at the end when serialized (keyword processing sequence) -> yes redirects to then and passes""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if appears at the end when serialized (keyword processing sequence) -> other redirects to else and passes" - */ - @Test - fun if_then_else_ifAppearsAtTheEndWhenSerialized_keywordProcessingSequence__otherRedirectsToElseAndPasses() { - - assertKsonEnforcesSchema( - """ - "other" - """, - """ - { - "then": { - "const": "yes" - }, - "else": { - "const": "other" - }, - "if": { - "maxLength": 4 - } - } - """, - true, - """if appears at the end when serialized (keyword processing sequence) -> other redirects to else and passes""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if appears at the end when serialized (keyword processing sequence) -> no redirects to then and fails" - */ - @Test - fun if_then_else_ifAppearsAtTheEndWhenSerialized_keywordProcessingSequence__noRedirectsToThenAndFails() { - - assertKsonEnforcesSchema( - """ - "no" - """, - """ - { - "then": { - "const": "yes" - }, - "else": { - "const": "other" - }, - "if": { - "maxLength": 4 - } - } - """, - false, - """if appears at the end when serialized (keyword processing sequence) -> no redirects to then and fails""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json`: - * "if appears at the end when serialized (keyword processing sequence) -> invalid redirects to else and fails" - */ - @Test - fun if_then_else_ifAppearsAtTheEndWhenSerialized_keywordProcessingSequence__invalidRedirectsToElseAndFails() { - - assertKsonEnforcesSchema( - """ - "invalid" - """, - """ - { - "then": { - "const": "yes" - }, - "else": { - "const": "other" - }, - "if": { - "maxLength": 4 - } - } - """, - false, - """if appears at the end when serialized (keyword processing sequence) -> invalid redirects to else and fails""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/infinite-loop-detection.json`: - * "evaluating the same schema location against the same data location twice is not a sign of an infinite loop -> passing case" - */ - @Test - fun infinite_loop_detection_evaluatingTheSameSchemaLocationAgainstTheSameDataLocationTwiceIsNotASignOfAnInfiniteLoop_passingCase() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "definitions": { - "int": { - "type": "integer" - } - }, - "allOf": [ - { - "properties": { - "foo": { - "${'$'}ref": "#/definitions/int" - } - } - }, - { - "additionalProperties": { - "${'$'}ref": "#/definitions/int" - } - } - ] - } - """, - true, - """evaluating the same schema location against the same data location twice is not a sign of an infinite loop -> passing case""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/infinite-loop-detection.json`: - * "evaluating the same schema location against the same data location twice is not a sign of an infinite loop -> failing case" - */ - @Test - fun infinite_loop_detection_evaluatingTheSameSchemaLocationAgainstTheSameDataLocationTwiceIsNotASignOfAnInfiniteLoop_failingCase() { - - assertKsonEnforcesSchema( - """ - { - "foo": "a string" - } - """, - """ - { - "definitions": { - "int": { - "type": "integer" - } - }, - "allOf": [ - { - "properties": { - "foo": { - "${'$'}ref": "#/definitions/int" - } - } - }, - { - "additionalProperties": { - "${'$'}ref": "#/definitions/int" - } - } - ] - } - """, - false, - """evaluating the same schema location against the same data location twice is not a sign of an infinite loop -> failing case""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "a schema given for items -> valid items" - */ - @Test - fun items_aSchemaGivenForItems_validItems() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "items": { - "type": "integer" - } - } - """, - true, - """a schema given for items -> valid items""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "a schema given for items -> wrong type of items" - */ - @Test - fun items_aSchemaGivenForItems_wrongTypeOfItems() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "x" - ] - """, - """ - { - "items": { - "type": "integer" - } - } - """, - false, - """a schema given for items -> wrong type of items""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "a schema given for items -> ignores non-arrays" - */ - @Test - fun items_aSchemaGivenForItems_ignoresNon_arrays() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "items": { - "type": "integer" - } - } - """, - true, - """a schema given for items -> ignores non-arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "a schema given for items -> JavaScript pseudo-array is valid" - */ - @Test - fun items_aSchemaGivenForItems_javaScriptPseudo_arrayIsValid() { - - assertKsonEnforcesSchema( - """ - { - "0": "invalid", - "length": 1 - } - """, - """ - { - "items": { - "type": "integer" - } - } - """, - true, - """a schema given for items -> JavaScript pseudo-array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "an array of schemas for items -> correct types" - */ - @Test - fun items_anArrayOfSchemasForItems_correctTypes() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "foo" - ] - """, - """ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - """, - true, - """an array of schemas for items -> correct types""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "an array of schemas for items -> wrong types" - */ - @Test - fun items_anArrayOfSchemasForItems_wrongTypes() { - - assertKsonEnforcesSchema( - """ - [ - "foo", - 1 - ] - """, - """ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - """, - false, - """an array of schemas for items -> wrong types""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "an array of schemas for items -> incomplete array of items" - */ - @Test - fun items_anArrayOfSchemasForItems_incompleteArrayOfItems() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - """, - true, - """an array of schemas for items -> incomplete array of items""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "an array of schemas for items -> array with additional items" - */ - @Test - fun items_anArrayOfSchemasForItems_arrayWithAdditionalItems() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "foo", - true - ] - """, - """ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - """, - true, - """an array of schemas for items -> array with additional items""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "an array of schemas for items -> empty array" - */ - @Test - fun items_anArrayOfSchemasForItems_emptyArray() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - """, - true, - """an array of schemas for items -> empty array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "an array of schemas for items -> JavaScript pseudo-array is valid" - */ - @Test - fun items_anArrayOfSchemasForItems_javaScriptPseudo_arrayIsValid() { - - assertKsonEnforcesSchema( - """ - { - "0": "invalid", - "1": "valid", - "length": 2 - } - """, - """ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - """, - true, - """an array of schemas for items -> JavaScript pseudo-array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items with boolean schema (true) -> any array is valid" - */ - @Test - fun items_itemsWithBooleanSchema_true__anyArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "foo", - true - ] - """, - """ - { - "items": true - } - """, - true, - """items with boolean schema (true) -> any array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items with boolean schema (true) -> empty array is valid" - */ - @Test - fun items_itemsWithBooleanSchema_true__emptyArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "items": true - } - """, - true, - """items with boolean schema (true) -> empty array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items with boolean schema (false) -> any non-empty array is invalid" - */ - @Test - fun items_itemsWithBooleanSchema_false__anyNon_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "foo", - true - ] - """, - """ - { - "items": false - } - """, - false, - """items with boolean schema (false) -> any non-empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items with boolean schema (false) -> empty array is valid" - */ - @Test - fun items_itemsWithBooleanSchema_false__emptyArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "items": false - } - """, - true, - """items with boolean schema (false) -> empty array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items with boolean schemas -> array with one item is valid" - */ - @Test - fun items_itemsWithBooleanSchemas_arrayWithOneItemIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "items": [ - true, - false - ] - } - """, - true, - """items with boolean schemas -> array with one item is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items with boolean schemas -> array with two items is invalid" - */ - @Test - fun items_itemsWithBooleanSchemas_arrayWithTwoItemsIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "foo" - ] - """, - """ - { - "items": [ - true, - false - ] - } - """, - false, - """items with boolean schemas -> array with two items is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items with boolean schemas -> empty array is valid" - */ - @Test - fun items_itemsWithBooleanSchemas_emptyArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "items": [ - true, - false - ] - } - """, - true, - """items with boolean schemas -> empty array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items and subitems -> valid items" - */ - @Test - fun items_itemsAndSubitems_validItems() { - - assertKsonEnforcesSchema( - """ - [ - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ] - """, - """ - { - "definitions": { - "item": { - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/sub-item" - }, - { - "${'$'}ref": "#/definitions/sub-item" - } - ] - }, - "sub-item": { - "type": "object", - "required": [ - "foo" - ] - } - }, - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - } - ] - } - """, - true, - """items and subitems -> valid items""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items and subitems -> too many items" - */ - @Test - fun items_itemsAndSubitems_tooManyItems() { - - assertKsonEnforcesSchema( - """ - [ - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ] - """, - """ - { - "definitions": { - "item": { - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/sub-item" - }, - { - "${'$'}ref": "#/definitions/sub-item" - } - ] - }, - "sub-item": { - "type": "object", - "required": [ - "foo" - ] - } - }, - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - } - ] - } - """, - false, - """items and subitems -> too many items""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items and subitems -> too many sub-items" - */ - @Test - fun items_itemsAndSubitems_tooManySub_items() { - - assertKsonEnforcesSchema( - """ - [ - [ - { - "foo": null - }, - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ] - """, - """ - { - "definitions": { - "item": { - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/sub-item" - }, - { - "${'$'}ref": "#/definitions/sub-item" - } - ] - }, - "sub-item": { - "type": "object", - "required": [ - "foo" - ] - } - }, - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - } - ] - } - """, - false, - """items and subitems -> too many sub-items""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items and subitems -> wrong item" - */ - @Test - fun items_itemsAndSubitems_wrongItem() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": null - }, - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ] - """, - """ - { - "definitions": { - "item": { - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/sub-item" - }, - { - "${'$'}ref": "#/definitions/sub-item" - } - ] - }, - "sub-item": { - "type": "object", - "required": [ - "foo" - ] - } - }, - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - } - ] - } - """, - false, - """items and subitems -> wrong item""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items and subitems -> wrong sub-item" - */ - @Test - fun items_itemsAndSubitems_wrongSub_item() { - - assertKsonEnforcesSchema( - """ - [ - [ - { - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ] - """, - """ - { - "definitions": { - "item": { - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/sub-item" - }, - { - "${'$'}ref": "#/definitions/sub-item" - } - ] - }, - "sub-item": { - "type": "object", - "required": [ - "foo" - ] - } - }, - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - } - ] - } - """, - false, - """items and subitems -> wrong sub-item""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "items and subitems -> fewer items is valid" - */ - @Test - fun items_itemsAndSubitems_fewerItemsIsValid() { - - assertKsonEnforcesSchema( - """ - [ - [ - { - "foo": null - } - ], - [ - { - "foo": null - } - ] - ] - """, - """ - { - "definitions": { - "item": { - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/sub-item" - }, - { - "${'$'}ref": "#/definitions/sub-item" - } - ] - }, - "sub-item": { - "type": "object", - "required": [ - "foo" - ] - } - }, - "type": "array", - "additionalItems": false, - "items": [ - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - }, - { - "${'$'}ref": "#/definitions/item" - } - ] - } - """, - true, - """items and subitems -> fewer items is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "nested items -> valid nested array" - */ - @Test - fun items_nestedItems_validNestedArray() { - - assertKsonEnforcesSchema( - """ - [ - [ - [ - [ - 1 - ] - ], - [ - [ - 2 - ], - [ - 3 - ] - ] - ], - [ - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ] - ] - """, - """ - { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "number" - } - } - } - } - } - """, - true, - """nested items -> valid nested array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "nested items -> nested array with invalid type" - */ - @Test - fun items_nestedItems_nestedArrayWithInvalidType() { - - assertKsonEnforcesSchema( - """ - [ - [ - [ - [ - "1" - ] - ], - [ - [ - 2 - ], - [ - 3 - ] - ] - ], - [ - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ] - ] - """, - """ - { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "number" - } - } - } - } - } - """, - false, - """nested items -> nested array with invalid type""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "nested items -> not deep enough" - */ - @Test - fun items_nestedItems_notDeepEnough() { - - assertKsonEnforcesSchema( - """ - [ - [ - [ - 1 - ], - [ - 2 - ], - [ - 3 - ] - ], - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ] - """, - """ - { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "number" - } - } - } - } - } - """, - false, - """nested items -> not deep enough""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "single-form items with null instance elements -> allows null elements" - */ - @Test - fun items_single_formItemsWithNullInstanceElements_allowsNullElements() { - - assertKsonEnforcesSchema( - """ - [ - null - ] - """, - """ - { - "items": { - "type": "null" - } - } - """, - true, - """single-form items with null instance elements -> allows null elements""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/items.json`: - * "array-form items with null instance elements -> allows null elements" - */ - @Test - fun items_array_formItemsWithNullInstanceElements_allowsNullElements() { - - assertKsonEnforcesSchema( - """ - [ - null - ] - """, - """ - { - "items": [ - { - "type": "null" - } - ] - } - """, - true, - """array-form items with null instance elements -> allows null elements""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: - * "maxItems validation -> shorter is valid" - */ - @Test - fun maxItems_maxItemsValidation_shorterIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "maxItems": 2 - } - """, - true, - """maxItems validation -> shorter is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: - * "maxItems validation -> exact length is valid" - */ - @Test - fun maxItems_maxItemsValidation_exactLengthIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2 - ] - """, - """ - { - "maxItems": 2 - } - """, - true, - """maxItems validation -> exact length is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: - * "maxItems validation -> too long is invalid" - */ - @Test - fun maxItems_maxItemsValidation_tooLongIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "maxItems": 2 - } - """, - false, - """maxItems validation -> too long is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: - * "maxItems validation -> ignores non-arrays" - */ - @Test - fun maxItems_maxItemsValidation_ignoresNon_arrays() { - - assertKsonEnforcesSchema( - """ - "foobar" - """, - """ - { - "maxItems": 2 - } - """, - true, - """maxItems validation -> ignores non-arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: - * "maxItems validation with a decimal -> shorter is valid" - */ - @Test - fun maxItems_maxItemsValidationWithADecimal_shorterIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "maxItems": 2.0 - } - """, - true, - """maxItems validation with a decimal -> shorter is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxItems.json`: - * "maxItems validation with a decimal -> too long is invalid" - */ - @Test - fun maxItems_maxItemsValidationWithADecimal_tooLongIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "maxItems": 2.0 - } - """, - false, - """maxItems validation with a decimal -> too long is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: - * "maxLength validation -> shorter is valid" - */ - @Test - fun maxLength_maxLengthValidation_shorterIsValid() { - - assertKsonEnforcesSchema( - """ - "f" - """, - """ - { - "maxLength": 2 - } - """, - true, - """maxLength validation -> shorter is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: - * "maxLength validation -> exact length is valid" - */ - @Test - fun maxLength_maxLengthValidation_exactLengthIsValid() { - - assertKsonEnforcesSchema( - """ - "fo" - """, - """ - { - "maxLength": 2 - } - """, - true, - """maxLength validation -> exact length is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: - * "maxLength validation -> too long is invalid" - */ - @Test - fun maxLength_maxLengthValidation_tooLongIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "maxLength": 2 - } - """, - false, - """maxLength validation -> too long is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: - * "maxLength validation -> ignores non-strings" - */ - @Test - fun maxLength_maxLengthValidation_ignoresNon_strings() { - - assertKsonEnforcesSchema( - """ - 100 - """, - """ - { - "maxLength": 2 - } - """, - true, - """maxLength validation -> ignores non-strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: - * "maxLength validation -> two graphemes is long enough" - */ - @Test - fun maxLength_maxLengthValidation_twoGraphemesIsLongEnough() { - - assertKsonEnforcesSchema( - """ - "💩💩" - """, - """ - { - "maxLength": 2 - } - """, - true, - """maxLength validation -> two graphemes is long enough""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: - * "maxLength validation with a decimal -> shorter is valid" - */ - @Test - fun maxLength_maxLengthValidationWithADecimal_shorterIsValid() { - - assertKsonEnforcesSchema( - """ - "f" - """, - """ - { - "maxLength": 2.0 - } - """, - true, - """maxLength validation with a decimal -> shorter is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxLength.json`: - * "maxLength validation with a decimal -> too long is invalid" - */ - @Test - fun maxLength_maxLengthValidationWithADecimal_tooLongIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "maxLength": 2.0 - } - """, - false, - """maxLength validation with a decimal -> too long is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties validation -> shorter is valid" - */ - @Test - fun maxProperties_maxPropertiesValidation_shorterIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "maxProperties": 2 - } - """, - true, - """maxProperties validation -> shorter is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties validation -> exact length is valid" - */ - @Test - fun maxProperties_maxPropertiesValidation_exactLengthIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "maxProperties": 2 - } - """, - true, - """maxProperties validation -> exact length is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties validation -> too long is invalid" - */ - @Test - fun maxProperties_maxPropertiesValidation_tooLongIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2, - "baz": 3 - } - """, - """ - { - "maxProperties": 2 - } - """, - false, - """maxProperties validation -> too long is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties validation -> ignores arrays" - */ - @Test - fun maxProperties_maxPropertiesValidation_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "maxProperties": 2 - } - """, - true, - """maxProperties validation -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties validation -> ignores strings" - */ - @Test - fun maxProperties_maxPropertiesValidation_ignoresStrings() { - - assertKsonEnforcesSchema( - """ - "foobar" - """, - """ - { - "maxProperties": 2 - } - """, - true, - """maxProperties validation -> ignores strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties validation -> ignores other non-objects" - */ - @Test - fun maxProperties_maxPropertiesValidation_ignoresOtherNon_objects() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "maxProperties": 2 - } - """, - true, - """maxProperties validation -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties validation with a decimal -> shorter is valid" - */ - @Test - fun maxProperties_maxPropertiesValidationWithADecimal_shorterIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "maxProperties": 2.0 - } - """, - true, - """maxProperties validation with a decimal -> shorter is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties validation with a decimal -> too long is invalid" - */ - @Test - fun maxProperties_maxPropertiesValidationWithADecimal_tooLongIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2, - "baz": 3 - } - """, - """ - { - "maxProperties": 2.0 - } - """, - false, - """maxProperties validation with a decimal -> too long is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties = 0 means the object is empty -> no properties is valid" - */ - @Test - fun maxProperties_maxProperties_0MeansTheObjectIsEmpty_noPropertiesIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "maxProperties": 0 - } - """, - true, - """maxProperties = 0 means the object is empty -> no properties is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json`: - * "maxProperties = 0 means the object is empty -> one property is invalid" - */ - @Test - fun maxProperties_maxProperties_0MeansTheObjectIsEmpty_onePropertyIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "maxProperties": 0 - } - """, - false, - """maxProperties = 0 means the object is empty -> one property is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: - * "maximum validation -> below the maximum is valid" - */ - @Test - fun maximum_maximumValidation_belowTheMaximumIsValid() { - - assertKsonEnforcesSchema( - """ - 2.6 - """, - """ - { - "maximum": 3.0 - } - """, - true, - """maximum validation -> below the maximum is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: - * "maximum validation -> boundary point is valid" - */ - @Test - fun maximum_maximumValidation_boundaryPointIsValid() { - - assertKsonEnforcesSchema( - """ - 3.0 - """, - """ - { - "maximum": 3.0 - } - """, - true, - """maximum validation -> boundary point is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: - * "maximum validation -> above the maximum is invalid" - */ - @Test - fun maximum_maximumValidation_aboveTheMaximumIsInvalid() { - - assertKsonEnforcesSchema( - """ - 3.5 - """, - """ - { - "maximum": 3.0 - } - """, - false, - """maximum validation -> above the maximum is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: - * "maximum validation -> ignores non-numbers" - */ - @Test - fun maximum_maximumValidation_ignoresNon_numbers() { - - assertKsonEnforcesSchema( - """ - "x" - """, - """ - { - "maximum": 3.0 - } - """, - true, - """maximum validation -> ignores non-numbers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: - * "maximum validation with unsigned integer -> below the maximum is invalid" - */ - @Test - fun maximum_maximumValidationWithUnsignedInteger_belowTheMaximumIsInvalid() { - - assertKsonEnforcesSchema( - """ - 299.97 - """, - """ - { - "maximum": 300 - } - """, - true, - """maximum validation with unsigned integer -> below the maximum is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: - * "maximum validation with unsigned integer -> boundary point integer is valid" - */ - @Test - fun maximum_maximumValidationWithUnsignedInteger_boundaryPointIntegerIsValid() { - - assertKsonEnforcesSchema( - """ - 300 - """, - """ - { - "maximum": 300 - } - """, - true, - """maximum validation with unsigned integer -> boundary point integer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: - * "maximum validation with unsigned integer -> boundary point float is valid" - */ - @Test - fun maximum_maximumValidationWithUnsignedInteger_boundaryPointFloatIsValid() { - - assertKsonEnforcesSchema( - """ - 300.0 - """, - """ - { - "maximum": 300 - } - """, - true, - """maximum validation with unsigned integer -> boundary point float is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/maximum.json`: - * "maximum validation with unsigned integer -> above the maximum is invalid" - */ - @Test - fun maximum_maximumValidationWithUnsignedInteger_aboveTheMaximumIsInvalid() { - - assertKsonEnforcesSchema( - """ - 300.5 - """, - """ - { - "maximum": 300 - } - """, - false, - """maximum validation with unsigned integer -> above the maximum is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: - * "minItems validation -> longer is valid" - */ - @Test - fun minItems_minItemsValidation_longerIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2 - ] - """, - """ - { - "minItems": 1 - } - """, - true, - """minItems validation -> longer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: - * "minItems validation -> exact length is valid" - */ - @Test - fun minItems_minItemsValidation_exactLengthIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1 - ] - """, - """ - { - "minItems": 1 - } - """, - true, - """minItems validation -> exact length is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: - * "minItems validation -> too short is invalid" - */ - @Test - fun minItems_minItemsValidation_tooShortIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "minItems": 1 - } - """, - false, - """minItems validation -> too short is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: - * "minItems validation -> ignores non-arrays" - */ - @Test - fun minItems_minItemsValidation_ignoresNon_arrays() { - - assertKsonEnforcesSchema( - """ - "" - """, - """ - { - "minItems": 1 - } - """, - true, - """minItems validation -> ignores non-arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: - * "minItems validation with a decimal -> longer is valid" - */ - @Test - fun minItems_minItemsValidationWithADecimal_longerIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2 - ] - """, - """ - { - "minItems": 1.0 - } - """, - true, - """minItems validation with a decimal -> longer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minItems.json`: - * "minItems validation with a decimal -> too short is invalid" - */ - @Test - fun minItems_minItemsValidationWithADecimal_tooShortIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "minItems": 1.0 - } - """, - false, - """minItems validation with a decimal -> too short is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: - * "minLength validation -> longer is valid" - */ - @Test - fun minLength_minLengthValidation_longerIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "minLength": 2 - } - """, - true, - """minLength validation -> longer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: - * "minLength validation -> exact length is valid" - */ - @Test - fun minLength_minLengthValidation_exactLengthIsValid() { - - assertKsonEnforcesSchema( - """ - "fo" - """, - """ - { - "minLength": 2 - } - """, - true, - """minLength validation -> exact length is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: - * "minLength validation -> too short is invalid" - */ - @Test - fun minLength_minLengthValidation_tooShortIsInvalid() { - - assertKsonEnforcesSchema( - """ - "f" - """, - """ - { - "minLength": 2 - } - """, - false, - """minLength validation -> too short is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: - * "minLength validation -> ignores non-strings" - */ - @Test - fun minLength_minLengthValidation_ignoresNon_strings() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "minLength": 2 - } - """, - true, - """minLength validation -> ignores non-strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: - * "minLength validation -> one grapheme is not long enough" - */ - @Test - fun minLength_minLengthValidation_oneGraphemeIsNotLongEnough() { - - assertKsonEnforcesSchema( - """ - "💩" - """, - """ - { - "minLength": 2 - } - """, - false, - """minLength validation -> one grapheme is not long enough""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: - * "minLength validation with a decimal -> longer is valid" - */ - @Test - fun minLength_minLengthValidationWithADecimal_longerIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "minLength": 2.0 - } - """, - true, - """minLength validation with a decimal -> longer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minLength.json`: - * "minLength validation with a decimal -> too short is invalid" - */ - @Test - fun minLength_minLengthValidationWithADecimal_tooShortIsInvalid() { - - assertKsonEnforcesSchema( - """ - "f" - """, - """ - { - "minLength": 2.0 - } - """, - false, - """minLength validation with a decimal -> too short is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: - * "minProperties validation -> longer is valid" - */ - @Test - fun minProperties_minPropertiesValidation_longerIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "minProperties": 1 - } - """, - true, - """minProperties validation -> longer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: - * "minProperties validation -> exact length is valid" - */ - @Test - fun minProperties_minPropertiesValidation_exactLengthIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "minProperties": 1 - } - """, - true, - """minProperties validation -> exact length is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: - * "minProperties validation -> too short is invalid" - */ - @Test - fun minProperties_minPropertiesValidation_tooShortIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "minProperties": 1 - } - """, - false, - """minProperties validation -> too short is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: - * "minProperties validation -> ignores arrays" - */ - @Test - fun minProperties_minPropertiesValidation_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "minProperties": 1 - } - """, - true, - """minProperties validation -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: - * "minProperties validation -> ignores strings" - */ - @Test - fun minProperties_minPropertiesValidation_ignoresStrings() { - - assertKsonEnforcesSchema( - """ - "" - """, - """ - { - "minProperties": 1 - } - """, - true, - """minProperties validation -> ignores strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: - * "minProperties validation -> ignores other non-objects" - */ - @Test - fun minProperties_minPropertiesValidation_ignoresOtherNon_objects() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "minProperties": 1 - } - """, - true, - """minProperties validation -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: - * "minProperties validation with a decimal -> longer is valid" - */ - @Test - fun minProperties_minPropertiesValidationWithADecimal_longerIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "minProperties": 1.0 - } - """, - true, - """minProperties validation with a decimal -> longer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minProperties.json`: - * "minProperties validation with a decimal -> too short is invalid" - */ - @Test - fun minProperties_minPropertiesValidationWithADecimal_tooShortIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "minProperties": 1.0 - } - """, - false, - """minProperties validation with a decimal -> too short is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation -> above the minimum is valid" - */ - @Test - fun minimum_minimumValidation_aboveTheMinimumIsValid() { - - assertKsonEnforcesSchema( - """ - 2.6 - """, - """ - { - "minimum": 1.1 - } - """, - true, - """minimum validation -> above the minimum is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation -> boundary point is valid" - */ - @Test - fun minimum_minimumValidation_boundaryPointIsValid() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "minimum": 1.1 - } - """, - true, - """minimum validation -> boundary point is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation -> below the minimum is invalid" - */ - @Test - fun minimum_minimumValidation_belowTheMinimumIsInvalid() { - - assertKsonEnforcesSchema( - """ - 0.6 - """, - """ - { - "minimum": 1.1 - } - """, - false, - """minimum validation -> below the minimum is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation -> ignores non-numbers" - */ - @Test - fun minimum_minimumValidation_ignoresNon_numbers() { - - assertKsonEnforcesSchema( - """ - "x" - """, - """ - { - "minimum": 1.1 - } - """, - true, - """minimum validation -> ignores non-numbers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation with signed integer -> negative above the minimum is valid" - */ - @Test - fun minimum_minimumValidationWithSignedInteger_negativeAboveTheMinimumIsValid() { - - assertKsonEnforcesSchema( - """ - -1 - """, - """ - { - "minimum": -2 - } - """, - true, - """minimum validation with signed integer -> negative above the minimum is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation with signed integer -> positive above the minimum is valid" - */ - @Test - fun minimum_minimumValidationWithSignedInteger_positiveAboveTheMinimumIsValid() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "minimum": -2 - } - """, - true, - """minimum validation with signed integer -> positive above the minimum is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation with signed integer -> boundary point is valid" - */ - @Test - fun minimum_minimumValidationWithSignedInteger_boundaryPointIsValid() { - - assertKsonEnforcesSchema( - """ - -2 - """, - """ - { - "minimum": -2 - } - """, - true, - """minimum validation with signed integer -> boundary point is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation with signed integer -> boundary point with float is valid" - */ - @Test - fun minimum_minimumValidationWithSignedInteger_boundaryPointWithFloatIsValid() { - - assertKsonEnforcesSchema( - """ - -2.0 - """, - """ - { - "minimum": -2 - } - """, - true, - """minimum validation with signed integer -> boundary point with float is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation with signed integer -> float below the minimum is invalid" - */ - @Test - fun minimum_minimumValidationWithSignedInteger_floatBelowTheMinimumIsInvalid() { - - assertKsonEnforcesSchema( - """ - -2.0001 - """, - """ - { - "minimum": -2 - } - """, - false, - """minimum validation with signed integer -> float below the minimum is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation with signed integer -> int below the minimum is invalid" - */ - @Test - fun minimum_minimumValidationWithSignedInteger_intBelowTheMinimumIsInvalid() { - - assertKsonEnforcesSchema( - """ - -3 - """, - """ - { - "minimum": -2 - } - """, - false, - """minimum validation with signed integer -> int below the minimum is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/minimum.json`: - * "minimum validation with signed integer -> ignores non-numbers" - */ - @Test - fun minimum_minimumValidationWithSignedInteger_ignoresNon_numbers() { - - assertKsonEnforcesSchema( - """ - "x" - """, - """ - { - "minimum": -2 - } - """, - true, - """minimum validation with signed integer -> ignores non-numbers""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "by int -> int by int" - */ - @Test - fun multipleOf_byInt_intByInt() { - - assertKsonEnforcesSchema( - """ - 10 - """, - """ - { - "multipleOf": 2 - } - """, - true, - """by int -> int by int""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "by int -> int by int fail" - */ - @Test - fun multipleOf_byInt_intByIntFail() { - - assertKsonEnforcesSchema( - """ - 7 - """, - """ - { - "multipleOf": 2 - } - """, - false, - """by int -> int by int fail""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "by int -> ignores non-numbers" - */ - @Test - fun multipleOf_byInt_ignoresNon_numbers() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "multipleOf": 2 - } - """, - true, - """by int -> ignores non-numbers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "by number -> zero is multiple of anything" - */ - @Test - fun multipleOf_byNumber_zeroIsMultipleOfAnything() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "multipleOf": 1.5 - } - """, - true, - """by number -> zero is multiple of anything""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "by number -> 4.5 is multiple of 1.5" - */ - @Test - fun multipleOf_byNumber_4_5IsMultipleOf1_5() { - - assertKsonEnforcesSchema( - """ - 4.5 - """, - """ - { - "multipleOf": 1.5 - } - """, - true, - """by number -> 4.5 is multiple of 1.5""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "by number -> 35 is not multiple of 1.5" - */ - @Test - fun multipleOf_byNumber_35IsNotMultipleOf1_5() { - - assertKsonEnforcesSchema( - """ - 35 - """, - """ - { - "multipleOf": 1.5 - } - """, - false, - """by number -> 35 is not multiple of 1.5""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "by small number -> 0.0075 is multiple of 0.0001" - */ - @Test - fun multipleOf_bySmallNumber_0_0075IsMultipleOf0_0001() { - - assertKsonEnforcesSchema( - """ - 0.0075 - """, - """ - { - "multipleOf": 1.0E-4 - } - """, - true, - """by small number -> 0.0075 is multiple of 0.0001""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "by small number -> 0.00751 is not multiple of 0.0001" - */ - @Test - fun multipleOf_bySmallNumber_0_00751IsNotMultipleOf0_0001() { - - assertKsonEnforcesSchema( - """ - 0.00751 - """, - """ - { - "multipleOf": 1.0E-4 - } - """, - false, - """by small number -> 0.00751 is not multiple of 0.0001""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "float division = inf -> always invalid, but naive implementations may raise an overflow error" - */ - @Test - fun multipleOf_floatDivision_Inf_alwaysInvalid_ButNaiveImplementationsMayRaiseAnOverflowError() { - - assertKsonEnforcesSchema( - """ - 1.0E308 - """, - """ - { - "type": "integer", - "multipleOf": 0.123456789 - } - """, - false, - """float division = inf -> always invalid, but naive implementations may raise an overflow error""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json`: - * "small multiple of large integer -> any integer is a multiple of 1e-8" - */ - @Test - fun multipleOf_smallMultipleOfLargeInteger_anyIntegerIsAMultipleOf1e_8() { - - assertKsonEnforcesSchema( - """ - 12391239123 - """, - """ - { - "type": "integer", - "multipleOf": 1.0E-8 - } - """, - true, - """small multiple of large integer -> any integer is a multiple of 1e-8""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "not -> allowed" - */ - @Test - fun not_not_allowed() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "not": { - "type": "integer" - } - } - """, - true, - """not -> allowed""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "not -> disallowed" - */ - @Test - fun not_not_disallowed() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "not": { - "type": "integer" - } - } - """, - false, - """not -> disallowed""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "not multiple types -> valid" - */ - @Test - fun not_notMultipleTypes_valid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "not": { - "type": [ - "integer", - "boolean" - ] - } - } - """, - true, - """not multiple types -> valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "not multiple types -> mismatch" - */ - @Test - fun not_notMultipleTypes_mismatch() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "not": { - "type": [ - "integer", - "boolean" - ] - } - } - """, - false, - """not multiple types -> mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "not multiple types -> other mismatch" - */ - @Test - fun not_notMultipleTypes_otherMismatch() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "not": { - "type": [ - "integer", - "boolean" - ] - } - } - """, - false, - """not multiple types -> other mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "not more complex schema -> match" - */ - @Test - fun not_notMoreComplexSchema_match() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "not": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - } - } - } - """, - true, - """not more complex schema -> match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "not more complex schema -> other match" - */ - @Test - fun not_notMoreComplexSchema_otherMatch() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "not": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - } - } - } - """, - true, - """not more complex schema -> other match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "not more complex schema -> mismatch" - */ - @Test - fun not_notMoreComplexSchema_mismatch() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "not": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - } - } - } - """, - false, - """not more complex schema -> mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbidden property -> property present" - */ - @Test - fun not_forbiddenProperty_propertyPresent() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "properties": { - "foo": { - "not": { - } - } - } - } - """, - false, - """forbidden property -> property present""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbidden property -> property absent" - */ - @Test - fun not_forbiddenProperty_propertyAbsent() { - - assertKsonEnforcesSchema( - """ - { - "bar": 1, - "baz": 2 - } - """, - """ - { - "properties": { - "foo": { - "not": { - } - } - } - } - """, - true, - """forbidden property -> property absent""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> number is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> string is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> boolean true is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_booleanTrueIsInvalid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> boolean true is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> boolean false is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_booleanFalseIsInvalid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> boolean false is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> null is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_nullIsInvalid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> null is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> object is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_objectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> empty object is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_emptyObjectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> empty object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> array is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_arrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with empty schema -> empty array is invalid" - */ - @Test - fun not_forbidEverythingWithEmptySchema_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "not": { - } - } - """, - false, - """forbid everything with empty schema -> empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> number is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> string is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> boolean true is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_booleanTrueIsInvalid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> boolean true is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> boolean false is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_booleanFalseIsInvalid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> boolean false is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> null is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_nullIsInvalid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> null is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> object is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_objectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> empty object is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_emptyObjectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> empty object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> array is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_arrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "forbid everything with boolean schema true -> empty array is invalid" - */ - @Test - fun not_forbidEverythingWithBooleanSchemaTrue_emptyArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "not": true - } - """, - false, - """forbid everything with boolean schema true -> empty array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> number is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> string is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_stringIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> boolean true is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_booleanTrueIsValid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> boolean true is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> boolean false is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_booleanFalseIsValid() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> boolean false is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> null is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_nullIsValid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> object is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_objectIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> empty object is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_emptyObjectIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> empty object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> array is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_arrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "allow everything with boolean schema false -> empty array is valid" - */ - @Test - fun not_allowEverythingWithBooleanSchemaFalse_emptyArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "not": false - } - """, - true, - """allow everything with boolean schema false -> empty array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/not.json`: - * "double negation -> any value is valid" - */ - @Test - fun not_doubleNegation_anyValueIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "not": { - "not": { - } - } - } - """, - true, - """double negation -> any value is valid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf -> first oneOf valid" - */ - @Test - fun oneOf_oneOf_firstOneOfValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "oneOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - } - """, - true, - """oneOf -> first oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf -> second oneOf valid" - */ - @Test - fun oneOf_oneOf_secondOneOfValid() { - - assertKsonEnforcesSchema( - """ - 2.5 - """, - """ - { - "oneOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - } - """, - true, - """oneOf -> second oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf -> both oneOf valid" - */ - @Test - fun oneOf_oneOf_bothOneOfValid() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "oneOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - } - """, - false, - """oneOf -> both oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf -> neither oneOf valid" - */ - @Test - fun oneOf_oneOf_neitherOneOfValid() { - - assertKsonEnforcesSchema( - """ - 1.5 - """, - """ - { - "oneOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - } - """, - false, - """oneOf -> neither oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with base schema -> mismatch base schema" - */ - @Test - fun oneOf_oneOfWithBaseSchema_mismatchBaseSchema() { - - assertKsonEnforcesSchema( - """ - 3 - """, - """ - { - "type": "string", - "oneOf": [ - { - "minLength": 2 - }, - { - "maxLength": 4 - } - ] - } - """, - false, - """oneOf with base schema -> mismatch base schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with base schema -> one oneOf valid" - */ - @Test - fun oneOf_oneOfWithBaseSchema_oneOneOfValid() { - - assertKsonEnforcesSchema( - """ - "foobar" - """, - """ - { - "type": "string", - "oneOf": [ - { - "minLength": 2 - }, - { - "maxLength": 4 - } - ] - } - """, - true, - """oneOf with base schema -> one oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with base schema -> both oneOf valid" - */ - @Test - fun oneOf_oneOfWithBaseSchema_bothOneOfValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "string", - "oneOf": [ - { - "minLength": 2 - }, - { - "maxLength": 4 - } - ] - } - """, - false, - """oneOf with base schema -> both oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with boolean schemas, all true -> any value is invalid" - */ - @Test - fun oneOf_oneOfWithBooleanSchemas_AllTrue_anyValueIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "oneOf": [ - true, - true, - true - ] - } - """, - false, - """oneOf with boolean schemas, all true -> any value is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with boolean schemas, one true -> any value is valid" - */ - @Test - fun oneOf_oneOfWithBooleanSchemas_OneTrue_anyValueIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "oneOf": [ - true, - false, - false - ] - } - """, - true, - """oneOf with boolean schemas, one true -> any value is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with boolean schemas, more than one true -> any value is invalid" - */ - @Test - fun oneOf_oneOfWithBooleanSchemas_MoreThanOneTrue_anyValueIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "oneOf": [ - true, - true, - false - ] - } - """, - false, - """oneOf with boolean schemas, more than one true -> any value is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with boolean schemas, all false -> any value is invalid" - */ - @Test - fun oneOf_oneOfWithBooleanSchemas_AllFalse_anyValueIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "oneOf": [ - false, - false, - false - ] - } - """, - false, - """oneOf with boolean schemas, all false -> any value is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf complex types -> first oneOf valid (complex)" - */ - @Test - fun oneOf_oneOfComplexTypes_firstOneOfValid_complex_() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "oneOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - true, - """oneOf complex types -> first oneOf valid (complex)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf complex types -> second oneOf valid (complex)" - */ - @Test - fun oneOf_oneOfComplexTypes_secondOneOfValid_complex_() { - - assertKsonEnforcesSchema( - """ - { - "foo": "baz" - } - """, - """ - { - "oneOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - true, - """oneOf complex types -> second oneOf valid (complex)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf complex types -> both oneOf valid (complex)" - */ - @Test - fun oneOf_oneOfComplexTypes_bothOneOfValid_complex_() { - - assertKsonEnforcesSchema( - """ - { - "foo": "baz", - "bar": 2 - } - """, - """ - { - "oneOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - false, - """oneOf complex types -> both oneOf valid (complex)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf complex types -> neither oneOf valid (complex)" - */ - @Test - fun oneOf_oneOfComplexTypes_neitherOneOfValid_complex_() { - - assertKsonEnforcesSchema( - """ - { - "foo": 2, - "bar": "quux" - } - """, - """ - { - "oneOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - } - """, - false, - """oneOf complex types -> neither oneOf valid (complex)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with empty schema -> one valid - valid" - */ - @Test - fun oneOf_oneOfWithEmptySchema_oneValid_Valid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "oneOf": [ - { - "type": "number" - }, - { - } - ] - } - """, - true, - """oneOf with empty schema -> one valid - valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with empty schema -> both valid - invalid" - */ - @Test - fun oneOf_oneOfWithEmptySchema_bothValid_Invalid() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "oneOf": [ - { - "type": "number" - }, - { - } - ] - } - """, - false, - """oneOf with empty schema -> both valid - invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with required -> both invalid - invalid" - */ - @Test - fun oneOf_oneOfWithRequired_bothInvalid_Invalid() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "type": "object", - "oneOf": [ - { - "required": [ - "foo", - "bar" - ] - }, - { - "required": [ - "foo", - "baz" - ] - } - ] - } - """, - false, - """oneOf with required -> both invalid - invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with required -> first valid - valid" - */ - @Test - fun oneOf_oneOfWithRequired_firstValid_Valid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "type": "object", - "oneOf": [ - { - "required": [ - "foo", - "bar" - ] - }, - { - "required": [ - "foo", - "baz" - ] - } - ] - } - """, - true, - """oneOf with required -> first valid - valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with required -> second valid - valid" - */ - @Test - fun oneOf_oneOfWithRequired_secondValid_Valid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "baz": 3 - } - """, - """ - { - "type": "object", - "oneOf": [ - { - "required": [ - "foo", - "bar" - ] - }, - { - "required": [ - "foo", - "baz" - ] - } - ] - } - """, - true, - """oneOf with required -> second valid - valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with required -> both valid - invalid" - */ - @Test - fun oneOf_oneOfWithRequired_bothValid_Invalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2, - "baz": 3 - } - """, - """ - { - "type": "object", - "oneOf": [ - { - "required": [ - "foo", - "bar" - ] - }, - { - "required": [ - "foo", - "baz" - ] - } - ] - } - """, - false, - """oneOf with required -> both valid - invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with missing optional property -> first oneOf valid" - */ - @Test - fun oneOf_oneOfWithMissingOptionalProperty_firstOneOfValid() { - - assertKsonEnforcesSchema( - """ - { - "bar": 8 - } - """, - """ - { - "oneOf": [ - { - "properties": { - "bar": true, - "baz": true - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": true - }, - "required": [ - "foo" - ] - } - ] - } - """, - true, - """oneOf with missing optional property -> first oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with missing optional property -> second oneOf valid" - */ - @Test - fun oneOf_oneOfWithMissingOptionalProperty_secondOneOfValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "foo" - } - """, - """ - { - "oneOf": [ - { - "properties": { - "bar": true, - "baz": true - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": true - }, - "required": [ - "foo" - ] - } - ] - } - """, - true, - """oneOf with missing optional property -> second oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with missing optional property -> both oneOf valid" - */ - @Test - fun oneOf_oneOfWithMissingOptionalProperty_bothOneOfValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "foo", - "bar": 8 - } - """, - """ - { - "oneOf": [ - { - "properties": { - "bar": true, - "baz": true - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": true - }, - "required": [ - "foo" - ] - } - ] - } - """, - false, - """oneOf with missing optional property -> both oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "oneOf with missing optional property -> neither oneOf valid" - */ - @Test - fun oneOf_oneOfWithMissingOptionalProperty_neitherOneOfValid() { - - assertKsonEnforcesSchema( - """ - { - "baz": "quux" - } - """, - """ - { - "oneOf": [ - { - "properties": { - "bar": true, - "baz": true - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": true - }, - "required": [ - "foo" - ] - } - ] - } - """, - false, - """oneOf with missing optional property -> neither oneOf valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "nested oneOf, to check validation semantics -> null is valid" - */ - @Test - fun oneOf_nestedOneOf_ToCheckValidationSemantics_nullIsValid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "oneOf": [ - { - "oneOf": [ - { - "type": "null" - } - ] - } - ] - } - """, - true, - """nested oneOf, to check validation semantics -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/oneOf.json`: - * "nested oneOf, to check validation semantics -> anything non-null is invalid" - */ - @Test - fun oneOf_nestedOneOf_ToCheckValidationSemantics_anythingNon_nullIsInvalid() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "oneOf": [ - { - "oneOf": [ - { - "type": "null" - } - ] - } - ] - } - """, - false, - """nested oneOf, to check validation semantics -> anything non-null is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern validation -> a matching pattern is valid" - */ - @Test - fun pattern_patternValidation_aMatchingPatternIsValid() { - - assertKsonEnforcesSchema( - """ - "aaa" - """, - """ - { - "pattern": "^a*${'$'}" - } - """, - true, - """pattern validation -> a matching pattern is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern validation -> a non-matching pattern is invalid" - */ - @Test - fun pattern_patternValidation_aNon_matchingPatternIsInvalid() { - - assertKsonEnforcesSchema( - """ - "abc" - """, - """ - { - "pattern": "^a*${'$'}" - } - """, - false, - """pattern validation -> a non-matching pattern is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern validation -> ignores booleans" - */ - @Test - fun pattern_patternValidation_ignoresBooleans() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "pattern": "^a*${'$'}" - } - """, - true, - """pattern validation -> ignores booleans""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern validation -> ignores integers" - */ - @Test - fun pattern_patternValidation_ignoresIntegers() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "pattern": "^a*${'$'}" - } - """, - true, - """pattern validation -> ignores integers""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern validation -> ignores floats" - */ - @Test - fun pattern_patternValidation_ignoresFloats() { - - assertKsonEnforcesSchema( - """ - 1.0 - """, - """ - { - "pattern": "^a*${'$'}" - } - """, - true, - """pattern validation -> ignores floats""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern validation -> ignores objects" - */ - @Test - fun pattern_patternValidation_ignoresObjects() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "pattern": "^a*${'$'}" - } - """, - true, - """pattern validation -> ignores objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern validation -> ignores arrays" - */ - @Test - fun pattern_patternValidation_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "pattern": "^a*${'$'}" - } - """, - true, - """pattern validation -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern validation -> ignores null" - */ - @Test - fun pattern_patternValidation_ignoresNull() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "pattern": "^a*${'$'}" - } - """, - true, - """pattern validation -> ignores null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/pattern.json`: - * "pattern is not anchored -> matches a substring" - */ - @Test - fun pattern_patternIsNotAnchored_matchesASubstring() { - - assertKsonEnforcesSchema( - """ - "xxaayy" - """, - """ - { - "pattern": "a+" - } - """, - true, - """pattern is not anchored -> matches a substring""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties validates properties matching a regex -> a single valid match is valid" - */ - @Test - fun patternProperties_patternPropertiesValidatesPropertiesMatchingARegex_aSingleValidMatchIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "patternProperties": { - "f.*o": { - "type": "integer" - } - } - } - """, - true, - """patternProperties validates properties matching a regex -> a single valid match is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties validates properties matching a regex -> multiple valid matches is valid" - */ - @Test - fun patternProperties_patternPropertiesValidatesPropertiesMatchingARegex_multipleValidMatchesIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "foooooo": 2 - } - """, - """ - { - "patternProperties": { - "f.*o": { - "type": "integer" - } - } - } - """, - true, - """patternProperties validates properties matching a regex -> multiple valid matches is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties validates properties matching a regex -> a single invalid match is invalid" - */ - @Test - fun patternProperties_patternPropertiesValidatesPropertiesMatchingARegex_aSingleInvalidMatchIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar", - "fooooo": 2 - } - """, - """ - { - "patternProperties": { - "f.*o": { - "type": "integer" - } - } - } - """, - false, - """patternProperties validates properties matching a regex -> a single invalid match is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties validates properties matching a regex -> multiple invalid matches is invalid" - */ - @Test - fun patternProperties_patternPropertiesValidatesPropertiesMatchingARegex_multipleInvalidMatchesIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar", - "foooooo": "baz" - } - """, - """ - { - "patternProperties": { - "f.*o": { - "type": "integer" - } - } - } - """, - false, - """patternProperties validates properties matching a regex -> multiple invalid matches is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties validates properties matching a regex -> ignores arrays" - */ - @Test - fun patternProperties_patternPropertiesValidatesPropertiesMatchingARegex_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - "foo" - ] - """, - """ - { - "patternProperties": { - "f.*o": { - "type": "integer" - } - } - } - """, - true, - """patternProperties validates properties matching a regex -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties validates properties matching a regex -> ignores strings" - */ - @Test - fun patternProperties_patternPropertiesValidatesPropertiesMatchingARegex_ignoresStrings() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "patternProperties": { - "f.*o": { - "type": "integer" - } - } - } - """, - true, - """patternProperties validates properties matching a regex -> ignores strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties validates properties matching a regex -> ignores other non-objects" - */ - @Test - fun patternProperties_patternPropertiesValidatesPropertiesMatchingARegex_ignoresOtherNon_objects() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "patternProperties": { - "f.*o": { - "type": "integer" - } - } - } - """, - true, - """patternProperties validates properties matching a regex -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "multiple simultaneous patternProperties are validated -> a single valid match is valid" - */ - @Test - fun patternProperties_multipleSimultaneousPatternPropertiesAreValidated_aSingleValidMatchIsValid() { - - assertKsonEnforcesSchema( - """ - { - "a": 21 - } - """, - """ - { - "patternProperties": { - "a*": { - "type": "integer" - }, - "aaa*": { - "maximum": 20 - } - } - } - """, - true, - """multiple simultaneous patternProperties are validated -> a single valid match is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "multiple simultaneous patternProperties are validated -> a simultaneous match is valid" - */ - @Test - fun patternProperties_multipleSimultaneousPatternPropertiesAreValidated_aSimultaneousMatchIsValid() { - - assertKsonEnforcesSchema( - """ - { - "aaaa": 18 - } - """, - """ - { - "patternProperties": { - "a*": { - "type": "integer" - }, - "aaa*": { - "maximum": 20 - } - } - } - """, - true, - """multiple simultaneous patternProperties are validated -> a simultaneous match is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "multiple simultaneous patternProperties are validated -> multiple matches is valid" - */ - @Test - fun patternProperties_multipleSimultaneousPatternPropertiesAreValidated_multipleMatchesIsValid() { - - assertKsonEnforcesSchema( - """ - { - "a": 21, - "aaaa": 18 - } - """, - """ - { - "patternProperties": { - "a*": { - "type": "integer" - }, - "aaa*": { - "maximum": 20 - } - } - } - """, - true, - """multiple simultaneous patternProperties are validated -> multiple matches is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "multiple simultaneous patternProperties are validated -> an invalid due to one is invalid" - */ - @Test - fun patternProperties_multipleSimultaneousPatternPropertiesAreValidated_anInvalidDueToOneIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "a": "bar" - } - """, - """ - { - "patternProperties": { - "a*": { - "type": "integer" - }, - "aaa*": { - "maximum": 20 - } - } - } - """, - false, - """multiple simultaneous patternProperties are validated -> an invalid due to one is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "multiple simultaneous patternProperties are validated -> an invalid due to the other is invalid" - */ - @Test - fun patternProperties_multipleSimultaneousPatternPropertiesAreValidated_anInvalidDueToTheOtherIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "aaaa": 31 - } - """, - """ - { - "patternProperties": { - "a*": { - "type": "integer" - }, - "aaa*": { - "maximum": 20 - } - } - } - """, - false, - """multiple simultaneous patternProperties are validated -> an invalid due to the other is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "multiple simultaneous patternProperties are validated -> an invalid due to both is invalid" - */ - @Test - fun patternProperties_multipleSimultaneousPatternPropertiesAreValidated_anInvalidDueToBothIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "aaa": "foo", - "aaaa": 31 - } - """, - """ - { - "patternProperties": { - "a*": { - "type": "integer" - }, - "aaa*": { - "maximum": 20 - } - } - } - """, - false, - """multiple simultaneous patternProperties are validated -> an invalid due to both is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "regexes are not anchored by default and are case sensitive -> non recognized members are ignored" - */ - @Test - fun patternProperties_regexesAreNotAnchoredByDefaultAndAreCaseSensitive_nonRecognizedMembersAreIgnored() { - - assertKsonEnforcesSchema( - """ - { - "answer 1": "42" - } - """, - """ - { - "patternProperties": { - "[0-9]{2,}": { - "type": "boolean" - }, - "X_": { - "type": "string" - } - } - } - """, - true, - """regexes are not anchored by default and are case sensitive -> non recognized members are ignored""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "regexes are not anchored by default and are case sensitive -> recognized members are accounted for" - */ - @Test - fun patternProperties_regexesAreNotAnchoredByDefaultAndAreCaseSensitive_recognizedMembersAreAccountedFor() { - - assertKsonEnforcesSchema( - """ - { - "a31b": null - } - """, - """ - { - "patternProperties": { - "[0-9]{2,}": { - "type": "boolean" - }, - "X_": { - "type": "string" - } - } - } - """, - false, - """regexes are not anchored by default and are case sensitive -> recognized members are accounted for""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "regexes are not anchored by default and are case sensitive -> regexes are case sensitive" - */ - @Test - fun patternProperties_regexesAreNotAnchoredByDefaultAndAreCaseSensitive_regexesAreCaseSensitive() { - - assertKsonEnforcesSchema( - """ - { - "a_x_3": 3 - } - """, - """ - { - "patternProperties": { - "[0-9]{2,}": { - "type": "boolean" - }, - "X_": { - "type": "string" - } - } - } - """, - true, - """regexes are not anchored by default and are case sensitive -> regexes are case sensitive""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "regexes are not anchored by default and are case sensitive -> regexes are case sensitive, 2" - */ - @Test - fun patternProperties_regexesAreNotAnchoredByDefaultAndAreCaseSensitive_regexesAreCaseSensitive_2() { - - assertKsonEnforcesSchema( - """ - { - "a_X_3": 3 - } - """, - """ - { - "patternProperties": { - "[0-9]{2,}": { - "type": "boolean" - }, - "X_": { - "type": "string" - } - } - } - """, - false, - """regexes are not anchored by default and are case sensitive -> regexes are case sensitive, 2""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties with boolean schemas -> object with property matching schema true is valid" - */ - @Test - fun patternProperties_patternPropertiesWithBooleanSchemas_objectWithPropertyMatchingSchemaTrueIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "patternProperties": { - "f.*": true, - "b.*": false - } - } - """, - true, - """patternProperties with boolean schemas -> object with property matching schema true is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties with boolean schemas -> object with property matching schema false is invalid" - */ - @Test - fun patternProperties_patternPropertiesWithBooleanSchemas_objectWithPropertyMatchingSchemaFalseIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "patternProperties": { - "f.*": true, - "b.*": false - } - } - """, - false, - """patternProperties with boolean schemas -> object with property matching schema false is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties with boolean schemas -> object with both properties is invalid" - */ - @Test - fun patternProperties_patternPropertiesWithBooleanSchemas_objectWithBothPropertiesIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "patternProperties": { - "f.*": true, - "b.*": false - } - } - """, - false, - """patternProperties with boolean schemas -> object with both properties is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties with boolean schemas -> object with a property matching both true and false is invalid" - */ - @Test - fun patternProperties_patternPropertiesWithBooleanSchemas_objectWithAPropertyMatchingBothTrueAndFalseIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foobar": 1 - } - """, - """ - { - "patternProperties": { - "f.*": true, - "b.*": false - } - } - """, - false, - """patternProperties with boolean schemas -> object with a property matching both true and false is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties with boolean schemas -> empty object is valid" - */ - @Test - fun patternProperties_patternPropertiesWithBooleanSchemas_emptyObjectIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "patternProperties": { - "f.*": true, - "b.*": false - } - } - """, - true, - """patternProperties with boolean schemas -> empty object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json`: - * "patternProperties with null valued instance properties -> allows null values" - */ - @Test - fun patternProperties_patternPropertiesWithNullValuedInstanceProperties_allowsNullValues() { - - assertKsonEnforcesSchema( - """ - { - "foobar": null - } - """, - """ - { - "patternProperties": { - "^.*bar${'$'}": { - "type": "null" - } - } - } - """, - true, - """patternProperties with null valued instance properties -> allows null values""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "object properties validation -> both properties present and valid is valid" - */ - @Test - fun properties_objectPropertiesValidation_bothPropertiesPresentAndValidIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": "baz" - } - """, - """ - { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "string" - } - } - } - """, - true, - """object properties validation -> both properties present and valid is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "object properties validation -> one property invalid is invalid" - */ - @Test - fun properties_objectPropertiesValidation_onePropertyInvalidIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": { - } - } - """, - """ - { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "string" - } - } - } - """, - false, - """object properties validation -> one property invalid is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "object properties validation -> both properties invalid is invalid" - */ - @Test - fun properties_objectPropertiesValidation_bothPropertiesInvalidIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": [ - ], - "bar": { - } - } - """, - """ - { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "string" - } - } - } - """, - false, - """object properties validation -> both properties invalid is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "object properties validation -> doesn't invalidate other properties" - */ - @Test - fun properties_objectPropertiesValidation_doesn_tInvalidateOtherProperties() { - - assertKsonEnforcesSchema( - """ - { - "quux": [ - ] - } - """, - """ - { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "string" - } - } - } - """, - true, - """object properties validation -> doesn't invalidate other properties""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "object properties validation -> ignores arrays" - */ - @Test - fun properties_objectPropertiesValidation_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "string" - } - } - } - """, - true, - """object properties validation -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "object properties validation -> ignores other non-objects" - */ - @Test - fun properties_objectPropertiesValidation_ignoresOtherNon_objects() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "string" - } - } - } - """, - true, - """object properties validation -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties, patternProperties, additionalProperties interaction -> property validates property" - */ - @Test - fun properties_properties_PatternProperties_AdditionalPropertiesInteraction_propertyValidatesProperty() { - - assertKsonEnforcesSchema( - """ - { - "foo": [ - 1, - 2 - ] - } - """, - """ - { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - } - """, - true, - """properties, patternProperties, additionalProperties interaction -> property validates property""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties, patternProperties, additionalProperties interaction -> property invalidates property" - */ - @Test - fun properties_properties_PatternProperties_AdditionalPropertiesInteraction_propertyInvalidatesProperty() { - - assertKsonEnforcesSchema( - """ - { - "foo": [ - 1, - 2, - 3, - 4 - ] - } - """, - """ - { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - } - """, - false, - """properties, patternProperties, additionalProperties interaction -> property invalidates property""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties, patternProperties, additionalProperties interaction -> patternProperty invalidates property" - */ - @Test - fun properties_properties_PatternProperties_AdditionalPropertiesInteraction_patternPropertyInvalidatesProperty() { - - assertKsonEnforcesSchema( - """ - { - "foo": [ - ] - } - """, - """ - { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - } - """, - false, - """properties, patternProperties, additionalProperties interaction -> patternProperty invalidates property""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties, patternProperties, additionalProperties interaction -> patternProperty validates nonproperty" - */ - @Test - fun properties_properties_PatternProperties_AdditionalPropertiesInteraction_patternPropertyValidatesNonproperty() { - - assertKsonEnforcesSchema( - """ - { - "fxo": [ - 1, - 2 - ] - } - """, - """ - { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - } - """, - true, - """properties, patternProperties, additionalProperties interaction -> patternProperty validates nonproperty""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties, patternProperties, additionalProperties interaction -> patternProperty invalidates nonproperty" - */ - @Test - fun properties_properties_PatternProperties_AdditionalPropertiesInteraction_patternPropertyInvalidatesNonproperty() { - - assertKsonEnforcesSchema( - """ - { - "fxo": [ - ] - } - """, - """ - { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - } - """, - false, - """properties, patternProperties, additionalProperties interaction -> patternProperty invalidates nonproperty""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties, patternProperties, additionalProperties interaction -> additionalProperty ignores property" - */ - @Test - fun properties_properties_PatternProperties_AdditionalPropertiesInteraction_additionalPropertyIgnoresProperty() { - - assertKsonEnforcesSchema( - """ - { - "bar": [ - ] - } - """, - """ - { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - } - """, - true, - """properties, patternProperties, additionalProperties interaction -> additionalProperty ignores property""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties, patternProperties, additionalProperties interaction -> additionalProperty validates others" - */ - @Test - fun properties_properties_PatternProperties_AdditionalPropertiesInteraction_additionalPropertyValidatesOthers() { - - assertKsonEnforcesSchema( - """ - { - "quux": 3 - } - """, - """ - { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - } - """, - true, - """properties, patternProperties, additionalProperties interaction -> additionalProperty validates others""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties, patternProperties, additionalProperties interaction -> additionalProperty invalidates others" - */ - @Test - fun properties_properties_PatternProperties_AdditionalPropertiesInteraction_additionalPropertyInvalidatesOthers() { - - assertKsonEnforcesSchema( - """ - { - "quux": "foo" - } - """, - """ - { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - } - """, - false, - """properties, patternProperties, additionalProperties interaction -> additionalProperty invalidates others""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties with boolean schema -> no property present is valid" - */ - @Test - fun properties_propertiesWithBooleanSchema_noPropertyPresentIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "properties": { - "foo": true, - "bar": false - } - } - """, - true, - """properties with boolean schema -> no property present is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties with boolean schema -> only 'true' property present is valid" - */ - @Test - fun properties_propertiesWithBooleanSchema_only_true_PropertyPresentIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "properties": { - "foo": true, - "bar": false - } - } - """, - true, - """properties with boolean schema -> only 'true' property present is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties with boolean schema -> only 'false' property present is invalid" - */ - @Test - fun properties_propertiesWithBooleanSchema_only_false_PropertyPresentIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "bar": 2 - } - """, - """ - { - "properties": { - "foo": true, - "bar": false - } - } - """, - false, - """properties with boolean schema -> only 'false' property present is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties with boolean schema -> both properties present is invalid" - */ - @Test - fun properties_propertiesWithBooleanSchema_bothPropertiesPresentIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1, - "bar": 2 - } - """, - """ - { - "properties": { - "foo": true, - "bar": false - } - } - """, - false, - """properties with boolean schema -> both properties present is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties with escaped characters -> object with all numbers is valid" - */ - @Test - fun properties_propertiesWithEscapedCharacters_objectWithAllNumbersIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo\nbar": 1, - "foo\"bar": 1, - "foo\\bar": 1, - "foo\rbar": 1, - "foo\tbar": 1, - "foo\fbar": 1 - } - """, - """ - { - "properties": { - "foo\nbar": { - "type": "number" - }, - "foo\"bar": { - "type": "number" - }, - "foo\\bar": { - "type": "number" - }, - "foo\rbar": { - "type": "number" - }, - "foo\tbar": { - "type": "number" - }, - "foo\fbar": { - "type": "number" - } - } - } - """, - true, - """properties with escaped characters -> object with all numbers is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties with escaped characters -> object with strings is invalid" - */ - @Test - fun properties_propertiesWithEscapedCharacters_objectWithStringsIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo\nbar": "1", - "foo\"bar": "1", - "foo\\bar": "1", - "foo\rbar": "1", - "foo\tbar": "1", - "foo\fbar": "1" - } - """, - """ - { - "properties": { - "foo\nbar": { - "type": "number" - }, - "foo\"bar": { - "type": "number" - }, - "foo\\bar": { - "type": "number" - }, - "foo\rbar": { - "type": "number" - }, - "foo\tbar": { - "type": "number" - }, - "foo\fbar": { - "type": "number" - } - } - } - """, - false, - """properties with escaped characters -> object with strings is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties with null valued instance properties -> allows null values" - */ - @Test - fun properties_propertiesWithNullValuedInstanceProperties_allowsNullValues() { - - assertKsonEnforcesSchema( - """ - { - "foo": null - } - """, - """ - { - "properties": { - "foo": { - "type": "null" - } - } - } - """, - true, - """properties with null valued instance properties -> allows null values""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties whose names are Javascript object property names -> ignores arrays" - */ - @Test - fun properties_propertiesWhoseNamesAreJavascriptObjectPropertyNames_ignoresArrays() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "properties": { - "__proto__": { - "type": "number" - }, - "toString": { - "properties": { - "length": { - "type": "string" - } - } - }, - "constructor": { - "type": "number" - } - } - } - """, - true, - """properties whose names are Javascript object property names -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties whose names are Javascript object property names -> ignores other non-objects" - */ - @Test - fun properties_propertiesWhoseNamesAreJavascriptObjectPropertyNames_ignoresOtherNon_objects() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "properties": { - "__proto__": { - "type": "number" - }, - "toString": { - "properties": { - "length": { - "type": "string" - } - } - }, - "constructor": { - "type": "number" - } - } - } - """, - true, - """properties whose names are Javascript object property names -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties whose names are Javascript object property names -> none of the properties mentioned" - */ - @Test - fun properties_propertiesWhoseNamesAreJavascriptObjectPropertyNames_noneOfThePropertiesMentioned() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "properties": { - "__proto__": { - "type": "number" - }, - "toString": { - "properties": { - "length": { - "type": "string" - } - } - }, - "constructor": { - "type": "number" - } - } - } - """, - true, - """properties whose names are Javascript object property names -> none of the properties mentioned""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties whose names are Javascript object property names -> __proto__ not valid" - */ - @Test - fun properties_propertiesWhoseNamesAreJavascriptObjectPropertyNames___proto__NotValid() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - "__proto__": "foo" - } - """, - """ - { - "properties": { - "__proto__": { - "type": "number" - }, - "toString": { - "properties": { - "length": { - "type": "string" - } - } - }, - "constructor": { - "type": "number" - } - } - } - """, - false, - """properties whose names are Javascript object property names -> __proto__ not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties whose names are Javascript object property names -> toString not valid" - */ - @Test - fun properties_propertiesWhoseNamesAreJavascriptObjectPropertyNames_toStringNotValid() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - "toString": { - "length": 37 - } - } - """, - """ - { - "properties": { - "__proto__": { - "type": "number" - }, - "toString": { - "properties": { - "length": { - "type": "string" - } - } - }, - "constructor": { - "type": "number" - } - } - } - """, - false, - """properties whose names are Javascript object property names -> toString not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties whose names are Javascript object property names -> constructor not valid" - */ - @Test - fun properties_propertiesWhoseNamesAreJavascriptObjectPropertyNames_constructorNotValid() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - "constructor": { - "length": 37 - } - } - """, - """ - { - "properties": { - "__proto__": { - "type": "number" - }, - "toString": { - "properties": { - "length": { - "type": "string" - } - } - }, - "constructor": { - "type": "number" - } - } - } - """, - false, - """properties whose names are Javascript object property names -> constructor not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/properties.json`: - * "properties whose names are Javascript object property names -> all present and valid" - */ - @Test - fun properties_propertiesWhoseNamesAreJavascriptObjectPropertyNames_allPresentAndValid() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - "__proto__": 12, - "toString": { - "length": "foo" - }, - "constructor": 37 - } - """, - """ - { - "properties": { - "__proto__": { - "type": "number" - }, - "toString": { - "properties": { - "length": { - "type": "string" - } - } - }, - "constructor": { - "type": "number" - } - } - } - """, - true, - """properties whose names are Javascript object property names -> all present and valid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation -> all property names valid" - */ - @Test - fun propertyNames_propertyNamesValidation_allPropertyNamesValid() { - - assertKsonEnforcesSchema( - """ - { - "f": { - }, - "foo": { - } - } - """, - """ - { - "propertyNames": { - "maxLength": 3 - } - } - """, - true, - """propertyNames validation -> all property names valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation -> some property names invalid" - */ - @Test - fun propertyNames_propertyNamesValidation_somePropertyNamesInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - }, - "foobar": { - } - } - """, - """ - { - "propertyNames": { - "maxLength": 3 - } - } - """, - false, - """propertyNames validation -> some property names invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation -> object without properties is valid" - */ - @Test - fun propertyNames_propertyNamesValidation_objectWithoutPropertiesIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "propertyNames": { - "maxLength": 3 - } - } - """, - true, - """propertyNames validation -> object without properties is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation -> ignores arrays" - */ - @Test - fun propertyNames_propertyNamesValidation_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3, - 4 - ] - """, - """ - { - "propertyNames": { - "maxLength": 3 - } - } - """, - true, - """propertyNames validation -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation -> ignores strings" - */ - @Test - fun propertyNames_propertyNamesValidation_ignoresStrings() { - - assertKsonEnforcesSchema( - """ - "foobar" - """, - """ - { - "propertyNames": { - "maxLength": 3 - } - } - """, - true, - """propertyNames validation -> ignores strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation -> ignores other non-objects" - */ - @Test - fun propertyNames_propertyNamesValidation_ignoresOtherNon_objects() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "propertyNames": { - "maxLength": 3 - } - } - """, - true, - """propertyNames validation -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation with pattern -> matching property names valid" - */ - @Test - fun propertyNames_propertyNamesValidationWithPattern_matchingPropertyNamesValid() { - - assertKsonEnforcesSchema( - """ - { - "a": { - }, - "aa": { - }, - "aaa": { - } - } - """, - """ - { - "propertyNames": { - "pattern": "^a+${'$'}" - } - } - """, - true, - """propertyNames validation with pattern -> matching property names valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation with pattern -> non-matching property name is invalid" - */ - @Test - fun propertyNames_propertyNamesValidationWithPattern_non_matchingPropertyNameIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "aaA": { - } - } - """, - """ - { - "propertyNames": { - "pattern": "^a+${'$'}" - } - } - """, - false, - """propertyNames validation with pattern -> non-matching property name is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames validation with pattern -> object without properties is valid" - */ - @Test - fun propertyNames_propertyNamesValidationWithPattern_objectWithoutPropertiesIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "propertyNames": { - "pattern": "^a+${'$'}" - } - } - """, - true, - """propertyNames validation with pattern -> object without properties is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames with boolean schema true -> object with any properties is valid" - */ - @Test - fun propertyNames_propertyNamesWithBooleanSchemaTrue_objectWithAnyPropertiesIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "propertyNames": true - } - """, - true, - """propertyNames with boolean schema true -> object with any properties is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames with boolean schema true -> empty object is valid" - */ - @Test - fun propertyNames_propertyNamesWithBooleanSchemaTrue_emptyObjectIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "propertyNames": true - } - """, - true, - """propertyNames with boolean schema true -> empty object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames with boolean schema false -> object with any properties is invalid" - */ - @Test - fun propertyNames_propertyNamesWithBooleanSchemaFalse_objectWithAnyPropertiesIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "propertyNames": false - } - """, - false, - """propertyNames with boolean schema false -> object with any properties is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json`: - * "propertyNames with boolean schema false -> empty object is valid" - */ - @Test - fun propertyNames_propertyNamesWithBooleanSchemaFalse_emptyObjectIsValid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "propertyNames": false - } - """, - true, - """propertyNames with boolean schema false -> empty object is valid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "root pointer ref -> match" - */ - @Test - fun ref_rootPointerRef_match() { - - assertKsonEnforcesSchema( - """ - { - "foo": false - } - """, - """ - { - "properties": { - "foo": { - "${'$'}ref": "#" - } - }, - "additionalProperties": false - } - """, - true, - """root pointer ref -> match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "root pointer ref -> recursive match" - */ - @Test - fun ref_rootPointerRef_recursiveMatch() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - "foo": false - } - } - """, - """ - { - "properties": { - "foo": { - "${'$'}ref": "#" - } - }, - "additionalProperties": false - } - """, - true, - """root pointer ref -> recursive match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "root pointer ref -> mismatch" - */ - @Test - fun ref_rootPointerRef_mismatch() { - - assertKsonEnforcesSchema( - """ - { - "bar": false - } - """, - """ - { - "properties": { - "foo": { - "${'$'}ref": "#" - } - }, - "additionalProperties": false - } - """, - false, - """root pointer ref -> mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "root pointer ref -> recursive mismatch" - */ - @Test - fun ref_rootPointerRef_recursiveMismatch() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - "bar": false - } - } - """, - """ - { - "properties": { - "foo": { - "${'$'}ref": "#" - } - }, - "additionalProperties": false - } - """, - false, - """root pointer ref -> recursive mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "relative pointer ref to object -> match" - */ - @Test - fun ref_relativePointerRefToObject_match() { - - assertKsonEnforcesSchema( - """ - { - "bar": 3 - } - """, - """ - { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "${'$'}ref": "#/properties/foo" - } - } - } - """, - true, - """relative pointer ref to object -> match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "relative pointer ref to object -> mismatch" - */ - @Test - fun ref_relativePointerRefToObject_mismatch() { - - assertKsonEnforcesSchema( - """ - { - "bar": true - } - """, - """ - { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "${'$'}ref": "#/properties/foo" - } - } - } - """, - false, - """relative pointer ref to object -> mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "relative pointer ref to array -> match array" - */ - @Test - fun ref_relativePointerRefToArray_matchArray() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2 - ] - """, - """ - { - "items": [ - { - "type": "integer" - }, - { - "${'$'}ref": "#/items/0" - } - ] - } - """, - true, - """relative pointer ref to array -> match array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "relative pointer ref to array -> mismatch array" - */ - @Test - fun ref_relativePointerRefToArray_mismatchArray() { - - assertKsonEnforcesSchema( - """ - [ - 1, - "foo" - ] - """, - """ - { - "items": [ - { - "type": "integer" - }, - { - "${'$'}ref": "#/items/0" - } - ] - } - """, - false, - """relative pointer ref to array -> mismatch array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "escaped pointer ref -> slash invalid" - */ - @Test - fun ref_escapedPointerRef_slashInvalid() { - - assertKsonEnforcesSchema( - """ - { - "slash": "aoeu" - } - """, - """ - { - "definitions": { - "tilde~field": { - "type": "integer" - }, - "slash/field": { - "type": "integer" - }, - "percent%field": { - "type": "integer" - } - }, - "properties": { - "tilde": { - "${'$'}ref": "#/definitions/tilde~0field" - }, - "slash": { - "${'$'}ref": "#/definitions/slash~1field" - }, - "percent": { - "${'$'}ref": "#/definitions/percent%25field" - } - } - } - """, - false, - """escaped pointer ref -> slash invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "escaped pointer ref -> tilde invalid" - */ - @Test - fun ref_escapedPointerRef_tildeInvalid() { - - assertKsonEnforcesSchema( - """ - { - "tilde": "aoeu" - } - """, - """ - { - "definitions": { - "tilde~field": { - "type": "integer" - }, - "slash/field": { - "type": "integer" - }, - "percent%field": { - "type": "integer" - } - }, - "properties": { - "tilde": { - "${'$'}ref": "#/definitions/tilde~0field" - }, - "slash": { - "${'$'}ref": "#/definitions/slash~1field" - }, - "percent": { - "${'$'}ref": "#/definitions/percent%25field" - } - } - } - """, - false, - """escaped pointer ref -> tilde invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "escaped pointer ref -> percent invalid" - */ - @Test - fun ref_escapedPointerRef_percentInvalid() { - - assertKsonEnforcesSchema( - """ - { - "percent": "aoeu" - } - """, - """ - { - "definitions": { - "tilde~field": { - "type": "integer" - }, - "slash/field": { - "type": "integer" - }, - "percent%field": { - "type": "integer" - } - }, - "properties": { - "tilde": { - "${'$'}ref": "#/definitions/tilde~0field" - }, - "slash": { - "${'$'}ref": "#/definitions/slash~1field" - }, - "percent": { - "${'$'}ref": "#/definitions/percent%25field" - } - } - } - """, - false, - """escaped pointer ref -> percent invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "escaped pointer ref -> slash valid" - */ - @Test - fun ref_escapedPointerRef_slashValid() { - - assertKsonEnforcesSchema( - """ - { - "slash": 123 - } - """, - """ - { - "definitions": { - "tilde~field": { - "type": "integer" - }, - "slash/field": { - "type": "integer" - }, - "percent%field": { - "type": "integer" - } - }, - "properties": { - "tilde": { - "${'$'}ref": "#/definitions/tilde~0field" - }, - "slash": { - "${'$'}ref": "#/definitions/slash~1field" - }, - "percent": { - "${'$'}ref": "#/definitions/percent%25field" - } - } - } - """, - true, - """escaped pointer ref -> slash valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "escaped pointer ref -> tilde valid" - */ - @Test - fun ref_escapedPointerRef_tildeValid() { - - assertKsonEnforcesSchema( - """ - { - "tilde": 123 - } - """, - """ - { - "definitions": { - "tilde~field": { - "type": "integer" - }, - "slash/field": { - "type": "integer" - }, - "percent%field": { - "type": "integer" - } - }, - "properties": { - "tilde": { - "${'$'}ref": "#/definitions/tilde~0field" - }, - "slash": { - "${'$'}ref": "#/definitions/slash~1field" - }, - "percent": { - "${'$'}ref": "#/definitions/percent%25field" - } - } - } - """, - true, - """escaped pointer ref -> tilde valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "escaped pointer ref -> percent valid" - */ - @Test - fun ref_escapedPointerRef_percentValid() { - - assertKsonEnforcesSchema( - """ - { - "percent": 123 - } - """, - """ - { - "definitions": { - "tilde~field": { - "type": "integer" - }, - "slash/field": { - "type": "integer" - }, - "percent%field": { - "type": "integer" - } - }, - "properties": { - "tilde": { - "${'$'}ref": "#/definitions/tilde~0field" - }, - "slash": { - "${'$'}ref": "#/definitions/slash~1field" - }, - "percent": { - "${'$'}ref": "#/definitions/percent%25field" - } - } - } - """, - true, - """escaped pointer ref -> percent valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "nested refs -> nested ref valid" - */ - @Test - fun ref_nestedRefs_nestedRefValid() { - - assertKsonEnforcesSchema( - """ - 5 - """, - """ - { - "definitions": { - "a": { - "type": "integer" - }, - "b": { - "${'$'}ref": "#/definitions/a" - }, - "c": { - "${'$'}ref": "#/definitions/b" - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/c" - } - ] - } - """, - true, - """nested refs -> nested ref valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "nested refs -> nested ref invalid" - */ - @Test - fun ref_nestedRefs_nestedRefInvalid() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "definitions": { - "a": { - "type": "integer" - }, - "b": { - "${'$'}ref": "#/definitions/a" - }, - "c": { - "${'$'}ref": "#/definitions/b" - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/c" - } - ] - } - """, - false, - """nested refs -> nested ref invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref overrides any sibling keywords -> ref valid" - */ - @Test - fun ref_refOverridesAnySiblingKeywords_refValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": [ - ] - } - """, - """ - { - "definitions": { - "reffed": { - "type": "array" - } - }, - "properties": { - "foo": { - "${'$'}ref": "#/definitions/reffed", - "maxItems": 2 - } - } - } - """, - true, - """ref overrides any sibling keywords -> ref valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref overrides any sibling keywords -> ref valid, maxItems ignored" - */ - @Test - fun ref_refOverridesAnySiblingKeywords_refValid_MaxItemsIgnored() { - - assertKsonEnforcesSchema( - """ - { - "foo": [ - 1, - 2, - 3 - ] - } - """, - """ - { - "definitions": { - "reffed": { - "type": "array" - } - }, - "properties": { - "foo": { - "${'$'}ref": "#/definitions/reffed", - "maxItems": 2 - } - } - } - """, - true, - """ref overrides any sibling keywords -> ref valid, maxItems ignored""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref overrides any sibling keywords -> ref invalid" - */ - @Test - fun ref_refOverridesAnySiblingKeywords_refInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "string" - } - """, - """ - { - "definitions": { - "reffed": { - "type": "array" - } - }, - "properties": { - "foo": { - "${'$'}ref": "#/definitions/reffed", - "maxItems": 2 - } - } - } - """, - false, - """ref overrides any sibling keywords -> ref invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$ref prevents a sibling $id from changing the base uri -> $ref resolves to /definitions/base_foo, data does not validate" - */ - @Test - fun ref_______refPreventsASibling______idFromChangingTheBaseUri_______refResolvesTo_definitions_base_foo_DataDoesNotValidate() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}id": "http://localhost:1234/sibling_id/base/", - "definitions": { - "foo": { - "${'$'}id": "http://localhost:1234/sibling_id/foo.json", - "type": "string" - }, - "base_foo": { - "${'$'}comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", - "${'$'}id": "foo.json", - "type": "number" - } - }, - "allOf": [ - { - "${'$'}comment": "${'$'}ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", - "${'$'}id": "http://localhost:1234/sibling_id/", - "${'$'}ref": "foo.json" - } - ] - } - """, - false, - """${'$'}ref prevents a sibling ${'$'}id from changing the base uri -> ${'$'}ref resolves to /definitions/base_foo, data does not validate""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$ref prevents a sibling $id from changing the base uri -> $ref resolves to /definitions/base_foo, data validates" - */ - @Test - fun ref_______refPreventsASibling______idFromChangingTheBaseUri_______refResolvesTo_definitions_base_foo_DataValidates() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}id": "http://localhost:1234/sibling_id/base/", - "definitions": { - "foo": { - "${'$'}id": "http://localhost:1234/sibling_id/foo.json", - "type": "string" - }, - "base_foo": { - "${'$'}comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", - "${'$'}id": "foo.json", - "type": "number" - } - }, - "allOf": [ - { - "${'$'}comment": "${'$'}ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", - "${'$'}id": "http://localhost:1234/sibling_id/", - "${'$'}ref": "foo.json" - } - ] - } - """, - true, - """${'$'}ref prevents a sibling ${'$'}id from changing the base uri -> ${'$'}ref resolves to /definitions/base_foo, data validates""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "remote ref, containing refs itself -> remote ref valid" - */ - @Test - fun ref_remoteRef_ContainingRefsItself_remoteRefValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "ref_remoteRef_ContainingRefsItself_remoteRefValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "minLength": 1 - } - """, - """ - { - "${'$'}ref": "http://json-schema.org/draft-07/schema#" - } - """, - true, - """remote ref, containing refs itself -> remote ref valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "remote ref, containing refs itself -> remote ref invalid" - */ - @Test - fun ref_remoteRef_ContainingRefsItself_remoteRefInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "ref_remoteRef_ContainingRefsItself_remoteRefInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "minLength": -1 - } - """, - """ - { - "${'$'}ref": "http://json-schema.org/draft-07/schema#" - } - """, - false, - """remote ref, containing refs itself -> remote ref invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "property named $ref that is not a reference -> property named $ref valid" - */ - @Test - fun ref_propertyNamed______refThatIsNotAReference_propertyNamed______refValid() { - - assertKsonEnforcesSchema( - """ - { - "${'$'}ref": "a" - } - """, - """ - { - "properties": { - "${'$'}ref": { - "type": "string" - } - } - } - """, - true, - """property named ${'$'}ref that is not a reference -> property named ${'$'}ref valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "property named $ref that is not a reference -> property named $ref invalid" - */ - @Test - fun ref_propertyNamed______refThatIsNotAReference_propertyNamed______refInvalid() { - - assertKsonEnforcesSchema( - """ - { - "${'$'}ref": 2 - } - """, - """ - { - "properties": { - "${'$'}ref": { - "type": "string" - } - } - } - """, - false, - """property named ${'$'}ref that is not a reference -> property named ${'$'}ref invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "property named $ref, containing an actual $ref -> property named $ref valid" - */ - @Test - fun ref_propertyNamed______ref_ContainingAnActual______ref_propertyNamed______refValid() { - - assertKsonEnforcesSchema( - """ - { - "${'$'}ref": "a" - } - """, - """ - { - "properties": { - "${'$'}ref": { - "${'$'}ref": "#/definitions/is-string" - } - }, - "definitions": { - "is-string": { - "type": "string" - } - } - } - """, - true, - """property named ${'$'}ref, containing an actual ${'$'}ref -> property named ${'$'}ref valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "property named $ref, containing an actual $ref -> property named $ref invalid" - */ - @Test - fun ref_propertyNamed______ref_ContainingAnActual______ref_propertyNamed______refInvalid() { - - assertKsonEnforcesSchema( - """ - { - "${'$'}ref": 2 - } - """, - """ - { - "properties": { - "${'$'}ref": { - "${'$'}ref": "#/definitions/is-string" - } - }, - "definitions": { - "is-string": { - "type": "string" - } - } - } - """, - false, - """property named ${'$'}ref, containing an actual ${'$'}ref -> property named ${'$'}ref invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$ref to boolean schema true -> any value is valid" - */ - @Test - fun ref_______refToBooleanSchemaTrue_anyValueIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - { - "${'$'}ref": "#/definitions/bool" - } - ], - "definitions": { - "bool": true - } - } - """, - true, - """${'$'}ref to boolean schema true -> any value is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$ref to boolean schema false -> any value is invalid" - */ - @Test - fun ref_______refToBooleanSchemaFalse_anyValueIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - { - "${'$'}ref": "#/definitions/bool" - } - ], - "definitions": { - "bool": false - } - } - """, - false, - """${'$'}ref to boolean schema false -> any value is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "Recursive references between schemas -> valid tree" - */ - @Test - fun ref_recursiveReferencesBetweenSchemas_validTree() { - - assertKsonEnforcesSchema( - """ - { - "meta": "root", - "nodes": [ - { - "value": 1, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": 1.1 - }, - { - "value": 1.2 - } - ] - } - }, - { - "value": 2, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": 2.1 - }, - { - "value": 2.2 - } - ] - } - } - ] - } - """, - """ - { - "${'$'}id": "http://localhost:1234/tree", - "description": "tree of nodes", - "type": "object", - "properties": { - "meta": { - "type": "string" - }, - "nodes": { - "type": "array", - "items": { - "${'$'}ref": "node" - } - } - }, - "required": [ - "meta", - "nodes" - ], - "definitions": { - "node": { - "${'$'}id": "http://localhost:1234/node", - "description": "node", - "type": "object", - "properties": { - "value": { - "type": "number" - }, - "subtree": { - "${'$'}ref": "tree" - } - }, - "required": [ - "value" - ] - } - } - } - """, - true, - """Recursive references between schemas -> valid tree""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "Recursive references between schemas -> invalid tree" - */ - @Test - fun ref_recursiveReferencesBetweenSchemas_invalidTree() { - - assertKsonEnforcesSchema( - """ - { - "meta": "root", - "nodes": [ - { - "value": 1, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": "string is invalid" - }, - { - "value": 1.2 - } - ] - } - }, - { - "value": 2, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": 2.1 - }, - { - "value": 2.2 - } - ] - } - } - ] - } - """, - """ - { - "${'$'}id": "http://localhost:1234/tree", - "description": "tree of nodes", - "type": "object", - "properties": { - "meta": { - "type": "string" - }, - "nodes": { - "type": "array", - "items": { - "${'$'}ref": "node" - } - } - }, - "required": [ - "meta", - "nodes" - ], - "definitions": { - "node": { - "${'$'}id": "http://localhost:1234/node", - "description": "node", - "type": "object", - "properties": { - "value": { - "type": "number" - }, - "subtree": { - "${'$'}ref": "tree" - } - }, - "required": [ - "value" - ] - } - } - } - """, - false, - """Recursive references between schemas -> invalid tree""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "refs with quote -> object with numbers is valid" - */ - @Test - fun ref_refsWithQuote_objectWithNumbersIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo\"bar": 1 - } - """, - """ - { - "properties": { - "foo\"bar": { - "${'$'}ref": "#/definitions/foo%22bar" - } - }, - "definitions": { - "foo\"bar": { - "type": "number" - } - } - } - """, - true, - """refs with quote -> object with numbers is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "refs with quote -> object with strings is invalid" - */ - @Test - fun ref_refsWithQuote_objectWithStringsIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo\"bar": "1" - } - """, - """ - { - "properties": { - "foo\"bar": { - "${'$'}ref": "#/definitions/foo%22bar" - } - }, - "definitions": { - "foo\"bar": { - "type": "number" - } - } - } - """, - false, - """refs with quote -> object with strings is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "Location-independent identifier -> match" - */ - @Test - fun ref_location_independentIdentifier_match() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "allOf": [ - { - "${'$'}ref": "#foo" - } - ], - "definitions": { - "A": { - "${'$'}id": "#foo", - "type": "integer" - } - } - } - """, - true, - """Location-independent identifier -> match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "Location-independent identifier -> mismatch" - */ - @Test - fun ref_location_independentIdentifier_mismatch() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "allOf": [ - { - "${'$'}ref": "#foo" - } - ], - "definitions": { - "A": { - "${'$'}id": "#foo", - "type": "integer" - } - } - } - """, - false, - """Location-independent identifier -> mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "Reference an anchor with a non-relative URI -> match" - */ - @Test - fun ref_referenceAnAnchorWithANon_relativeURI_match() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}id": "https://example.com/schema-with-anchor", - "allOf": [ - { - "${'$'}ref": "https://example.com/schema-with-anchor#foo" - } - ], - "definitions": { - "A": { - "${'$'}id": "#foo", - "type": "integer" - } - } - } - """, - true, - """Reference an anchor with a non-relative URI -> match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "Reference an anchor with a non-relative URI -> mismatch" - */ - @Test - fun ref_referenceAnAnchorWithANon_relativeURI_mismatch() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}id": "https://example.com/schema-with-anchor", - "allOf": [ - { - "${'$'}ref": "https://example.com/schema-with-anchor#foo" - } - ], - "definitions": { - "A": { - "${'$'}id": "#foo", - "type": "integer" - } - } - } - """, - false, - """Reference an anchor with a non-relative URI -> mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "Location-independent identifier with base URI change in subschema -> match" - */ - @Test - fun ref_location_independentIdentifierWithBaseURIChangeInSubschema_match() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}id": "http://localhost:1234/root", - "allOf": [ - { - "${'$'}ref": "http://localhost:1234/nested.json#foo" - } - ], - "definitions": { - "A": { - "${'$'}id": "nested.json", - "definitions": { - "B": { - "${'$'}id": "#foo", - "type": "integer" - } - } - } - } - } - """, - true, - """Location-independent identifier with base URI change in subschema -> match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "Location-independent identifier with base URI change in subschema -> mismatch" - */ - @Test - fun ref_location_independentIdentifierWithBaseURIChangeInSubschema_mismatch() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}id": "http://localhost:1234/root", - "allOf": [ - { - "${'$'}ref": "http://localhost:1234/nested.json#foo" - } - ], - "definitions": { - "A": { - "${'$'}id": "nested.json", - "definitions": { - "B": { - "${'$'}id": "#foo", - "type": "integer" - } - } - } - } - } - """, - false, - """Location-independent identifier with base URI change in subschema -> mismatch""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "naive replacement of $ref with its destination is not correct -> do not evaluate the $ref inside the enum, matching any string" - */ - @Test - fun ref_naiveReplacementOf______refWithItsDestinationIsNotCorrect_doNotEvaluateThe______refInsideTheEnum_MatchingAnyString() { - - assertKsonEnforcesSchema( - """ - "this is a string" - """, - """ - { - "definitions": { - "a_string": { - "type": "string" - } - }, - "enum": [ - { - "${'$'}ref": "#/definitions/a_string" - } - ] - } - """, - false, - """naive replacement of ${'$'}ref with its destination is not correct -> do not evaluate the ${'$'}ref inside the enum, matching any string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "naive replacement of $ref with its destination is not correct -> do not evaluate the $ref inside the enum, definition exact match" - */ - @Test - fun ref_naiveReplacementOf______refWithItsDestinationIsNotCorrect_doNotEvaluateThe______refInsideTheEnum_DefinitionExactMatch() { - - assertKsonEnforcesSchema( - """ - { - "type": "string" - } - """, - """ - { - "definitions": { - "a_string": { - "type": "string" - } - }, - "enum": [ - { - "${'$'}ref": "#/definitions/a_string" - } - ] - } - """, - false, - """naive replacement of ${'$'}ref with its destination is not correct -> do not evaluate the ${'$'}ref inside the enum, definition exact match""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "naive replacement of $ref with its destination is not correct -> match the enum exactly" - */ - @Test - fun ref_naiveReplacementOf______refWithItsDestinationIsNotCorrect_matchTheEnumExactly() { - - assertKsonEnforcesSchema( - """ - { - "${'$'}ref": "#/definitions/a_string" - } - """, - """ - { - "definitions": { - "a_string": { - "type": "string" - } - }, - "enum": [ - { - "${'$'}ref": "#/definitions/a_string" - } - ] - } - """, - true, - """naive replacement of ${'$'}ref with its destination is not correct -> match the enum exactly""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "refs with relative uris and defs -> invalid on inner field" - */ - @Test - fun ref_refsWithRelativeUrisAndDefs_invalidOnInnerField() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - "bar": 1 - }, - "bar": "a" - } - """, - """ - { - "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", - "properties": { - "foo": { - "${'$'}id": "schema-relative-uri-defs2.json", - "definitions": { - "inner": { - "properties": { - "bar": { - "type": "string" - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/inner" - } - ] - } - }, - "allOf": [ - { - "${'$'}ref": "schema-relative-uri-defs2.json" - } - ] - } - """, - false, - """refs with relative uris and defs -> invalid on inner field""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "refs with relative uris and defs -> invalid on outer field" - */ - @Test - fun ref_refsWithRelativeUrisAndDefs_invalidOnOuterField() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - "bar": "a" - }, - "bar": 1 - } - """, - """ - { - "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", - "properties": { - "foo": { - "${'$'}id": "schema-relative-uri-defs2.json", - "definitions": { - "inner": { - "properties": { - "bar": { - "type": "string" - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/inner" - } - ] - } - }, - "allOf": [ - { - "${'$'}ref": "schema-relative-uri-defs2.json" - } - ] - } - """, - false, - """refs with relative uris and defs -> invalid on outer field""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "refs with relative uris and defs -> valid on both fields" - */ - @Test - fun ref_refsWithRelativeUrisAndDefs_validOnBothFields() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - "bar": "a" - }, - "bar": "a" - } - """, - """ - { - "${'$'}id": "http://example.com/schema-relative-uri-defs1.json", - "properties": { - "foo": { - "${'$'}id": "schema-relative-uri-defs2.json", - "definitions": { - "inner": { - "properties": { - "bar": { - "type": "string" - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/inner" - } - ] - } - }, - "allOf": [ - { - "${'$'}ref": "schema-relative-uri-defs2.json" - } - ] - } - """, - true, - """refs with relative uris and defs -> valid on both fields""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "relative refs with absolute uris and defs -> invalid on inner field" - */ - @Test - fun ref_relativeRefsWithAbsoluteUrisAndDefs_invalidOnInnerField() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - "bar": 1 - }, - "bar": "a" - } - """, - """ - { - "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", - "properties": { - "foo": { - "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", - "definitions": { - "inner": { - "properties": { - "bar": { - "type": "string" - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/inner" - } - ] - } - }, - "allOf": [ - { - "${'$'}ref": "schema-refs-absolute-uris-defs2.json" - } - ] - } - """, - false, - """relative refs with absolute uris and defs -> invalid on inner field""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "relative refs with absolute uris and defs -> invalid on outer field" - */ - @Test - fun ref_relativeRefsWithAbsoluteUrisAndDefs_invalidOnOuterField() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - "bar": "a" - }, - "bar": 1 - } - """, - """ - { - "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", - "properties": { - "foo": { - "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", - "definitions": { - "inner": { - "properties": { - "bar": { - "type": "string" - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/inner" - } - ] - } - }, - "allOf": [ - { - "${'$'}ref": "schema-refs-absolute-uris-defs2.json" - } - ] - } - """, - false, - """relative refs with absolute uris and defs -> invalid on outer field""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "relative refs with absolute uris and defs -> valid on both fields" - */ - @Test - fun ref_relativeRefsWithAbsoluteUrisAndDefs_validOnBothFields() { - - assertKsonEnforcesSchema( - """ - { - "foo": { - "bar": "a" - }, - "bar": "a" - } - """, - """ - { - "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs1.json", - "properties": { - "foo": { - "${'$'}id": "http://example.com/schema-refs-absolute-uris-defs2.json", - "definitions": { - "inner": { - "properties": { - "bar": { - "type": "string" - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/inner" - } - ] - } - }, - "allOf": [ - { - "${'$'}ref": "schema-refs-absolute-uris-defs2.json" - } - ] - } - """, - true, - """relative refs with absolute uris and defs -> valid on both fields""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$id must be resolved against nearest parent, not just immediate parent -> number is valid" - */ - @Test - fun ref_______idMustBeResolvedAgainstNearestParent_NotJustImmediateParent_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}id": "http://example.com/a.json", - "definitions": { - "x": { - "${'$'}id": "http://example.com/b/c.json", - "not": { - "definitions": { - "y": { - "${'$'}id": "d.json", - "type": "number" - } - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "http://example.com/b/d.json" - } - ] - } - """, - true, - """${'$'}id must be resolved against nearest parent, not just immediate parent -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$id must be resolved against nearest parent, not just immediate parent -> non-number is invalid" - */ - @Test - fun ref_______idMustBeResolvedAgainstNearestParent_NotJustImmediateParent_non_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}id": "http://example.com/a.json", - "definitions": { - "x": { - "${'$'}id": "http://example.com/b/c.json", - "not": { - "definitions": { - "y": { - "${'$'}id": "d.json", - "type": "number" - } - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "http://example.com/b/d.json" - } - ] - } - """, - false, - """${'$'}id must be resolved against nearest parent, not just immediate parent -> non-number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "simple URN base URI with $ref via the URN -> valid under the URN IDed schema" - */ - @Test - fun ref_simpleURNBaseURIWith______refViaTheURN_validUnderTheURNIDedSchema() { - - assertKsonEnforcesSchema( - """ - { - "foo": 37 - } - """, - """ - { - "${'$'}comment": "URIs do not have to have HTTP(s) schemes", - "${'$'}id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed", - "minimum": 30, - "properties": { - "foo": { - "${'$'}ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed" - } - } - } - """, - true, - """simple URN base URI with ${'$'}ref via the URN -> valid under the URN IDed schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "simple URN base URI with $ref via the URN -> invalid under the URN IDed schema" - */ - @Test - fun ref_simpleURNBaseURIWith______refViaTheURN_invalidUnderTheURNIDedSchema() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12 - } - """, - """ - { - "${'$'}comment": "URIs do not have to have HTTP(s) schemes", - "${'$'}id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed", - "minimum": 30, - "properties": { - "foo": { - "${'$'}ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed" - } - } - } - """, - false, - """simple URN base URI with ${'$'}ref via the URN -> invalid under the URN IDed schema""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "simple URN base URI with JSON pointer -> a string is valid" - */ - @Test - fun ref_simpleURNBaseURIWithJSONPointer_aStringIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "${'$'}comment": "URIs do not have to have HTTP(s) schemes", - "${'$'}id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed", - "properties": { - "foo": { - "${'$'}ref": "#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - true, - """simple URN base URI with JSON pointer -> a string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "simple URN base URI with JSON pointer -> a non-string is invalid" - */ - @Test - fun ref_simpleURNBaseURIWithJSONPointer_aNon_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12 - } - """, - """ - { - "${'$'}comment": "URIs do not have to have HTTP(s) schemes", - "${'$'}id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed", - "properties": { - "foo": { - "${'$'}ref": "#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - false, - """simple URN base URI with JSON pointer -> a non-string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with NSS -> a string is valid" - */ - @Test - fun ref_uRNBaseURIWithNSS_aStringIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "${'$'}comment": "RFC 8141 §2.2", - "${'$'}id": "urn:example:1/406/47452/2", - "properties": { - "foo": { - "${'$'}ref": "#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - true, - """URN base URI with NSS -> a string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with NSS -> a non-string is invalid" - */ - @Test - fun ref_uRNBaseURIWithNSS_aNon_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12 - } - """, - """ - { - "${'$'}comment": "RFC 8141 §2.2", - "${'$'}id": "urn:example:1/406/47452/2", - "properties": { - "foo": { - "${'$'}ref": "#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - false, - """URN base URI with NSS -> a non-string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with r-component -> a string is valid" - */ - @Test - fun ref_uRNBaseURIWithR_component_aStringIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "${'$'}comment": "RFC 8141 §2.3.1", - "${'$'}id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk", - "properties": { - "foo": { - "${'$'}ref": "#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - true, - """URN base URI with r-component -> a string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with r-component -> a non-string is invalid" - */ - @Test - fun ref_uRNBaseURIWithR_component_aNon_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12 - } - """, - """ - { - "${'$'}comment": "RFC 8141 §2.3.1", - "${'$'}id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk", - "properties": { - "foo": { - "${'$'}ref": "#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - false, - """URN base URI with r-component -> a non-string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with q-component -> a string is valid" - */ - @Test - fun ref_uRNBaseURIWithQ_component_aStringIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "${'$'}comment": "RFC 8141 §2.3.2", - "${'$'}id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z", - "properties": { - "foo": { - "${'$'}ref": "#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - true, - """URN base URI with q-component -> a string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with q-component -> a non-string is invalid" - */ - @Test - fun ref_uRNBaseURIWithQ_component_aNon_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12 - } - """, - """ - { - "${'$'}comment": "RFC 8141 §2.3.2", - "${'$'}id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z", - "properties": { - "foo": { - "${'$'}ref": "#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - false, - """URN base URI with q-component -> a non-string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with URN and JSON pointer ref -> a string is valid" - */ - @Test - fun ref_uRNBaseURIWithURNAndJSONPointerRef_aStringIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "${'$'}id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed", - "properties": { - "foo": { - "${'$'}ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - true, - """URN base URI with URN and JSON pointer ref -> a string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with URN and JSON pointer ref -> a non-string is invalid" - */ - @Test - fun ref_uRNBaseURIWithURNAndJSONPointerRef_aNon_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12 - } - """, - """ - { - "${'$'}id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed", - "properties": { - "foo": { - "${'$'}ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/definitions/bar" - } - }, - "definitions": { - "bar": { - "type": "string" - } - } - } - """, - false, - """URN base URI with URN and JSON pointer ref -> a non-string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with URN and anchor ref -> a string is valid" - */ - @Test - fun ref_uRNBaseURIWithURNAndAnchorRef_aStringIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": "bar" - } - """, - """ - { - "${'$'}id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed", - "properties": { - "foo": { - "${'$'}ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something" - } - }, - "definitions": { - "bar": { - "${'$'}id": "#something", - "type": "string" - } - } - } - """, - true, - """URN base URI with URN and anchor ref -> a string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "URN base URI with URN and anchor ref -> a non-string is invalid" - */ - @Test - fun ref_uRNBaseURIWithURNAndAnchorRef_aNon_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 12 - } - """, - """ - { - "${'$'}id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed", - "properties": { - "foo": { - "${'$'}ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something" - } - }, - "definitions": { - "bar": { - "${'$'}id": "#something", - "type": "string" - } - } - } - """, - false, - """URN base URI with URN and anchor ref -> a non-string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref to if -> a non-integer is invalid due to the $ref" - */ - @Test - fun ref_refToIf_aNon_integerIsInvalidDueToThe______ref() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - { - "${'$'}ref": "http://example.com/ref/if" - }, - { - "if": { - "${'$'}id": "http://example.com/ref/if", - "type": "integer" - } - } - ] - } - """, - false, - """ref to if -> a non-integer is invalid due to the ${'$'}ref""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref to if -> an integer is valid" - */ - @Test - fun ref_refToIf_anIntegerIsValid() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "allOf": [ - { - "${'$'}ref": "http://example.com/ref/if" - }, - { - "if": { - "${'$'}id": "http://example.com/ref/if", - "type": "integer" - } - } - ] - } - """, - true, - """ref to if -> an integer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref to then -> a non-integer is invalid due to the $ref" - */ - @Test - fun ref_refToThen_aNon_integerIsInvalidDueToThe______ref() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - { - "${'$'}ref": "http://example.com/ref/then" - }, - { - "then": { - "${'$'}id": "http://example.com/ref/then", - "type": "integer" - } - } - ] - } - """, - false, - """ref to then -> a non-integer is invalid due to the ${'$'}ref""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref to then -> an integer is valid" - */ - @Test - fun ref_refToThen_anIntegerIsValid() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "allOf": [ - { - "${'$'}ref": "http://example.com/ref/then" - }, - { - "then": { - "${'$'}id": "http://example.com/ref/then", - "type": "integer" - } - } - ] - } - """, - true, - """ref to then -> an integer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref to else -> a non-integer is invalid due to the $ref" - */ - @Test - fun ref_refToElse_aNon_integerIsInvalidDueToThe______ref() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "allOf": [ - { - "${'$'}ref": "http://example.com/ref/else" - }, - { - "else": { - "${'$'}id": "http://example.com/ref/else", - "type": "integer" - } - } - ] - } - """, - false, - """ref to else -> a non-integer is invalid due to the ${'$'}ref""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref to else -> an integer is valid" - */ - @Test - fun ref_refToElse_anIntegerIsValid() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "allOf": [ - { - "${'$'}ref": "http://example.com/ref/else" - }, - { - "else": { - "${'$'}id": "http://example.com/ref/else", - "type": "integer" - } - } - ] - } - """, - true, - """ref to else -> an integer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref with absolute-path-reference -> a string is valid" - */ - @Test - fun ref_refWithAbsolute_path_reference_aStringIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "${'$'}id": "http://example.com/ref/absref.json", - "definitions": { - "a": { - "${'$'}id": "http://example.com/ref/absref/foobar.json", - "type": "number" - }, - "b": { - "${'$'}id": "http://example.com/absref/foobar.json", - "type": "string" - } - }, - "allOf": [ - { - "${'$'}ref": "/absref/foobar.json" - } - ] - } - """, - true, - """ref with absolute-path-reference -> a string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "ref with absolute-path-reference -> an integer is invalid" - */ - @Test - fun ref_refWithAbsolute_path_reference_anIntegerIsInvalid() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "${'$'}id": "http://example.com/ref/absref.json", - "definitions": { - "a": { - "${'$'}id": "http://example.com/ref/absref/foobar.json", - "type": "number" - }, - "b": { - "${'$'}id": "http://example.com/absref/foobar.json", - "type": "string" - } - }, - "allOf": [ - { - "${'$'}ref": "/absref/foobar.json" - } - ] - } - """, - false, - """ref with absolute-path-reference -> an integer is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$id with file URI still resolves pointers - *nix -> number is valid" - */ - @Test - fun ref_______idWithFileURIStillResolvesPointers__nix_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}id": "file:///folder/file.json", - "definitions": { - "foo": { - "type": "number" - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/foo" - } - ] - } - """, - true, - """${'$'}id with file URI still resolves pointers - *nix -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$id with file URI still resolves pointers - *nix -> non-number is invalid" - */ - @Test - fun ref_______idWithFileURIStillResolvesPointers__nix_non_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}id": "file:///folder/file.json", - "definitions": { - "foo": { - "type": "number" - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/foo" - } - ] - } - """, - false, - """${'$'}id with file URI still resolves pointers - *nix -> non-number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$id with file URI still resolves pointers - windows -> number is valid" - */ - @Test - fun ref_______idWithFileURIStillResolvesPointers_Windows_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}id": "file:///c:/folder/file.json", - "definitions": { - "foo": { - "type": "number" - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/foo" - } - ] - } - """, - true, - """${'$'}id with file URI still resolves pointers - windows -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "$id with file URI still resolves pointers - windows -> non-number is invalid" - */ - @Test - fun ref_______idWithFileURIStillResolvesPointers_Windows_non_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}id": "file:///c:/folder/file.json", - "definitions": { - "foo": { - "type": "number" - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions/foo" - } - ] - } - """, - false, - """${'$'}id with file URI still resolves pointers - windows -> non-number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "empty tokens in $ref json-pointer -> number is valid" - */ - @Test - fun ref_emptyTokensIn______refJson_pointer_numberIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "definitions": { - "": { - "definitions": { - "": { - "type": "number" - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions//definitions/" - } - ] - } - """, - true, - """empty tokens in ${'$'}ref json-pointer -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/ref.json`: - * "empty tokens in $ref json-pointer -> non-number is invalid" - */ - @Test - fun ref_emptyTokensIn______refJson_pointer_non_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "definitions": { - "": { - "definitions": { - "": { - "type": "number" - } - } - } - }, - "allOf": [ - { - "${'$'}ref": "#/definitions//definitions/" - } - ] - } - """, - false, - """empty tokens in ${'$'}ref json-pointer -> non-number is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "remote ref -> remote ref valid" - */ - @Test - fun refRemote_remoteRef_remoteRefValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_remoteRef_remoteRefValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}ref": "http://localhost:1234/integer.json" - } - """, - true, - """remote ref -> remote ref valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "remote ref -> remote ref invalid" - */ - @Test - fun refRemote_remoteRef_remoteRefInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_remoteRef_remoteRefInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}ref": "http://localhost:1234/integer.json" - } - """, - false, - """remote ref -> remote ref invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "fragment within remote ref -> remote fragment valid" - */ - @Test - fun refRemote_fragmentWithinRemoteRef_remoteFragmentValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_fragmentWithinRemoteRef_remoteFragmentValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}ref": "http://localhost:1234/subSchemas.json#/definitions/integer" - } - """, - true, - """fragment within remote ref -> remote fragment valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "fragment within remote ref -> remote fragment invalid" - */ - @Test - fun refRemote_fragmentWithinRemoteRef_remoteFragmentInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_fragmentWithinRemoteRef_remoteFragmentInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}ref": "http://localhost:1234/subSchemas.json#/definitions/integer" - } - """, - false, - """fragment within remote ref -> remote fragment invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "ref within remote ref -> ref within ref valid" - */ - @Test - fun refRemote_refWithinRemoteRef_refWithinRefValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_refWithinRemoteRef_refWithinRefValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}ref": "http://localhost:1234/subSchemas.json#/definitions/refToInteger" - } - """, - true, - """ref within remote ref -> ref within ref valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "ref within remote ref -> ref within ref invalid" - */ - @Test - fun refRemote_refWithinRemoteRef_refWithinRefInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_refWithinRemoteRef_refWithinRefInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}ref": "http://localhost:1234/subSchemas.json#/definitions/refToInteger" - } - """, - false, - """ref within remote ref -> ref within ref invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "base URI change -> base URI change ref valid" - */ - @Test - fun refRemote_baseURIChange_baseURIChangeRefValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_baseURIChange_baseURIChangeRefValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - [ - [ - 1 - ] - ] - """, - """ - { - "${'$'}id": "http://localhost:1234/", - "items": { - "${'$'}id": "baseUriChange/", - "items": { - "${'$'}ref": "folderInteger.json" - } - } - } - """, - true, - """base URI change -> base URI change ref valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "base URI change -> base URI change ref invalid" - */ - @Test - fun refRemote_baseURIChange_baseURIChangeRefInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_baseURIChange_baseURIChangeRefInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - [ - [ - "a" - ] - ] - """, - """ - { - "${'$'}id": "http://localhost:1234/", - "items": { - "${'$'}id": "baseUriChange/", - "items": { - "${'$'}ref": "folderInteger.json" - } - } - } - """, - false, - """base URI change -> base URI change ref invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "base URI change - change folder -> number is valid" - */ - @Test - fun refRemote_baseURIChange_ChangeFolder_numberIsValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_baseURIChange_ChangeFolder_numberIsValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "list": [ - 1 - ] - } - """, - """ - { - "${'$'}id": "http://localhost:1234/scope_change_defs1.json", - "type": "object", - "properties": { - "list": { - "${'$'}ref": "#/definitions/baz" - } - }, - "definitions": { - "baz": { - "${'$'}id": "baseUriChangeFolder/", - "type": "array", - "items": { - "${'$'}ref": "folderInteger.json" - } - } - } - } - """, - true, - """base URI change - change folder -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "base URI change - change folder -> string is invalid" - */ - @Test - fun refRemote_baseURIChange_ChangeFolder_stringIsInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_baseURIChange_ChangeFolder_stringIsInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "list": [ - "a" - ] - } - """, - """ - { - "${'$'}id": "http://localhost:1234/scope_change_defs1.json", - "type": "object", - "properties": { - "list": { - "${'$'}ref": "#/definitions/baz" - } - }, - "definitions": { - "baz": { - "${'$'}id": "baseUriChangeFolder/", - "type": "array", - "items": { - "${'$'}ref": "folderInteger.json" - } - } - } - } - """, - false, - """base URI change - change folder -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "base URI change - change folder in subschema -> number is valid" - */ - @Test - fun refRemote_baseURIChange_ChangeFolderInSubschema_numberIsValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_baseURIChange_ChangeFolderInSubschema_numberIsValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "list": [ - 1 - ] - } - """, - """ - { - "${'$'}id": "http://localhost:1234/scope_change_defs2.json", - "type": "object", - "properties": { - "list": { - "${'$'}ref": "#/definitions/baz/definitions/bar" - } - }, - "definitions": { - "baz": { - "${'$'}id": "baseUriChangeFolderInSubschema/", - "definitions": { - "bar": { - "type": "array", - "items": { - "${'$'}ref": "folderInteger.json" - } - } - } - } - } - } - """, - true, - """base URI change - change folder in subschema -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "base URI change - change folder in subschema -> string is invalid" - */ - @Test - fun refRemote_baseURIChange_ChangeFolderInSubschema_stringIsInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_baseURIChange_ChangeFolderInSubschema_stringIsInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "list": [ - "a" - ] - } - """, - """ - { - "${'$'}id": "http://localhost:1234/scope_change_defs2.json", - "type": "object", - "properties": { - "list": { - "${'$'}ref": "#/definitions/baz/definitions/bar" - } - }, - "definitions": { - "baz": { - "${'$'}id": "baseUriChangeFolderInSubschema/", - "definitions": { - "bar": { - "type": "array", - "items": { - "${'$'}ref": "folderInteger.json" - } - } - } - } - } - } - """, - false, - """base URI change - change folder in subschema -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "root ref in remote ref -> string is valid" - */ - @Test - fun refRemote_rootRefInRemoteRef_stringIsValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_rootRefInRemoteRef_stringIsValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "name": "foo" - } - """, - """ - { - "${'$'}id": "http://localhost:1234/object", - "type": "object", - "properties": { - "name": { - "${'$'}ref": "name.json#/definitions/orNull" - } - } - } - """, - true, - """root ref in remote ref -> string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "root ref in remote ref -> null is valid" - */ - @Test - fun refRemote_rootRefInRemoteRef_nullIsValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_rootRefInRemoteRef_nullIsValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "name": null - } - """, - """ - { - "${'$'}id": "http://localhost:1234/object", - "type": "object", - "properties": { - "name": { - "${'$'}ref": "name.json#/definitions/orNull" - } - } - } - """, - true, - """root ref in remote ref -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "root ref in remote ref -> object is invalid" - */ - @Test - fun refRemote_rootRefInRemoteRef_objectIsInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_rootRefInRemoteRef_objectIsInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "name": { - "name": null - } - } - """, - """ - { - "${'$'}id": "http://localhost:1234/object", - "type": "object", - "properties": { - "name": { - "${'$'}ref": "name.json#/definitions/orNull" - } - } - } - """, - false, - """root ref in remote ref -> object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "remote ref with ref to definitions -> invalid" - */ - @Test - fun refRemote_remoteRefWithRefToDefinitions_invalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_remoteRefWithRefToDefinitions_invalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "bar": 1 - } - """, - """ - { - "${'$'}id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", - "allOf": [ - { - "${'$'}ref": "ref-and-definitions.json" - } - ] - } - """, - false, - """remote ref with ref to definitions -> invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "remote ref with ref to definitions -> valid" - */ - @Test - fun refRemote_remoteRefWithRefToDefinitions_valid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_remoteRefWithRefToDefinitions_valid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "bar": "a" - } - """, - """ - { - "${'$'}id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", - "allOf": [ - { - "${'$'}ref": "ref-and-definitions.json" - } - ] - } - """, - true, - """remote ref with ref to definitions -> valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "Location-independent identifier in remote ref -> integer is valid" - */ - @Test - fun refRemote_location_independentIdentifierInRemoteRef_integerIsValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_location_independentIdentifierInRemoteRef_integerIsValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}ref": "http://localhost:1234/locationIndependentIdentifierPre2019.json#/definitions/refToInteger" - } - """, - true, - """Location-independent identifier in remote ref -> integer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "Location-independent identifier in remote ref -> string is invalid" - */ - @Test - fun refRemote_location_independentIdentifierInRemoteRef_stringIsInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_location_independentIdentifierInRemoteRef_stringIsInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "${'$'}ref": "http://localhost:1234/locationIndependentIdentifierPre2019.json#/definitions/refToInteger" - } - """, - false, - """Location-independent identifier in remote ref -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "retrieved nested refs resolve relative to their URI not $id -> number is invalid" - */ - @Test - fun refRemote_retrievedNestedRefsResolveRelativeToTheirURINot______id_numberIsInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_retrievedNestedRefsResolveRelativeToTheirURINot______id_numberIsInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "name": { - "foo": 1 - } - } - """, - """ - { - "${'$'}id": "http://localhost:1234/some-id", - "properties": { - "name": { - "${'$'}ref": "nested/foo-ref-string.json" - } - } - } - """, - false, - """retrieved nested refs resolve relative to their URI not ${'$'}id -> number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "retrieved nested refs resolve relative to their URI not $id -> string is valid" - */ - @Test - fun refRemote_retrievedNestedRefsResolveRelativeToTheirURINot______id_stringIsValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_retrievedNestedRefsResolveRelativeToTheirURINot______id_stringIsValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - { - "name": { - "foo": "a" - } - } - """, - """ - { - "${'$'}id": "http://localhost:1234/some-id", - "properties": { - "name": { - "${'$'}ref": "nested/foo-ref-string.json" - } - } - } - """, - true, - """retrieved nested refs resolve relative to their URI not ${'$'}id -> string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "$ref to $ref finds location-independent $id -> number is valid" - */ - @Test - fun refRemote_______refTo______refFindsLocation_independent______id_numberIsValid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_______refTo______refFindsLocation_independent______id_numberIsValid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "${'$'}ref": "http://localhost:1234/draft7/detached-ref.json#/definitions/foo" - } - """, - true, - """${'$'}ref to ${'$'}ref finds location-independent ${'$'}id -> number is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/refRemote.json`: - * "$ref to $ref finds location-independent $id -> non-number is invalid" - */ - @Test - fun refRemote_______refTo______refFindsLocation_independent______id_non_numberIsInvalid() { - /** - * TODO implement the schema functionality under test here and remove this exclusion from - * "refRemote_______refTo______refFindsLocation_independent______id_non_numberIsInvalid" from - * [org.kson.jsonsuite.schemaTestSuiteExclusions] - */ - return - - assertKsonEnforcesSchema( - """ - "a" - """, - """ - { - "${'$'}ref": "http://localhost:1234/draft7/detached-ref.json#/definitions/foo" - } - """, - false, - """${'$'}ref to ${'$'}ref finds location-independent ${'$'}id -> non-number is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required validation -> present required property is valid" - */ - @Test - fun required_requiredValidation_presentRequiredPropertyIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 1 - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "required": [ - "foo" - ] - } - """, - true, - """required validation -> present required property is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required validation -> non-present required property is invalid" - */ - @Test - fun required_requiredValidation_non_presentRequiredPropertyIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "bar": 1 - } - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "required": [ - "foo" - ] - } - """, - false, - """required validation -> non-present required property is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required validation -> ignores arrays" - */ - @Test - fun required_requiredValidation_ignoresArrays() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "required": [ - "foo" - ] - } - """, - true, - """required validation -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required validation -> ignores strings" - */ - @Test - fun required_requiredValidation_ignoresStrings() { - - assertKsonEnforcesSchema( - """ - "" - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "required": [ - "foo" - ] - } - """, - true, - """required validation -> ignores strings""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required validation -> ignores other non-objects" - */ - @Test - fun required_requiredValidation_ignoresOtherNon_objects() { - - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "properties": { - "foo": { - }, - "bar": { - } - }, - "required": [ - "foo" - ] - } - """, - true, - """required validation -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required default validation -> not required by default" - */ - @Test - fun required_requiredDefaultValidation_notRequiredByDefault() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "properties": { - "foo": { - } - } - } - """, - true, - """required default validation -> not required by default""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required with empty array -> property not required" - */ - @Test - fun required_requiredWithEmptyArray_propertyNotRequired() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "properties": { - "foo": { - } - }, - "required": [ - ] - } - """, - true, - """required with empty array -> property not required""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required with escaped characters -> object with all properties present is valid" - */ - @Test - fun required_requiredWithEscapedCharacters_objectWithAllPropertiesPresentIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo\nbar": 1, - "foo\"bar": 1, - "foo\\bar": 1, - "foo\rbar": 1, - "foo\tbar": 1, - "foo\fbar": 1 - } - """, - """ - { - "required": [ - "foo\nbar", - "foo\"bar", - "foo\\bar", - "foo\rbar", - "foo\tbar", - "foo\fbar" - ] - } - """, - true, - """required with escaped characters -> object with all properties present is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required with escaped characters -> object with some properties missing is invalid" - */ - @Test - fun required_requiredWithEscapedCharacters_objectWithSomePropertiesMissingIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - "foo\nbar": "1", - "foo\"bar": "1" - } - """, - """ - { - "required": [ - "foo\nbar", - "foo\"bar", - "foo\\bar", - "foo\rbar", - "foo\tbar", - "foo\fbar" - ] - } - """, - false, - """required with escaped characters -> object with some properties missing is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required properties whose names are Javascript object property names -> ignores arrays" - */ - @Test - fun required_requiredPropertiesWhoseNamesAreJavascriptObjectPropertyNames_ignoresArrays() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "required": [ - "__proto__", - "toString", - "constructor" - ] - } - """, - true, - """required properties whose names are Javascript object property names -> ignores arrays""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required properties whose names are Javascript object property names -> ignores other non-objects" - */ - @Test - fun required_requiredPropertiesWhoseNamesAreJavascriptObjectPropertyNames_ignoresOtherNon_objects() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - 12 - """, - """ - { - "required": [ - "__proto__", - "toString", - "constructor" - ] - } - """, - true, - """required properties whose names are Javascript object property names -> ignores other non-objects""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required properties whose names are Javascript object property names -> none of the properties mentioned" - */ - @Test - fun required_requiredPropertiesWhoseNamesAreJavascriptObjectPropertyNames_noneOfThePropertiesMentioned() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "required": [ - "__proto__", - "toString", - "constructor" - ] - } - """, - false, - """required properties whose names are Javascript object property names -> none of the properties mentioned""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required properties whose names are Javascript object property names -> __proto__ present" - */ - @Test - fun required_requiredPropertiesWhoseNamesAreJavascriptObjectPropertyNames___proto__Present() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - "__proto__": "foo" - } - """, - """ - { - "required": [ - "__proto__", - "toString", - "constructor" - ] - } - """, - false, - """required properties whose names are Javascript object property names -> __proto__ present""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required properties whose names are Javascript object property names -> toString present" - */ - @Test - fun required_requiredPropertiesWhoseNamesAreJavascriptObjectPropertyNames_toStringPresent() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - "toString": { - "length": 37 - } - } - """, - """ - { - "required": [ - "__proto__", - "toString", - "constructor" - ] - } - """, - false, - """required properties whose names are Javascript object property names -> toString present""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required properties whose names are Javascript object property names -> constructor present" - */ - @Test - fun required_requiredPropertiesWhoseNamesAreJavascriptObjectPropertyNames_constructorPresent() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - "constructor": { - "length": 37 - } - } - """, - """ - { - "required": [ - "__proto__", - "toString", - "constructor" - ] - } - """, - false, - """required properties whose names are Javascript object property names -> constructor present""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/required.json`: - * "required properties whose names are Javascript object property names -> all present" - */ - @Test - fun required_requiredPropertiesWhoseNamesAreJavascriptObjectPropertyNames_allPresent() { - // Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object. - assertKsonEnforcesSchema( - """ - { - "__proto__": 12, - "toString": { - "length": "foo" - }, - "constructor": 37 - } - """, - """ - { - "required": [ - "__proto__", - "toString", - "constructor" - ] - } - """, - true, - """required properties whose names are Javascript object property names -> all present""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> an integer is an integer" - */ - @Test - fun type_integerTypeMatchesIntegers_anIntegerIsAnInteger() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "type": "integer" - } - """, - true, - """integer type matches integers -> an integer is an integer""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> a float with zero fractional part is an integer" - */ - @Test - fun type_integerTypeMatchesIntegers_aFloatWithZeroFractionalPartIsAnInteger() { - - assertKsonEnforcesSchema( - """ - 1.0 - """, - """ - { - "type": "integer" - } - """, - true, - """integer type matches integers -> a float with zero fractional part is an integer""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> a float is not an integer" - */ - @Test - fun type_integerTypeMatchesIntegers_aFloatIsNotAnInteger() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "type": "integer" - } - """, - false, - """integer type matches integers -> a float is not an integer""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> a string is not an integer" - */ - @Test - fun type_integerTypeMatchesIntegers_aStringIsNotAnInteger() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "integer" - } - """, - false, - """integer type matches integers -> a string is not an integer""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> a string is still not an integer, even if it looks like one" - */ - @Test - fun type_integerTypeMatchesIntegers_aStringIsStillNotAnInteger_EvenIfItLooksLikeOne() { - - assertKsonEnforcesSchema( - """ - "1" - """, - """ - { - "type": "integer" - } - """, - false, - """integer type matches integers -> a string is still not an integer, even if it looks like one""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> an object is not an integer" - */ - @Test - fun type_integerTypeMatchesIntegers_anObjectIsNotAnInteger() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "integer" - } - """, - false, - """integer type matches integers -> an object is not an integer""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> an array is not an integer" - */ - @Test - fun type_integerTypeMatchesIntegers_anArrayIsNotAnInteger() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "type": "integer" - } - """, - false, - """integer type matches integers -> an array is not an integer""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> a boolean is not an integer" - */ - @Test - fun type_integerTypeMatchesIntegers_aBooleanIsNotAnInteger() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "type": "integer" - } - """, - false, - """integer type matches integers -> a boolean is not an integer""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "integer type matches integers -> null is not an integer" - */ - @Test - fun type_integerTypeMatchesIntegers_nullIsNotAnInteger() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": "integer" - } - """, - false, - """integer type matches integers -> null is not an integer""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> an integer is a number" - */ - @Test - fun type_numberTypeMatchesNumbers_anIntegerIsANumber() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "type": "number" - } - """, - true, - """number type matches numbers -> an integer is a number""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> a float with zero fractional part is a number (and an integer)" - */ - @Test - fun type_numberTypeMatchesNumbers_aFloatWithZeroFractionalPartIsANumber_andAnInteger_() { - - assertKsonEnforcesSchema( - """ - 1.0 - """, - """ - { - "type": "number" - } - """, - true, - """number type matches numbers -> a float with zero fractional part is a number (and an integer)""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> a float is a number" - */ - @Test - fun type_numberTypeMatchesNumbers_aFloatIsANumber() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "type": "number" - } - """, - true, - """number type matches numbers -> a float is a number""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> a string is not a number" - */ - @Test - fun type_numberTypeMatchesNumbers_aStringIsNotANumber() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "number" - } - """, - false, - """number type matches numbers -> a string is not a number""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> a string is still not a number, even if it looks like one" - */ - @Test - fun type_numberTypeMatchesNumbers_aStringIsStillNotANumber_EvenIfItLooksLikeOne() { - - assertKsonEnforcesSchema( - """ - "1" - """, - """ - { - "type": "number" - } - """, - false, - """number type matches numbers -> a string is still not a number, even if it looks like one""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> an object is not a number" - */ - @Test - fun type_numberTypeMatchesNumbers_anObjectIsNotANumber() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "number" - } - """, - false, - """number type matches numbers -> an object is not a number""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> an array is not a number" - */ - @Test - fun type_numberTypeMatchesNumbers_anArrayIsNotANumber() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "type": "number" - } - """, - false, - """number type matches numbers -> an array is not a number""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> a boolean is not a number" - */ - @Test - fun type_numberTypeMatchesNumbers_aBooleanIsNotANumber() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "type": "number" - } - """, - false, - """number type matches numbers -> a boolean is not a number""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "number type matches numbers -> null is not a number" - */ - @Test - fun type_numberTypeMatchesNumbers_nullIsNotANumber() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": "number" - } - """, - false, - """number type matches numbers -> null is not a number""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> 1 is not a string" - */ - @Test - fun type_stringTypeMatchesStrings_1IsNotAString() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "type": "string" - } - """, - false, - """string type matches strings -> 1 is not a string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> a float is not a string" - */ - @Test - fun type_stringTypeMatchesStrings_aFloatIsNotAString() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "type": "string" - } - """, - false, - """string type matches strings -> a float is not a string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> a string is a string" - */ - @Test - fun type_stringTypeMatchesStrings_aStringIsAString() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "string" - } - """, - true, - """string type matches strings -> a string is a string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> a string is still a string, even if it looks like a number" - */ - @Test - fun type_stringTypeMatchesStrings_aStringIsStillAString_EvenIfItLooksLikeANumber() { - - assertKsonEnforcesSchema( - """ - "1" - """, - """ - { - "type": "string" - } - """, - true, - """string type matches strings -> a string is still a string, even if it looks like a number""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> an empty string is still a string" - */ - @Test - fun type_stringTypeMatchesStrings_anEmptyStringIsStillAString() { - - assertKsonEnforcesSchema( - """ - "" - """, - """ - { - "type": "string" - } - """, - true, - """string type matches strings -> an empty string is still a string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> an object is not a string" - */ - @Test - fun type_stringTypeMatchesStrings_anObjectIsNotAString() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "string" - } - """, - false, - """string type matches strings -> an object is not a string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> an array is not a string" - */ - @Test - fun type_stringTypeMatchesStrings_anArrayIsNotAString() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "type": "string" - } - """, - false, - """string type matches strings -> an array is not a string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> a boolean is not a string" - */ - @Test - fun type_stringTypeMatchesStrings_aBooleanIsNotAString() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "type": "string" - } - """, - false, - """string type matches strings -> a boolean is not a string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "string type matches strings -> null is not a string" - */ - @Test - fun type_stringTypeMatchesStrings_nullIsNotAString() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": "string" - } - """, - false, - """string type matches strings -> null is not a string""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "object type matches objects -> an integer is not an object" - */ - @Test - fun type_objectTypeMatchesObjects_anIntegerIsNotAnObject() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "type": "object" - } - """, - false, - """object type matches objects -> an integer is not an object""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "object type matches objects -> a float is not an object" - */ - @Test - fun type_objectTypeMatchesObjects_aFloatIsNotAnObject() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "type": "object" - } - """, - false, - """object type matches objects -> a float is not an object""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "object type matches objects -> a string is not an object" - */ - @Test - fun type_objectTypeMatchesObjects_aStringIsNotAnObject() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "object" - } - """, - false, - """object type matches objects -> a string is not an object""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "object type matches objects -> an object is an object" - */ - @Test - fun type_objectTypeMatchesObjects_anObjectIsAnObject() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "object" - } - """, - true, - """object type matches objects -> an object is an object""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "object type matches objects -> an array is not an object" - */ - @Test - fun type_objectTypeMatchesObjects_anArrayIsNotAnObject() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "type": "object" - } - """, - false, - """object type matches objects -> an array is not an object""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "object type matches objects -> a boolean is not an object" - */ - @Test - fun type_objectTypeMatchesObjects_aBooleanIsNotAnObject() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "type": "object" - } - """, - false, - """object type matches objects -> a boolean is not an object""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "object type matches objects -> null is not an object" - */ - @Test - fun type_objectTypeMatchesObjects_nullIsNotAnObject() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": "object" - } - """, - false, - """object type matches objects -> null is not an object""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "array type matches arrays -> an integer is not an array" - */ - @Test - fun type_arrayTypeMatchesArrays_anIntegerIsNotAnArray() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "type": "array" - } - """, - false, - """array type matches arrays -> an integer is not an array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "array type matches arrays -> a float is not an array" - */ - @Test - fun type_arrayTypeMatchesArrays_aFloatIsNotAnArray() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "type": "array" - } - """, - false, - """array type matches arrays -> a float is not an array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "array type matches arrays -> a string is not an array" - */ - @Test - fun type_arrayTypeMatchesArrays_aStringIsNotAnArray() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "array" - } - """, - false, - """array type matches arrays -> a string is not an array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "array type matches arrays -> an object is not an array" - */ - @Test - fun type_arrayTypeMatchesArrays_anObjectIsNotAnArray() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "array" - } - """, - false, - """array type matches arrays -> an object is not an array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "array type matches arrays -> an array is an array" - */ - @Test - fun type_arrayTypeMatchesArrays_anArrayIsAnArray() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "type": "array" - } - """, - true, - """array type matches arrays -> an array is an array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "array type matches arrays -> a boolean is not an array" - */ - @Test - fun type_arrayTypeMatchesArrays_aBooleanIsNotAnArray() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "type": "array" - } - """, - false, - """array type matches arrays -> a boolean is not an array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "array type matches arrays -> null is not an array" - */ - @Test - fun type_arrayTypeMatchesArrays_nullIsNotAnArray() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": "array" - } - """, - false, - """array type matches arrays -> null is not an array""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> an integer is not a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_anIntegerIsNotABoolean() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "type": "boolean" - } - """, - false, - """boolean type matches booleans -> an integer is not a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> zero is not a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_zeroIsNotABoolean() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "type": "boolean" - } - """, - false, - """boolean type matches booleans -> zero is not a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> a float is not a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_aFloatIsNotABoolean() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "type": "boolean" - } - """, - false, - """boolean type matches booleans -> a float is not a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> a string is not a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_aStringIsNotABoolean() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "boolean" - } - """, - false, - """boolean type matches booleans -> a string is not a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> an empty string is not a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_anEmptyStringIsNotABoolean() { - - assertKsonEnforcesSchema( - """ - "" - """, - """ - { - "type": "boolean" - } - """, - false, - """boolean type matches booleans -> an empty string is not a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> an object is not a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_anObjectIsNotABoolean() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "boolean" - } - """, - false, - """boolean type matches booleans -> an object is not a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> an array is not a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_anArrayIsNotABoolean() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "type": "boolean" - } - """, - false, - """boolean type matches booleans -> an array is not a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> true is a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_trueIsABoolean() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "type": "boolean" - } - """, - true, - """boolean type matches booleans -> true is a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> false is a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_falseIsABoolean() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "type": "boolean" - } - """, - true, - """boolean type matches booleans -> false is a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "boolean type matches booleans -> null is not a boolean" - */ - @Test - fun type_booleanTypeMatchesBooleans_nullIsNotABoolean() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": "boolean" - } - """, - false, - """boolean type matches booleans -> null is not a boolean""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> an integer is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_anIntegerIsNotNull() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> an integer is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> a float is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_aFloatIsNotNull() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> a float is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> zero is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_zeroIsNotNull() { - - assertKsonEnforcesSchema( - """ - 0 - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> zero is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> a string is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_aStringIsNotNull() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> a string is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> an empty string is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_anEmptyStringIsNotNull() { - - assertKsonEnforcesSchema( - """ - "" - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> an empty string is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> an object is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_anObjectIsNotNull() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> an object is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> an array is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_anArrayIsNotNull() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> an array is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> true is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_trueIsNotNull() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> true is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> false is not null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_falseIsNotNull() { - - assertKsonEnforcesSchema( - """ - false - """, - """ - { - "type": "null" - } - """, - false, - """null type matches only the null object -> false is not null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "null type matches only the null object -> null is null" - */ - @Test - fun type_nullTypeMatchesOnlyTheNullObject_nullIsNull() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": "null" - } - """, - true, - """null type matches only the null object -> null is null""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "multiple types can be specified in an array -> an integer is valid" - */ - @Test - fun type_multipleTypesCanBeSpecifiedInAnArray_anIntegerIsValid() { - - assertKsonEnforcesSchema( - """ - 1 - """, - """ - { - "type": [ - "integer", - "string" - ] - } - """, - true, - """multiple types can be specified in an array -> an integer is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "multiple types can be specified in an array -> a string is valid" - */ - @Test - fun type_multipleTypesCanBeSpecifiedInAnArray_aStringIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": [ - "integer", - "string" - ] - } - """, - true, - """multiple types can be specified in an array -> a string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "multiple types can be specified in an array -> a float is invalid" - */ - @Test - fun type_multipleTypesCanBeSpecifiedInAnArray_aFloatIsInvalid() { - - assertKsonEnforcesSchema( - """ - 1.1 - """, - """ - { - "type": [ - "integer", - "string" - ] - } - """, - false, - """multiple types can be specified in an array -> a float is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "multiple types can be specified in an array -> an object is invalid" - */ - @Test - fun type_multipleTypesCanBeSpecifiedInAnArray_anObjectIsInvalid() { - - assertKsonEnforcesSchema( - """ - { - } - """, - """ - { - "type": [ - "integer", - "string" - ] - } - """, - false, - """multiple types can be specified in an array -> an object is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "multiple types can be specified in an array -> an array is invalid" - */ - @Test - fun type_multipleTypesCanBeSpecifiedInAnArray_anArrayIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - ] - """, - """ - { - "type": [ - "integer", - "string" - ] - } - """, - false, - """multiple types can be specified in an array -> an array is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "multiple types can be specified in an array -> a boolean is invalid" - */ - @Test - fun type_multipleTypesCanBeSpecifiedInAnArray_aBooleanIsInvalid() { - - assertKsonEnforcesSchema( - """ - true - """, - """ - { - "type": [ - "integer", - "string" - ] - } - """, - false, - """multiple types can be specified in an array -> a boolean is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "multiple types can be specified in an array -> null is invalid" - */ - @Test - fun type_multipleTypesCanBeSpecifiedInAnArray_nullIsInvalid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": [ - "integer", - "string" - ] - } - """, - false, - """multiple types can be specified in an array -> null is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type as array with one item -> string is valid" - */ - @Test - fun type_typeAsArrayWithOneItem_stringIsValid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": [ - "string" - ] - } - """, - true, - """type as array with one item -> string is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type as array with one item -> number is invalid" - */ - @Test - fun type_typeAsArrayWithOneItem_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "type": [ - "string" - ] - } - """, - false, - """type as array with one item -> number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array or object -> array is valid" - */ - @Test - fun type_type_ArrayOrObject_arrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "type": [ - "array", - "object" - ] - } - """, - true, - """type: array or object -> array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array or object -> object is valid" - */ - @Test - fun type_type_ArrayOrObject_objectIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 123 - } - """, - """ - { - "type": [ - "array", - "object" - ] - } - """, - true, - """type: array or object -> object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array or object -> number is invalid" - */ - @Test - fun type_type_ArrayOrObject_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "type": [ - "array", - "object" - ] - } - """, - false, - """type: array or object -> number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array or object -> string is invalid" - */ - @Test - fun type_type_ArrayOrObject_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": [ - "array", - "object" - ] - } - """, - false, - """type: array or object -> string is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array or object -> null is invalid" - */ - @Test - fun type_type_ArrayOrObject_nullIsInvalid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": [ - "array", - "object" - ] - } - """, - false, - """type: array or object -> null is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array, object or null -> array is valid" - */ - @Test - fun type_type_Array_ObjectOrNull_arrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 3 - ] - """, - """ - { - "type": [ - "array", - "object", - "null" - ] - } - """, - true, - """type: array, object or null -> array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array, object or null -> object is valid" - */ - @Test - fun type_type_Array_ObjectOrNull_objectIsValid() { - - assertKsonEnforcesSchema( - """ - { - "foo": 123 - } - """, - """ - { - "type": [ - "array", - "object", - "null" - ] - } - """, - true, - """type: array, object or null -> object is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array, object or null -> null is valid" - */ - @Test - fun type_type_Array_ObjectOrNull_nullIsValid() { - - assertKsonEnforcesSchema( - """ - null - """, - """ - { - "type": [ - "array", - "object", - "null" - ] - } - """, - true, - """type: array, object or null -> null is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array, object or null -> number is invalid" - */ - @Test - fun type_type_Array_ObjectOrNull_numberIsInvalid() { - - assertKsonEnforcesSchema( - """ - 123 - """, - """ - { - "type": [ - "array", - "object", - "null" - ] - } - """, - false, - """type: array, object or null -> number is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/type.json`: - * "type: array, object or null -> string is invalid" - */ - @Test - fun type_type_Array_ObjectOrNull_stringIsInvalid() { - - assertKsonEnforcesSchema( - """ - "foo" - """, - """ - { - "type": [ - "array", - "object", - "null" - ] - } - """, - false, - """type: array, object or null -> string is invalid""") - } - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> unique array of integers is valid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_uniqueArrayOfIntegersIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2 - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> unique array of integers is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> non-unique array of integers is invalid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_non_uniqueArrayOfIntegersIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 1 - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> non-unique array of integers is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> non-unique array of more than two integers is invalid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_non_uniqueArrayOfMoreThanTwoIntegersIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2, - 1 - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> non-unique array of more than two integers is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> numbers are unique if mathematically unequal" - */ - @Test - fun uniqueItems_uniqueItemsValidation_numbersAreUniqueIfMathematicallyUnequal() { - - assertKsonEnforcesSchema( - """ - [ - 1.0, - 1.0, - 1 - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> numbers are unique if mathematically unequal""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> false is not equal to zero" - */ - @Test - fun uniqueItems_uniqueItemsValidation_falseIsNotEqualToZero() { - - assertKsonEnforcesSchema( - """ - [ - 0, - false - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> false is not equal to zero""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> true is not equal to one" - */ - @Test - fun uniqueItems_uniqueItemsValidation_trueIsNotEqualToOne() { - - assertKsonEnforcesSchema( - """ - [ - 1, - true - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> true is not equal to one""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> unique array of strings is valid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_uniqueArrayOfStringsIsValid() { - - assertKsonEnforcesSchema( - """ - [ - "foo", - "bar", - "baz" - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> unique array of strings is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> non-unique array of strings is invalid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_non_uniqueArrayOfStringsIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - "foo", - "bar", - "foo" - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> non-unique array of strings is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> unique array of objects is valid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_uniqueArrayOfObjectsIsValid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": "bar" - }, - { - "foo": "baz" - } - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> unique array of objects is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> non-unique array of objects is invalid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_non_uniqueArrayOfObjectsIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": "bar" - }, - { - "foo": "bar" - } - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> non-unique array of objects is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> property order of array of objects is ignored" - */ - @Test - fun uniqueItems_uniqueItemsValidation_propertyOrderOfArrayOfObjectsIsIgnored() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": "bar", - "bar": "foo" - }, - { - "bar": "foo", - "foo": "bar" - } - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> property order of array of objects is ignored""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> unique array of nested objects is valid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_uniqueArrayOfNestedObjectsIsValid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": false - } - } - } - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> unique array of nested objects is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> non-unique array of nested objects is invalid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_non_uniqueArrayOfNestedObjectsIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": true - } - } - } - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> non-unique array of nested objects is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> unique array of arrays is valid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_uniqueArrayOfArraysIsValid() { - - assertKsonEnforcesSchema( - """ - [ - [ - "foo" - ], - [ - "bar" - ] - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> unique array of arrays is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> non-unique array of arrays is invalid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_non_uniqueArrayOfArraysIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - [ - "foo" - ], - [ - "foo" - ] - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> non-unique array of arrays is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> non-unique array of more than two arrays is invalid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_non_uniqueArrayOfMoreThanTwoArraysIsInvalid() { - - assertKsonEnforcesSchema( - """ - [ - [ - "foo" - ], - [ - "bar" - ], - [ - "foo" - ] - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> non-unique array of more than two arrays is invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> 1 and true are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation_1AndTrueAreUnique() { - - assertKsonEnforcesSchema( - """ - [ - 1, - true - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> 1 and true are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> 0 and false are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation_0AndFalseAreUnique() { - - assertKsonEnforcesSchema( - """ - [ - 0, - false - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> 0 and false are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> [1] and [true] are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation__1_And_true_AreUnique() { - - assertKsonEnforcesSchema( - """ - [ - [ - 1 - ], - [ - true - ] - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> [1] and [true] are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> [0] and [false] are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation__0_And_false_AreUnique() { - - assertKsonEnforcesSchema( - """ - [ - [ - 0 - ], - [ - false - ] - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> [0] and [false] are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> nested [1] and [true] are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation_nested_1_And_true_AreUnique() { - - assertKsonEnforcesSchema( - """ - [ - [ - [ - 1 - ], - "foo" - ], - [ - [ - true - ], - "foo" - ] - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> nested [1] and [true] are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> nested [0] and [false] are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation_nested_0_And_false_AreUnique() { - - assertKsonEnforcesSchema( - """ - [ - [ - [ - 0 - ], - "foo" - ], - [ - [ - false - ], - "foo" - ] - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> nested [0] and [false] are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> unique heterogeneous types are valid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_uniqueHeterogeneousTypesAreValid() { - - assertKsonEnforcesSchema( - """ - [ - { - }, - [ - 1 - ], - true, - null, - 1, - "{}" - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> unique heterogeneous types are valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> non-unique heterogeneous types are invalid" - */ - @Test - fun uniqueItems_uniqueItemsValidation_non_uniqueHeterogeneousTypesAreInvalid() { - - assertKsonEnforcesSchema( - """ - [ - { - }, - [ - 1 - ], - true, - null, - { - }, - 1 - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> non-unique heterogeneous types are invalid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> different objects are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation_differentObjectsAreUnique() { - - assertKsonEnforcesSchema( - """ - [ - { - "a": 1, - "b": 2 - }, - { - "a": 2, - "b": 1 - } - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> different objects are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> objects are non-unique despite key order" - */ - @Test - fun uniqueItems_uniqueItemsValidation_objectsAreNon_uniqueDespiteKeyOrder() { - - assertKsonEnforcesSchema( - """ - [ - { - "a": 1, - "b": 2 - }, - { - "b": 2, - "a": 1 - } - ] - """, - """ - { - "uniqueItems": true - } - """, - false, - """uniqueItems validation -> objects are non-unique despite key order""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> {"a": false} and {"a": 0} are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation___a__False_And__a__0_AreUnique() { - - assertKsonEnforcesSchema( - """ - [ - { - "a": false - }, - { - "a": 0 - } - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> {"a": false} and {"a": 0} are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems validation -> {"a": true} and {"a": 1} are unique" - */ - @Test - fun uniqueItems_uniqueItemsValidation___a__True_And__a__1_AreUnique() { - - assertKsonEnforcesSchema( - """ - [ - { - "a": true - }, - { - "a": 1 - } - ] - """, - """ - { - "uniqueItems": true - } - """, - true, - """uniqueItems validation -> {"a": true} and {"a": 1} are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items -> [false, true] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItems__false_True_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - true - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - } - """, - true, - """uniqueItems with an array of items -> [false, true] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items -> [true, false] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItems__true_False_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - false - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - } - """, - true, - """uniqueItems with an array of items -> [true, false] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items -> [false, false] from items array is not valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItems__false_False_FromItemsArrayIsNotValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - false - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - } - """, - false, - """uniqueItems with an array of items -> [false, false] from items array is not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items -> [true, true] from items array is not valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItems__true_True_FromItemsArrayIsNotValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - true - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - } - """, - false, - """uniqueItems with an array of items -> [true, true] from items array is not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items -> unique array extended from [false, true] is valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItems_uniqueArrayExtendedFrom_false_True_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - true, - "foo", - "bar" - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - } - """, - true, - """uniqueItems with an array of items -> unique array extended from [false, true] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items -> unique array extended from [true, false] is valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItems_uniqueArrayExtendedFrom_true_False_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - false, - "foo", - "bar" - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - } - """, - true, - """uniqueItems with an array of items -> unique array extended from [true, false] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items -> non-unique array extended from [false, true] is not valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItems_non_uniqueArrayExtendedFrom_false_True_IsNotValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - true, - "foo", - "foo" - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - } - """, - false, - """uniqueItems with an array of items -> non-unique array extended from [false, true] is not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items -> non-unique array extended from [true, false] is not valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItems_non_uniqueArrayExtendedFrom_true_False_IsNotValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - false, - "foo", - "foo" - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - } - """, - false, - """uniqueItems with an array of items -> non-unique array extended from [true, false] is not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items and additionalItems=false -> [false, true] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItemsAndAdditionalItems_false__false_True_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - true - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true, - "additionalItems": false - } - """, - true, - """uniqueItems with an array of items and additionalItems=false -> [false, true] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items and additionalItems=false -> [true, false] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItemsAndAdditionalItems_false__true_False_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - false - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true, - "additionalItems": false - } - """, - true, - """uniqueItems with an array of items and additionalItems=false -> [true, false] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items and additionalItems=false -> [false, false] from items array is not valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItemsAndAdditionalItems_false__false_False_FromItemsArrayIsNotValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - false - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true, - "additionalItems": false - } - """, - false, - """uniqueItems with an array of items and additionalItems=false -> [false, false] from items array is not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items and additionalItems=false -> [true, true] from items array is not valid" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItemsAndAdditionalItems_false__true_True_FromItemsArrayIsNotValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - true - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true, - "additionalItems": false - } - """, - false, - """uniqueItems with an array of items and additionalItems=false -> [true, true] from items array is not valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems with an array of items and additionalItems=false -> extra items are invalid even if unique" - */ - @Test - fun uniqueItems_uniqueItemsWithAnArrayOfItemsAndAdditionalItems_false_extraItemsAreInvalidEvenIfUnique() { - - assertKsonEnforcesSchema( - """ - [ - false, - true, - null - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true, - "additionalItems": false - } - """, - false, - """uniqueItems with an array of items and additionalItems=false -> extra items are invalid even if unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> unique array of integers is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_uniqueArrayOfIntegersIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 2 - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> unique array of integers is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> non-unique array of integers is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_non_uniqueArrayOfIntegersIsValid() { - - assertKsonEnforcesSchema( - """ - [ - 1, - 1 - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> non-unique array of integers is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> numbers are unique if mathematically unequal" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_numbersAreUniqueIfMathematicallyUnequal() { - - assertKsonEnforcesSchema( - """ - [ - 1.0, - 1.0, - 1 - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> numbers are unique if mathematically unequal""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> false is not equal to zero" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_falseIsNotEqualToZero() { - - assertKsonEnforcesSchema( - """ - [ - 0, - false - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> false is not equal to zero""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> true is not equal to one" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_trueIsNotEqualToOne() { - - assertKsonEnforcesSchema( - """ - [ - 1, - true - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> true is not equal to one""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> unique array of objects is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_uniqueArrayOfObjectsIsValid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": "bar" - }, - { - "foo": "baz" - } - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> unique array of objects is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> non-unique array of objects is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_non_uniqueArrayOfObjectsIsValid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": "bar" - }, - { - "foo": "bar" - } - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> non-unique array of objects is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> unique array of nested objects is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_uniqueArrayOfNestedObjectsIsValid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": false - } - } - } - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> unique array of nested objects is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> non-unique array of nested objects is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_non_uniqueArrayOfNestedObjectsIsValid() { - - assertKsonEnforcesSchema( - """ - [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": true - } - } - } - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> non-unique array of nested objects is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> unique array of arrays is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_uniqueArrayOfArraysIsValid() { - - assertKsonEnforcesSchema( - """ - [ - [ - "foo" - ], - [ - "bar" - ] - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> unique array of arrays is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> non-unique array of arrays is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_non_uniqueArrayOfArraysIsValid() { - - assertKsonEnforcesSchema( - """ - [ - [ - "foo" - ], - [ - "foo" - ] - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> non-unique array of arrays is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> 1 and true are unique" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_1AndTrueAreUnique() { - - assertKsonEnforcesSchema( - """ - [ - 1, - true - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> 1 and true are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> 0 and false are unique" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_0AndFalseAreUnique() { - - assertKsonEnforcesSchema( - """ - [ - 0, - false - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> 0 and false are unique""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> unique heterogeneous types are valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_uniqueHeterogeneousTypesAreValid() { - - assertKsonEnforcesSchema( - """ - [ - { - }, - [ - 1 - ], - true, - null, - 1 - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> unique heterogeneous types are valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false validation -> non-unique heterogeneous types are valid" - */ - @Test - fun uniqueItems_uniqueItems_falseValidation_non_uniqueHeterogeneousTypesAreValid() { - - assertKsonEnforcesSchema( - """ - [ - { - }, - [ - 1 - ], - true, - null, - { - }, - 1 - ] - """, - """ - { - "uniqueItems": false - } - """, - true, - """uniqueItems=false validation -> non-unique heterogeneous types are valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items -> [false, true] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItems__false_True_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - true - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - } - """, - true, - """uniqueItems=false with an array of items -> [false, true] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items -> [true, false] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItems__true_False_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - false - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - } - """, - true, - """uniqueItems=false with an array of items -> [true, false] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items -> [false, false] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItems__false_False_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - false - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - } - """, - true, - """uniqueItems=false with an array of items -> [false, false] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items -> [true, true] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItems__true_True_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - true - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - } - """, - true, - """uniqueItems=false with an array of items -> [true, true] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items -> unique array extended from [false, true] is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItems_uniqueArrayExtendedFrom_false_True_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - true, - "foo", - "bar" - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - } - """, - true, - """uniqueItems=false with an array of items -> unique array extended from [false, true] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items -> unique array extended from [true, false] is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItems_uniqueArrayExtendedFrom_true_False_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - false, - "foo", - "bar" - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - } - """, - true, - """uniqueItems=false with an array of items -> unique array extended from [true, false] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items -> non-unique array extended from [false, true] is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItems_non_uniqueArrayExtendedFrom_false_True_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - true, - "foo", - "foo" - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - } - """, - true, - """uniqueItems=false with an array of items -> non-unique array extended from [false, true] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items -> non-unique array extended from [true, false] is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItems_non_uniqueArrayExtendedFrom_true_False_IsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - false, - "foo", - "foo" - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - } - """, - true, - """uniqueItems=false with an array of items -> non-unique array extended from [true, false] is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items and additionalItems=false -> [false, true] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItemsAndAdditionalItems_false__false_True_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - true - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false, - "additionalItems": false - } - """, - true, - """uniqueItems=false with an array of items and additionalItems=false -> [false, true] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items and additionalItems=false -> [true, false] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItemsAndAdditionalItems_false__true_False_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - false - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false, - "additionalItems": false - } - """, - true, - """uniqueItems=false with an array of items and additionalItems=false -> [true, false] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items and additionalItems=false -> [false, false] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItemsAndAdditionalItems_false__false_False_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - false, - false - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false, - "additionalItems": false - } - """, - true, - """uniqueItems=false with an array of items and additionalItems=false -> [false, false] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items and additionalItems=false -> [true, true] from items array is valid" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItemsAndAdditionalItems_false__true_True_FromItemsArrayIsValid() { - - assertKsonEnforcesSchema( - """ - [ - true, - true - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false, - "additionalItems": false - } - """, - true, - """uniqueItems=false with an array of items and additionalItems=false -> [true, true] from items array is valid""") - } - - /** - * Test generated by [org.kson.jsonsuite.JsonTestSuiteGenerator] based on `buildSrc/support/jsonsuite/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json`: - * "uniqueItems=false with an array of items and additionalItems=false -> extra items are invalid even if unique" - */ - @Test - fun uniqueItems_uniqueItems_falseWithAnArrayOfItemsAndAdditionalItems_false_extraItemsAreInvalidEvenIfUnique() { - - assertKsonEnforcesSchema( - """ - [ - false, - true, - null - ] - """, - """ - { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false, - "additionalItems": false - } - """, - false, - """uniqueItems=false with an array of items and additionalItems=false -> extra items are invalid even if unique""") - } -} diff --git a/src/commonTest/kotlin/org/kson/schema/JsonSchemaTest.kt b/src/commonTest/kotlin/org/kson/schema/JsonSchemaTest.kt index 2d1f9dd3..70b5c624 100644 --- a/src/commonTest/kotlin/org/kson/schema/JsonSchemaTest.kt +++ b/src/commonTest/kotlin/org/kson/schema/JsonSchemaTest.kt @@ -17,7 +17,7 @@ interface JsonSchemaTest { schemaJson: String, shouldAcceptAsValid: Boolean, message: String? = null) { - val jsonSchema = assertValidSchema(schemaJson) + val jsonSchema = assertValidSchema(schemaJson, message) val parseResult = KsonCore.parseToAst( ksonSource.trimIndent(), coreCompileConfig = CoreCompileConfig(schemaJson = jsonSchema) @@ -68,15 +68,15 @@ interface JsonSchemaTest { * Assertion helper for testing that [source] is successfully parsed by the schema parser * (produces non-null jsonSchema) with no error messages */ - fun assertValidSchema(source: String): JsonSchema { + fun assertValidSchema(source: String, message: String? = null): JsonSchema { val result = KsonCore.parseSchema(source) val jsonSchema = result.jsonSchema assertTrue( result.messages.isEmpty(), "Should have no error messages when parsing succeeds, got: " + - result.messages.joinToString("\n") + result.messages.joinToString("\n") + message ) - assertNotNull(jsonSchema, "Should produce a non-null schema when parsing succeeds") + assertNotNull(jsonSchema, "Should produce a non-null schema when parsing succeeds $message") return jsonSchema }