@@ -2123,3 +2123,84 @@ TEST(Evaluator_2020_12, cross_id_1) {
21232123 EVALUATE_TRACE_POST_DESCRIBE (instance, 0 ,
21242124 " The value was expected to be of type string" );
21252125}
2126+
2127+ TEST (Evaluator_2020_12, propertyNames_1) {
2128+ const sourcemeta::core::JSON schema{sourcemeta::core::parse_json (R"JSON( {
2129+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2130+ "propertyNames": {
2131+ "title": "Test",
2132+ "description": "Test",
2133+ "default": "Test",
2134+ "deprecated": true,
2135+ "examples": [ "foo" ],
2136+ "readOnly": true,
2137+ "writeOnly": true,
2138+
2139+ "x-foo": "bar",
2140+
2141+ "format": "email",
2142+
2143+ "contentEncoding": "base64",
2144+ "contentMediaType": "application/json",
2145+ "contentSchema": true,
2146+
2147+ "prefixItems": [ { "type": "string" } ],
2148+ "items": { "type": "string" },
2149+ "unevaluatedItems": { "type": "string" },
2150+ "contains": { "type": "string" },
2151+
2152+ "properties": { "foo": { "type": "string" } },
2153+ "patternProperties": { "^f": { "type": "string" } },
2154+ "additionalProperties": { "type": "string" },
2155+ "unevaluatedProperties": { "type": "string" }
2156+ }
2157+ })JSON" )};
2158+
2159+ const sourcemeta::core::JSON instance{
2160+ sourcemeta::core::parse_json (" { \" foo\" : 1 }" )};
2161+ EVALUATE_WITH_TRACE_FAST_SUCCESS (schema, instance, 0 );
2162+ }
2163+
2164+ TEST (Evaluator_2020_12, propertyNames_1_exhaustive) {
2165+ const sourcemeta::core::JSON schema{sourcemeta::core::parse_json (R"JSON( {
2166+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2167+ "propertyNames": {
2168+ "title": "Test",
2169+ "description": "Test",
2170+ "default": "Test",
2171+ "deprecated": true,
2172+ "examples": [ "foo" ],
2173+ "readOnly": true,
2174+ "writeOnly": true,
2175+
2176+ "x-foo": "bar",
2177+
2178+ "format": "email",
2179+
2180+ "contentEncoding": "base64",
2181+ "contentMediaType": "application/json",
2182+ "contentSchema": true,
2183+
2184+ "prefixItems": [ { "type": "string" } ],
2185+ "items": { "type": "string" },
2186+ "unevaluatedItems": { "type": "string" },
2187+ "contains": { "type": "string" },
2188+
2189+ "properties": { "foo": { "type": "string" } },
2190+ "patternProperties": { "^f": { "type": "string" } },
2191+ "additionalProperties": { "type": "string" },
2192+ "unevaluatedProperties": { "type": "string" }
2193+ }
2194+ })JSON" )};
2195+
2196+ const sourcemeta::core::JSON instance{
2197+ sourcemeta::core::parse_json (" { \" foo\" : 1 }" )};
2198+ EVALUATE_WITH_TRACE_EXHAUSTIVE_SUCCESS (schema, instance, 1 );
2199+
2200+ EVALUATE_TRACE_PRE (0 , LoopKeys, " /propertyNames" , " #/propertyNames" , " " );
2201+ EVALUATE_TRACE_POST_SUCCESS (0 , LoopKeys, " /propertyNames" , " #/propertyNames" ,
2202+ " " );
2203+ EVALUATE_TRACE_POST_DESCRIBE (instance, 0 ,
2204+ " The object property \" foo\" was expected to "
2205+ " validate against the given subschema" );
2206+ }
0 commit comments