|
7 | 7 | #include <sourcemeta/core/jsonschema.h> |
8 | 8 |
|
9 | 9 | #define EXPECT_OUTPUT(traces, index, expected_instance_location, \ |
10 | | - expected_evaluate_path, expected_message) \ |
| 10 | + expected_evaluate_path, expected_schema_location, \ |
| 11 | + expected_message) \ |
11 | 12 | EXPECT_TRUE(traces.size() > index); \ |
12 | 13 | EXPECT_EQ(traces.at((index)).message, (expected_message)); \ |
13 | 14 | EXPECT_EQ(sourcemeta::core::to_string(traces.at((index)).instance_location), \ |
14 | 15 | expected_instance_location); \ |
15 | 16 | EXPECT_EQ(sourcemeta::core::to_string(traces.at((index)).evaluate_path), \ |
16 | | - expected_evaluate_path); |
| 17 | + expected_evaluate_path); \ |
| 18 | + EXPECT_EQ(traces.at((index)).schema_location.get(), \ |
| 19 | + (expected_schema_location)); |
17 | 20 |
|
18 | 21 | #define EXPECT_ANNOTATION_COUNT(output, expected_count) \ |
19 | 22 | EXPECT_EQ(output.annotations().size(), (expected_count)); |
@@ -116,9 +119,11 @@ TEST(Compiler_output_simple, fail_meaningless_if_1) { |
116 | 119 |
|
117 | 120 | EXPECT_OUTPUT( |
118 | 121 | traces, 0, "/foo/~1baz", "/properties/foo/unevaluatedProperties", |
| 122 | + "#/properties/foo/unevaluatedProperties", |
119 | 123 | "The object value was not expected to define the property \"/baz\""); |
120 | 124 | EXPECT_OUTPUT( |
121 | 125 | traces, 1, "/foo", "/properties/foo/unevaluatedProperties", |
| 126 | + "#/properties/foo/unevaluatedProperties", |
122 | 127 | "The object value was not expected to define unevaluated properties"); |
123 | 128 |
|
124 | 129 | EXPECT_ANNOTATION_COUNT(output, 0); |
@@ -209,7 +214,7 @@ TEST(Compiler_output_simple, fail_string) { |
209 | 214 |
|
210 | 215 | EXPECT_EQ(traces.size(), 1); |
211 | 216 | EXPECT_OUTPUT( |
212 | | - traces, 0, "", "/type", |
| 217 | + traces, 0, "", "/type", "#/type", |
213 | 218 | "The value was expected to be of type string but it was of type integer"); |
214 | 219 |
|
215 | 220 | EXPECT_ANNOTATION_COUNT(output, 0); |
@@ -244,7 +249,7 @@ TEST(Compiler_output_simple, fail_string_over_ref) { |
244 | 249 |
|
245 | 250 | EXPECT_EQ(traces.size(), 1); |
246 | 251 | EXPECT_OUTPUT( |
247 | | - traces, 0, "", "/$ref/type", |
| 252 | + traces, 0, "", "/$ref/type", "#/$defs/string/type", |
248 | 253 | "The value was expected to be of type string but it was of type integer"); |
249 | 254 | EXPECT_ANNOTATION_COUNT(output, 0); |
250 | 255 | } |
@@ -280,7 +285,7 @@ TEST(Compiler_output_simple, fail_string_with_matching_base) { |
280 | 285 |
|
281 | 286 | EXPECT_EQ(traces.size(), 1); |
282 | 287 | EXPECT_OUTPUT( |
283 | | - traces, 0, "", "/type", |
| 288 | + traces, 0, "", "/type", "#/$defs/string/type", |
284 | 289 | "The value was expected to be of type string but it was of type integer"); |
285 | 290 | EXPECT_ANNOTATION_COUNT(output, 0); |
286 | 291 | } |
@@ -315,7 +320,7 @@ TEST(Compiler_output_simple, fail_string_with_non_matching_base) { |
315 | 320 |
|
316 | 321 | EXPECT_EQ(traces.size(), 1); |
317 | 322 | EXPECT_OUTPUT( |
318 | | - traces, 0, "", "/$ref/type", |
| 323 | + traces, 0, "", "/$ref/type", "#/$defs/string/type", |
319 | 324 | "The value was expected to be of type string but it was of type integer"); |
320 | 325 | EXPECT_ANNOTATION_COUNT(output, 0); |
321 | 326 | } |
@@ -346,7 +351,7 @@ TEST(Compiler_output_simple, fail_oneof_1) { |
346 | 351 | output.cend()}; |
347 | 352 |
|
348 | 353 | EXPECT_EQ(traces.size(), 1); |
349 | | - EXPECT_OUTPUT(traces, 0, "", "/oneOf", |
| 354 | + EXPECT_OUTPUT(traces, 0, "", "/oneOf", "#/oneOf", |
350 | 355 | "The string value was expected to validate against one and " |
351 | 356 | "only one of the 2 given subschemas"); |
352 | 357 | EXPECT_ANNOTATION_COUNT(output, 0); |
@@ -377,7 +382,7 @@ TEST(Compiler_output_simple, fail_not_1) { |
377 | 382 | output.cend()}; |
378 | 383 |
|
379 | 384 | EXPECT_EQ(traces.size(), 1); |
380 | | - EXPECT_OUTPUT(traces, 0, "", "/not", |
| 385 | + EXPECT_OUTPUT(traces, 0, "", "/not", "#/not", |
381 | 386 | "The string value was expected to not validate against the " |
382 | 387 | "given subschema, but it did"); |
383 | 388 | EXPECT_ANNOTATION_COUNT(output, 0); |
@@ -410,7 +415,7 @@ TEST(Compiler_output_simple, fail_not_not_1) { |
410 | 415 | output.cend()}; |
411 | 416 |
|
412 | 417 | EXPECT_EQ(traces.size(), 1); |
413 | | - EXPECT_OUTPUT(traces, 0, "", "/not", |
| 418 | + EXPECT_OUTPUT(traces, 0, "", "/not", "#/not", |
414 | 419 | "The integer value was expected to not validate against the " |
415 | 420 | "given subschema, but it did"); |
416 | 421 | EXPECT_ANNOTATION_COUNT(output, 0); |
@@ -450,7 +455,7 @@ TEST(Compiler_output_simple, fail_anyof_1) { |
450 | 455 |
|
451 | 456 | EXPECT_EQ(traces.size(), 1); |
452 | 457 | EXPECT_OUTPUT( |
453 | | - traces, 0, "", "/allOf/1/type", |
| 458 | + traces, 0, "", "/allOf/1/type", "#/allOf/1/type", |
454 | 459 | "The value was expected to be of type integer but it was of type object"); |
455 | 460 | EXPECT_ANNOTATION_COUNT(output, 0); |
456 | 461 | } |
@@ -483,7 +488,7 @@ TEST(Compiler_output_simple, fail_anyof_2) { |
483 | 488 | output.cend()}; |
484 | 489 |
|
485 | 490 | EXPECT_EQ(traces.size(), 1); |
486 | | - EXPECT_OUTPUT(traces, 0, "", "/anyOf", |
| 491 | + EXPECT_OUTPUT(traces, 0, "", "/anyOf", "#/anyOf", |
487 | 492 | "The object value was expected to validate against at least " |
488 | 493 | "one of the 2 given subschemas"); |
489 | 494 | EXPECT_ANNOTATION_COUNT(output, 0); |
|
0 commit comments