Skip to content

Commit

Permalink
Test SchemaFlatFileResolver re-identifying a schema with absolute r…
Browse files Browse the repository at this point in the history
…efs (#1505)

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
jviotti authored Jan 30, 2025
1 parent 8cf5a49 commit eeee8b4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/jsonschema/jsonschema_flat_file_resolver_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,29 @@ TEST(JSONSchema_SchemaFlatFileResolver, with_recursive_ref) {
resolver("https://www.sourcemeta.com/2019-09-recursive-ref.json").value(),
expected);
}

TEST(JSONSchema_SchemaFlatFileResolver, with_absolute_references_reidentify) {
sourcemeta::core::SchemaFlatFileResolver resolver;
const auto schema_path{std::filesystem::path{SCHEMAS_PATH} /
"2020-12-absolute-ref.json"};

const sourcemeta::core::JSON expected = sourcemeta::core::parse_json(R"JSON({
"$id": "https://www.example.com/2020-12-absolute-ref.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$ref": "2020-12-id.json"
})JSON");

const auto &identifier{resolver.add(schema_path)};
EXPECT_EQ(identifier, "https://www.sourcemeta.com/2020-12-absolute-ref.json");

resolver.reidentify("https://www.sourcemeta.com/2020-12-absolute-ref.json",
"https://www.example.com/2020-12-absolute-ref.json");

EXPECT_FALSE(resolver("https://www.sourcemeta.com/2020-12-absolute-ref.json")
.has_value());
EXPECT_TRUE(resolver("https://www.example.com/2020-12-absolute-ref.json")
.has_value());
EXPECT_EQ(
resolver("https://www.example.com/2020-12-absolute-ref.json").value(),
expected);
}

5 comments on commit eeee8b4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (macos/llvm)

Benchmark suite Current: eeee8b4 Previous: 8cf5a49 Ratio
Regex_Lower_S_Or_Upper_S_Asterisk 1.574202409082606 ns/iter 2.2458258585886375 ns/iter 0.70
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 1.5657428802363467 ns/iter 1.9312792320088579 ns/iter 0.81
Regex_Period_Asterisk 1.5659842824326367 ns/iter 1.8543390971448808 ns/iter 0.84
Regex_Group_Period_Asterisk_Group 1.5674228475532592 ns/iter 1.935738423508453 ns/iter 0.81
Regex_Period_Plus 1.898787437750302 ns/iter 2.2141495336060437 ns/iter 0.86
Regex_Period 1.8829918490383135 ns/iter 2.644948429650571 ns/iter 0.71
Regex_Caret_Period_Plus_Dollar 1.882915898498629 ns/iter 2.570080828177242 ns/iter 0.73
Regex_Caret_Group_Period_Plus_Group_Dollar 1.905824796771796 ns/iter 2.5520923010991994 ns/iter 0.75
Regex_Caret_Period_Asterisk_Dollar 1.59475142672225 ns/iter 2.1989583374446973 ns/iter 0.73
Regex_Caret_Group_Period_Asterisk_Group_Dollar 1.5868629255267144 ns/iter 2.382166543386614 ns/iter 0.67
Regex_Caret_X_Hyphen 6.5817484066807594 ns/iter 8.966162205468052 ns/iter 0.73
Regex_Period_Md_Dollar 67.85782382468453 ns/iter 93.469451320087 ns/iter 0.73
Regex_Caret_Slash_Period_Asterisk 5.014689280780032 ns/iter 7.462991725297044 ns/iter 0.67
Regex_Caret_Period_Range_Dollar 2.199914738072529 ns/iter 3.1015821852281773 ns/iter 0.71
Regex_Nested_Backtrack 729.2853780854929 ns/iter 978.3882679102969 ns/iter 0.75
JSON_Array_Of_Objects_Unique 326.9754026152866 ns/iter 444.1164198936398 ns/iter 0.74
JSON_Parse_1 21126.853058872028 ns/iter 30990.432252770446 ns/iter 0.68
JSON_Fast_Hash_Helm_Chart_Lock 47.58255428294501 ns/iter 69.16707412128278 ns/iter 0.69
JSON_Equality_Helm_Chart_Lock 118.57622544285837 ns/iter 155.37048034859276 ns/iter 0.76
JSON_String_Equal/10 7.678094502144012 ns/iter 10.019955892640828 ns/iter 0.77
JSON_String_Equal/100 6.1281257834745055 ns/iter 8.255261094801297 ns/iter 0.74
JSON_String_Equal_Small_By_Perfect_Hash/10 0.31338319838212725 ns/iter 0.4339872702313934 ns/iter 0.72
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 2.93901215535019 ns/iter 4.06682891629415 ns/iter 0.72
JSON_String_Fast_Hash/10 1.5763973810940526 ns/iter 2.1543049444411198 ns/iter 0.73
JSON_String_Fast_Hash/100 1.8795224827166008 ns/iter 2.4844176838821723 ns/iter 0.76
JSON_String_Key_Hash/10 1.2574323264793936 ns/iter 1.6432286027783927 ns/iter 0.77
JSON_String_Key_Hash/100 1.2519948337264935 ns/iter 1.6638998993855616 ns/iter 0.75
JSON_Object_Defines_Miss_Same_Length 2.1913480483975265 ns/iter 3.335863760964066 ns/iter 0.66
JSON_Object_Defines_Miss_Too_Small 2.193168216985182 ns/iter 3.025926662150068 ns/iter 0.72
JSON_Object_Defines_Miss_Too_Large 2.1933265007941087 ns/iter 3.0978096616726676 ns/iter 0.71
Pointer_Object_Traverse 17.05045251971464 ns/iter 25.33617080616605 ns/iter 0.67
Pointer_Object_Try_Traverse 21.914687888085858 ns/iter 29.100240898907977 ns/iter 0.75
Pointer_Push_Back_Pointer_To_Weak_Pointer 170.1382242346276 ns/iter 217.5574601891273 ns/iter 0.78

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (linux/llvm)

Benchmark suite Current: eeee8b4 Previous: 8cf5a49 Ratio
Regex_Lower_S_Or_Upper_S_Asterisk 2.2108609081051327 ns/iter 2.2270752955242745 ns/iter 0.99
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 2.2391461119359164 ns/iter 2.207675952314714 ns/iter 1.01
Regex_Period_Asterisk 2.217377433681511 ns/iter 2.202200757276197 ns/iter 1.01
Regex_Group_Period_Asterisk_Group 2.1967525432352 ns/iter 2.2110025339181525 ns/iter 0.99
Regex_Period_Plus 2.7997467245200753 ns/iter 2.8006313272732815 ns/iter 1.00
Regex_Period 2.7979387257615738 ns/iter 2.7994861256969363 ns/iter 1.00
Regex_Caret_Period_Plus_Dollar 2.7972639864760698 ns/iter 2.7999675253821747 ns/iter 1.00
Regex_Caret_Group_Period_Plus_Group_Dollar 2.7977596602194037 ns/iter 2.799551506131991 ns/iter 1.00
Regex_Caret_Period_Asterisk_Dollar 3.4173203704813244 ns/iter 3.418952988534301 ns/iter 1.00
Regex_Caret_Group_Period_Asterisk_Group_Dollar 3.4185838072179626 ns/iter 3.4207344150709846 ns/iter 1.00
Regex_Caret_X_Hyphen 13.076664256032164 ns/iter 13.064675190195798 ns/iter 1.00
Regex_Period_Md_Dollar 81.91786274558321 ns/iter 81.73306018112471 ns/iter 1.00
Regex_Caret_Slash_Period_Asterisk 6.836560091173742 ns/iter 6.838112570380814 ns/iter 1.00
Regex_Caret_Period_Range_Dollar 4.045269326306317 ns/iter 4.046297873256092 ns/iter 1.00
Regex_Nested_Backtrack 505.55881620691866 ns/iter 499.36500454443814 ns/iter 1.01
JSON_Array_Of_Objects_Unique 402.5793725894212 ns/iter 408.4433899067244 ns/iter 0.99
JSON_Parse_1 30629.35695457375 ns/iter 30296.929983060272 ns/iter 1.01
JSON_Fast_Hash_Helm_Chart_Lock 59.16715966175035 ns/iter 59.357573665400025 ns/iter 1.00
JSON_Equality_Helm_Chart_Lock 163.80073124345293 ns/iter 157.0616992042028 ns/iter 1.04
JSON_String_Equal/10 6.596144406313535 ns/iter 6.222476464624364 ns/iter 1.06
JSON_String_Equal/100 6.53600380896747 ns/iter 6.850214845462466 ns/iter 0.95
JSON_String_Equal_Small_By_Perfect_Hash/10 0.9346347063756293 ns/iter 0.9352128189554774 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 10.255262549088286 ns/iter 14.604966453864959 ns/iter 0.70
JSON_String_Fast_Hash/10 2.4869836319494545 ns/iter 2.48967114275639 ns/iter 1.00
JSON_String_Fast_Hash/100 2.488012849998057 ns/iter 2.489231626350758 ns/iter 1.00
JSON_String_Key_Hash/10 2.179015289769519 ns/iter 2.656484066800175 ns/iter 0.82
JSON_String_Key_Hash/100 1.868400614682435 ns/iter 1.890100562728237 ns/iter 0.99
JSON_Object_Defines_Miss_Same_Length 3.73761693357406 ns/iter 3.7361104835252883 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 3.734014650846587 ns/iter 3.7799533215937986 ns/iter 0.99
JSON_Object_Defines_Miss_Too_Large 3.735140688225413 ns/iter 3.7376513129595206 ns/iter 1.00
Pointer_Object_Traverse 44.328882511155875 ns/iter 44.38814616809202 ns/iter 1.00
Pointer_Object_Try_Traverse 52.36549571406911 ns/iter 52.357129476188504 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 295.62387604684784 ns/iter 308.51627054204283 ns/iter 0.96

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (windows/msvc)

Benchmark suite Current: eeee8b4 Previous: 8cf5a49 Ratio
Regex_Lower_S_Or_Upper_S_Asterisk 6.848189285713196 ns/iter 7.24306808035686 ns/iter 0.95
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 6.937060267855344 ns/iter 6.903044642856214 ns/iter 1.00
Regex_Period_Asterisk 7.117039062501464 ns/iter 7.315520056630072 ns/iter 0.97
Regex_Group_Period_Asterisk_Group 6.829004464286977 ns/iter 7.019067825807428 ns/iter 0.97
Regex_Period_Plus 7.406154017855573 ns/iter 7.697251304924719 ns/iter 0.96
Regex_Period 7.33842184223911 ns/iter 7.697978794641053 ns/iter 0.95
Regex_Caret_Period_Plus_Dollar 7.155025669641293 ns/iter 7.465769163100739 ns/iter 0.96
Regex_Caret_Group_Period_Plus_Group_Dollar 7.271935267856934 ns/iter 7.185964285714164 ns/iter 1.01
Regex_Caret_Period_Asterisk_Dollar 6.917888392857309 ns/iter 7.172145503696643 ns/iter 0.96
Regex_Caret_Group_Period_Asterisk_Group_Dollar 6.965229464285016 ns/iter 6.890382812499191 ns/iter 1.01
Regex_Caret_X_Hyphen 11.778487500002655 ns/iter 11.797003571428734 ns/iter 1.00
Regex_Period_Md_Dollar 150.4613839285542 ns/iter 150.34085489550088 ns/iter 1.00
Regex_Caret_Slash_Period_Asterisk 10.442978124999058 ns/iter 10.842842187500423 ns/iter 0.96
Regex_Caret_Period_Range_Dollar 7.493752198689184 ns/iter 7.719560267859091 ns/iter 0.97
Regex_Nested_Backtrack 605.7165178570959 ns/iter 649.7722321427091 ns/iter 0.93
JSON_Array_Of_Objects_Unique 521.1084000000028 ns/iter 490.42293557595747 ns/iter 1.06
JSON_Parse_1 81933.06919643817 ns/iter 80885.9381277624 ns/iter 1.01
JSON_Fast_Hash_Helm_Chart_Lock 71.06539285712999 ns/iter 62.425937500003265 ns/iter 1.14
JSON_Equality_Helm_Chart_Lock 190.73224917256536 ns/iter 185.69874681018902 ns/iter 1.03
JSON_String_Equal/10 8.988910674154537 ns/iter 9.060500852411069 ns/iter 0.99
JSON_String_Equal/100 9.921728125000584 ns/iter 10.03044999999858 ns/iter 0.99
JSON_String_Equal_Small_By_Perfect_Hash/10 2.1711937500001 ns/iter 2.16822500000049 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 14.595638392858998 ns/iter 15.290882279387597 ns/iter 0.95
JSON_String_Fast_Hash/10 4.047149560798574 ns/iter 4.030949471484057 ns/iter 1.00
JSON_String_Fast_Hash/100 4.024541167900606 ns/iter 4.024913757186968 ns/iter 1.00
JSON_String_Key_Hash/10 8.000974517852038 ns/iter 8.000596839284164 ns/iter 1.00
JSON_String_Key_Hash/100 4.0376630429245575 ns/iter 4.0305541294648 ns/iter 1.00
JSON_Object_Defines_Miss_Same_Length 3.7240071362072236 ns/iter 3.724511243349552 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 4.9718719999987115 ns/iter 4.9622619999991 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Large 3.440082538499864 ns/iter 3.403632405395875 ns/iter 1.01
Pointer_Object_Traverse 50.60863999999583 ns/iter 50.38366000001133 ns/iter 1.00
Pointer_Object_Try_Traverse 67.66316964284361 ns/iter 67.52850000000063 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 182.50236450912308 ns/iter 178.62923294392743 ns/iter 1.02

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (macos/gcc)

Benchmark suite Current: eeee8b4 Previous: 8cf5a49 Ratio
Regex_Lower_S_Or_Upper_S_Asterisk 1.9775467675749383 ns/iter 2.1474114065616297 ns/iter 0.92
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 1.9815095212805114 ns/iter 2.097186850711712 ns/iter 0.94
Regex_Period_Asterisk 1.9007176336790017 ns/iter 2.104534677862823 ns/iter 0.90
Regex_Group_Period_Asterisk_Group 2.0863586954698823 ns/iter 2.1477959861472034 ns/iter 0.97
Regex_Period_Plus 2.741259582632124 ns/iter 2.106017485637286 ns/iter 1.30
Regex_Period 2.1043798957412183 ns/iter 2.1471174639873305 ns/iter 0.98
Regex_Caret_Period_Plus_Dollar 2.091920562348601 ns/iter 2.477149789943814 ns/iter 0.84
Regex_Caret_Group_Period_Plus_Group_Dollar 1.9713966899053583 ns/iter 2.153035969708371 ns/iter 0.92
Regex_Caret_Period_Asterisk_Dollar 2.160401478303646 ns/iter 2.1077532788910704 ns/iter 1.02
Regex_Caret_Group_Period_Asterisk_Group_Dollar 2.416267927768212 ns/iter 2.449274790967231 ns/iter 0.99
Regex_Caret_X_Hyphen 6.627031176475574 ns/iter 7.358027784551672 ns/iter 0.90
Regex_Period_Md_Dollar 76.62784787795925 ns/iter 79.35266264829255 ns/iter 0.97
Regex_Caret_Slash_Period_Asterisk 4.6852978945564585 ns/iter 5.125080256705062 ns/iter 0.91
Regex_Caret_Period_Range_Dollar 1.9607279775558117 ns/iter 2.094043830778999 ns/iter 0.94
Regex_Nested_Backtrack 843.3256077166175 ns/iter 879.9034618945302 ns/iter 0.96
JSON_Array_Of_Objects_Unique 218.6498051968864 ns/iter 234.61476147545105 ns/iter 0.93
JSON_Parse_1 23838.17808574992 ns/iter 25499.527461027996 ns/iter 0.93
JSON_Fast_Hash_Helm_Chart_Lock 24.394426363415388 ns/iter 26.62064859441013 ns/iter 0.92
JSON_Equality_Helm_Chart_Lock 118.91069340343599 ns/iter 126.48953626974541 ns/iter 0.94
JSON_String_Equal/10 5.722924343804009 ns/iter 5.776251818090912 ns/iter 0.99
JSON_String_Equal/100 5.354344762190323 ns/iter 5.54141518039224 ns/iter 0.97
JSON_String_Equal_Small_By_Perfect_Hash/10 0.8141188089566251 ns/iter 0.801659643317213 ns/iter 1.02
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 3.6705832530238665 ns/iter 3.7319907230811404 ns/iter 0.98
JSON_String_Fast_Hash/10 2.007866434191008 ns/iter 2.0311515513602623 ns/iter 0.99
JSON_String_Fast_Hash/100 1.9580395168619087 ns/iter 2.0411049611975653 ns/iter 0.96
JSON_String_Key_Hash/10 1.4362981128128565 ns/iter 1.5527776129163937 ns/iter 0.92
JSON_String_Key_Hash/100 1.9252299082431414 ns/iter 2.0730944322752256 ns/iter 0.93
JSON_Object_Defines_Miss_Same_Length 1.7241320811771217 ns/iter 1.9022250347431315 ns/iter 0.91
JSON_Object_Defines_Miss_Too_Small 1.8814336928115438 ns/iter 2.04070451461554 ns/iter 0.92
JSON_Object_Defines_Miss_Too_Large 1.7236810369418731 ns/iter 2.369642906381747 ns/iter 0.73
Pointer_Object_Traverse 54.08054521630487 ns/iter 69.58990923492337 ns/iter 0.78
Pointer_Object_Try_Traverse 36.46296678134313 ns/iter 38.753988591279374 ns/iter 0.94
Pointer_Push_Back_Pointer_To_Weak_Pointer 165.14505028220867 ns/iter 167.29791605641006 ns/iter 0.99

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (linux/gcc)

Benchmark suite Current: eeee8b4 Previous: 8cf5a49 Ratio
Pointer_Object_Traverse 47.42922090772828 ns/iter 46.71411734798 ns/iter 1.02
Pointer_Object_Try_Traverse 26.140447423766194 ns/iter 26.14048997993231 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 145.09313957607228 ns/iter 145.31897559497136 ns/iter 1.00
JSON_Array_Of_Objects_Unique 412.278373934213 ns/iter 413.42395277071915 ns/iter 1.00
JSON_Parse_1 33514.63315451741 ns/iter 33385.22039848418 ns/iter 1.00
JSON_Fast_Hash_Helm_Chart_Lock 62.604196760388994 ns/iter 69.07388741767379 ns/iter 0.91
JSON_Equality_Helm_Chart_Lock 155.41379053811733 ns/iter 149.26452424409166 ns/iter 1.04
JSON_String_Equal/10 6.345650765284901 ns/iter 6.3403048631384245 ns/iter 1.00
JSON_String_Equal/100 6.959308775192976 ns/iter 6.963749028481358 ns/iter 1.00
JSON_String_Equal_Small_By_Perfect_Hash/10 0.9354138145919799 ns/iter 0.9354327199278691 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 14.301061794932604 ns/iter 14.289882425946328 ns/iter 1.00
JSON_String_Fast_Hash/10 0.934107881897671 ns/iter 0.9342627895567384 ns/iter 1.00
JSON_String_Fast_Hash/100 0.9331749462058775 ns/iter 0.932895891227248 ns/iter 1.00
JSON_String_Key_Hash/10 1.6823855385306303 ns/iter 1.6716531927153484 ns/iter 1.01
JSON_String_Key_Hash/100 1.982661164724045 ns/iter 1.9834161416244755 ns/iter 1.00
JSON_Object_Defines_Miss_Same_Length 2.4861200932604657 ns/iter 2.4890638744520786 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 2.493268337228044 ns/iter 2.48705927605561 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Large 3.1077040305454076 ns/iter 3.109234691331528 ns/iter 1.00
Regex_Lower_S_Or_Upper_S_Asterisk 3.4239330505716 ns/iter 3.4198182886389636 ns/iter 1.00
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 3.4237884840221047 ns/iter 3.4187201887066236 ns/iter 1.00
Regex_Period_Asterisk 3.4254418758036063 ns/iter 3.420889915103344 ns/iter 1.00
Regex_Group_Period_Asterisk_Group 3.4187849066785683 ns/iter 3.4224694944648495 ns/iter 1.00
Regex_Period_Plus 3.7361456486782294 ns/iter 3.732624775676041 ns/iter 1.00
Regex_Period 3.4332139012992164 ns/iter 3.7303412661503 ns/iter 0.92
Regex_Caret_Period_Plus_Dollar 3.4236967898583783 ns/iter 3.7357351956493456 ns/iter 0.92
Regex_Caret_Group_Period_Plus_Group_Dollar 3.435638237607592 ns/iter 3.7310337523264856 ns/iter 0.92
Regex_Caret_Period_Asterisk_Dollar 3.7366243792150575 ns/iter 4.1000549445494885 ns/iter 0.91
Regex_Caret_Group_Period_Asterisk_Group_Dollar 3.731207123182937 ns/iter 3.4232389819670206 ns/iter 1.09
Regex_Caret_X_Hyphen 13.118059189297366 ns/iter 12.438545401603536 ns/iter 1.05
Regex_Period_Md_Dollar 89.18252972071971 ns/iter 89.67561540643806 ns/iter 0.99
Regex_Caret_Slash_Period_Asterisk 8.087251057690779 ns/iter 7.000837346067002 ns/iter 1.16
Regex_Caret_Period_Range_Dollar 3.7485553856067773 ns/iter 3.419181450041491 ns/iter 1.10
Regex_Nested_Backtrack 833.9326712895022 ns/iter 817.1496088193188 ns/iter 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.