From edd19a4a369b5760bca58523fa834563173c6dd5 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 8 Jun 2026 13:50:48 -0400 Subject: [PATCH 1/2] Upgrade Core and Blaze Signed-off-by: Juan Cruz Viotti --- DEPENDENCIES | 4 +- cmake/FindBlaze.cmake | 3 + cmake/FindCore.cmake | 13 +- config.cmake.in | 2 +- src/compiler/mapper/enum_8_bit.h | 2 +- src/compiler/mapper/enum_8_bit_top_level.h | 2 +- src/compiler/mapper/enum_arbitrary.h | 2 +- src/compiler/mapper/enum_singleton.h | 2 +- src/compiler/mapper/integer_bounded_8_bit.h | 2 +- .../integer_bounded_greater_than_8_bit.h | 2 +- .../mapper/integer_bounded_multiplier_8_bit.h | 2 +- ...er_bounded_multiplier_greater_than_8_bit.h | 2 +- src/compiler/mapper/integer_lower_bound.h | 2 +- .../mapper/integer_lower_bound_multiplier.h | 2 +- src/compiler/mapper/integer_unbound.h | 2 +- .../mapper/integer_unbound_multiplier.h | 2 +- src/compiler/mapper/integer_upper_bound.h | 2 +- .../mapper/integer_upper_bound_multiplier.h | 2 +- src/compiler/mapper/number_arbitrary.h | 2 +- test/runtime/CMakeLists.txt | 2 - test/runtime/decode_any_test.cc | 167 +- test/runtime/decode_array_test.cc | 33 +- test/runtime/decode_integer_test.cc | 44 +- test/runtime/decode_number_test.cc | 36 +- test/runtime/decode_object_test.cc | 8 +- test/runtime/decode_string_test.cc | 46 +- test/runtime/decode_test.cc | 8 +- test/runtime/decode_utils.h | 29 - test/runtime/encode_any_test.cc | 1630 +++++++++++------ test/runtime/encode_array_test.cc | 87 +- test/runtime/encode_integer_test.cc | 98 +- test/runtime/encode_number_test.cc | 98 +- test/runtime/encode_object_test.cc | 56 +- test/runtime/encode_string_test.cc | 149 +- test/runtime/encode_test.cc | 15 +- test/runtime/encode_utils.h | 65 - test/runtime/input_stream_varint_test.cc | 16 +- test/runtime/output_stream_varint_test.cc | 44 +- vendor/blaze/DEPENDENCIES | 4 +- vendor/blaze/config.cmake.in | 4 +- .../0001-draft3-ref-sibling.patch | 26 - vendor/blaze/ports/javascript/README.md | 4 + vendor/blaze/ports/javascript/describe.mjs | 39 +- vendor/blaze/src/alterschema/alterschema.cc | 4 + .../canonicalizer/additional_items_implicit.h | 2 +- .../allof_merge_compatible_branches.h | 2 +- .../alterschema/canonicalizer/comment_drop.h | 2 +- .../alterschema/canonicalizer/const_as_enum.h | 2 +- .../canonicalizer/dependencies_to_any_of.h | 2 +- .../dependencies_to_extends_disallow.h | 2 +- .../dependent_required_to_any_of.h | 2 +- .../dependent_schemas_to_any_of.h | 2 +- .../canonicalizer/deprecated_false_drop.h | 2 +- .../disallow_to_array_of_schemas.h | 2 +- .../canonicalizer/divisible_by_implicit.h | 2 +- .../canonicalizer/draft3_type_any.h | 2 +- .../canonicalizer/empty_definitions_drop.h | 2 +- .../canonicalizer/empty_defs_drop.h | 2 +- .../canonicalizer/empty_dependencies_drop.h | 2 +- .../empty_dependent_required_drop.h | 2 +- .../empty_dependent_schemas_drop.h | 2 +- .../enum_drop_redundant_validation.h | 2 +- .../canonicalizer/enum_filter_by_type.h | 2 +- .../exclusive_maximum_boolean_integer_fold.h | 2 +- .../exclusive_maximum_integer_to_maximum.h | 2 +- .../exclusive_minimum_boolean_integer_fold.h | 2 +- .../exclusive_minimum_integer_to_minimum.h | 2 +- .../canonicalizer/extends_to_array.h | 2 +- .../canonicalizer/if_then_else_implicit.h | 2 +- .../implicit_contains_keywords.h | 2 +- .../canonicalizer/implicit_object_keywords.h | 2 +- .../canonicalizer/inline_single_use_ref.h | 2 +- .../canonicalizer/items_implicit.h | 2 +- .../max_contains_covered_by_max_items.h | 2 +- .../canonicalizer/max_decimal_implicit.h | 2 +- .../maximum_can_equal_integer_fold.h | 2 +- .../maximum_can_equal_true_drop.h | 2 +- .../min_items_given_min_contains.h | 2 +- .../canonicalizer/min_length_implicit.h | 2 +- .../min_properties_covered_by_required.h | 2 +- .../minimum_can_equal_integer_fold.h | 2 +- .../minimum_can_equal_true_drop.h | 2 +- .../canonicalizer/multiple_of_implicit.h | 2 +- .../optional_property_implicit.h | 2 +- .../recursive_anchor_false_drop.h | 2 +- .../required_property_implicit.h | 2 +- .../canonicalizer/single_branch_allof.h | 2 +- .../canonicalizer/single_branch_anyof.h | 2 +- .../canonicalizer/single_branch_oneof.h | 2 +- .../canonicalizer/type_array_to_any_of.h | 2 +- .../canonicalizer/type_boolean_as_enum.h | 2 +- .../canonicalizer/type_inherit_in_place.h | 2 +- .../canonicalizer/type_null_as_enum.h | 2 +- .../canonicalizer/type_union_implicit.h | 2 +- .../canonicalizer/type_union_to_schemas.h | 2 +- .../type_with_applicator_to_allof.h | 2 +- .../type_with_applicator_to_extends.h | 2 +- .../unevaluated_items_to_items.h | 2 +- ...ated_properties_to_additional_properties.h | 2 +- .../unsatisfiable_can_equal_bounds.h | 2 +- .../unsatisfiable_exclusive_equal_bounds.h | 2 +- .../unsatisfiable_type_and_enum.h | 2 +- .../alterschema/common/allof_false_simplify.h | 2 +- .../alterschema/common/anyof_false_simplify.h | 2 +- .../common/anyof_remove_false_schemas.h | 2 +- .../alterschema/common/anyof_true_simplify.h | 2 +- .../src/alterschema/common/const_in_enum.h | 2 +- .../src/alterschema/common/const_with_type.h | 2 +- .../content_media_type_without_encoding.h | 2 +- .../content_schema_without_media_type.h | 2 +- .../common/dependencies_property_tautology.h | 2 +- .../common/dependent_required_tautology.h | 2 +- .../common/disallow_narrows_type.h | 2 +- .../common/double_negation_elimination.h | 2 +- .../draft_official_dialect_with_https.h | 2 +- ..._official_dialect_without_empty_fragment.h | 3 +- .../alterschema/common/draft_ref_siblings.h | 2 +- .../common/drop_allof_empty_schemas.h | 2 +- .../common/drop_extends_empty_schemas.h | 2 +- .../common/duplicate_allof_branches.h | 2 +- .../common/duplicate_anyof_branches.h | 2 +- .../common/duplicate_enum_values.h | 2 +- .../common/duplicate_required_values.h | 2 +- .../common/dynamic_ref_to_static_ref.h | 2 +- .../src/alterschema/common/else_without_if.h | 2 +- .../alterschema/common/empty_object_as_true.h | 2 +- .../src/alterschema/common/enum_with_type.h | 2 +- .../common/equal_numeric_bounds_to_enum.h | 2 +- .../common/exclusive_bounds_false_drop.h | 2 +- .../exclusive_maximum_number_and_maximum.h | 2 +- .../exclusive_minimum_number_and_minimum.h | 2 +- .../alterschema/common/flatten_nested_allof.h | 2 +- .../alterschema/common/flatten_nested_anyof.h | 2 +- .../common/flatten_nested_extends.h | 2 +- .../alterschema/common/if_without_then_else.h | 2 +- .../alterschema/common/ignored_metaschema.h | 2 +- .../common/max_contains_without_contains.h | 2 +- .../common/maximum_real_for_integer.h | 2 +- .../common/min_contains_without_contains.h | 2 +- .../common/minimum_real_for_integer.h | 2 +- ...ern_official_dialect_with_empty_fragment.h | 3 +- .../modern_official_dialect_with_http.h | 2 +- .../common/non_applicable_additional_items.h | 2 +- .../common/non_applicable_disallow_types.h | 2 +- .../non_applicable_enum_validation_keywords.h | 2 +- .../non_applicable_type_specific_keywords.h | 2 +- .../blaze/src/alterschema/common/not_false.h | 2 +- .../alterschema/common/oneof_false_simplify.h | 2 +- .../common/oneof_to_anyof_disjoint_types.h | 2 +- .../alterschema/common/orphan_definitions.h | 2 +- .../required_properties_in_properties.h | 2 +- .../alterschema/common/single_type_array.h | 2 +- .../src/alterschema/common/then_without_if.h | 2 +- .../common/unknown_keywords_prefix.h | 4 +- .../alterschema/common/unknown_local_ref.h | 2 +- .../unnecessary_allof_ref_wrapper_draft.h | 2 +- .../common/unnecessary_extends_ref_wrapper.h | 2 +- .../common/unsatisfiable_drop_validation.h | 2 +- .../unsatisfiable_in_place_applicator_type.h | 2 +- .../include/sourcemeta/blaze/alterschema.h | 14 +- .../blaze/alterschema_transformer.h | 28 +- .../src/alterschema/linter/comment_trim.h | 2 +- .../linter/conflicting_readonly_writeonly.h | 2 +- .../alterschema/linter/const_not_in_enum.h | 2 +- .../linter/content_schema_default.h | 2 +- .../alterschema/linter/definitions_to_defs.h | 2 +- .../alterschema/linter/dependencies_default.h | 2 +- .../linter/dependent_required_default.h | 2 +- .../linter/description_trailing_period.h | 2 +- .../src/alterschema/linter/description_trim.h | 2 +- .../src/alterschema/linter/disallow_default.h | 2 +- .../alterschema/linter/divisible_by_default.h | 2 +- .../alterschema/linter/duplicate_examples.h | 2 +- .../blaze/src/alterschema/linter/else_empty.h | 2 +- .../src/alterschema/linter/enum_to_const.h | 2 +- .../linter/equal_numeric_bounds_to_const.h | 2 +- .../alterschema/linter/forbid_empty_enum.h | 2 +- .../linter/incoherent_min_max_contains.h | 2 +- .../alterschema/linter/invalid_external_ref.h | 4 +- .../alterschema/linter/items_array_default.h | 2 +- .../alterschema/linter/items_schema_default.h | 2 +- .../alterschema/linter/multiple_of_default.h | 2 +- .../linter/pattern_non_ecma_regex.h | 46 + .../linter/pattern_properties_default.h | 2 +- .../pattern_properties_non_ecma_regex.h | 48 + .../linter/portable_anchor_names.h | 2 +- .../alterschema/linter/properties_default.h | 2 +- .../linter/property_names_default.h | 2 +- .../linter/property_names_type_default.h | 2 +- .../linter/simple_properties_identifiers.h | 2 +- .../blaze/src/alterschema/linter/then_empty.h | 2 +- .../linter/title_description_equal.h | 2 +- .../linter/title_trailing_period.h | 2 +- .../blaze/src/alterschema/linter/title_trim.h | 2 +- .../linter/top_level_description.h | 2 +- .../alterschema/linter/top_level_examples.h | 2 +- .../src/alterschema/linter/top_level_title.h | 2 +- .../linter/unevaluated_items_default.h | 2 +- .../linter/unevaluated_properties_default.h | 2 +- .../linter/unknown_format_prefix.h | 2 +- .../unnecessary_allof_ref_wrapper_modern.h | 2 +- .../linter/unnecessary_allof_wrapper.h | 4 +- .../linter/unnecessary_extends_wrapper.h | 4 +- .../linter/unsatisfiable_max_contains.h | 2 +- .../linter/unsatisfiable_min_properties.h | 2 +- .../src/alterschema/linter/valid_default.h | 2 +- .../src/alterschema/linter/valid_examples.h | 2 +- vendor/blaze/src/alterschema/schema_rule.cc | 4 +- vendor/blaze/src/alterschema/transformer.cc | 38 +- .../prefix_promoted_2020_12_keywords.h | 2 +- .../prefix_promoted_draft_2019_09_keywords.h | 2 +- .../prefix_promoted_draft_4_keywords.h | 2 +- .../prefix_promoted_draft_6_keywords.h | 2 +- .../prefix_promoted_draft_7_keywords.h | 2 +- .../upgrade/upgrade_2019_09_to_2020_12.h | 93 +- .../upgrade_dialect_override_cleanup.h | 2 +- .../upgrade/upgrade_draft_3_to_draft_4.h | 2 +- .../upgrade/upgrade_draft_4_to_draft_6.h | 2 +- .../upgrade/upgrade_draft_6_to_draft_7.h | 2 +- .../upgrade_draft_7_to_draft_2019_09.h | 98 +- vendor/blaze/src/compiler/default_compiler.cc | 3 + .../src/compiler/default_compiler_draft3.h | 158 +- vendor/blaze/src/evaluator/CMakeLists.txt | 4 + .../blaze/src/evaluator/evaluator_describe.cc | 138 +- .../sourcemeta/blaze/evaluator_dispatch.h | 39 + .../sourcemeta/blaze/evaluator_value.h | 14 +- vendor/blaze/src/foundation/foundation.cc | 10 +- vendor/core/CMakeLists.txt | 18 + vendor/core/cmake/FindPCRE2.cmake | 2 + .../core/cmake/common/compiler/options.cmake | 38 +- vendor/core/config.cmake.in | 16 + vendor/core/src/core/crypto/CMakeLists.txt | 4 +- vendor/core/src/core/crypto/crypto_crc32.cc | 48 + .../crypto/include/sourcemeta/core/crypto.h | 1 + .../include/sourcemeta/core/crypto_crc32.h | 45 + vendor/core/src/core/css/CMakeLists.txt | 9 + vendor/core/src/core/css/css2_color.cc | 235 +++ .../core/css/include/sourcemeta/core/css.h | 128 ++ vendor/core/src/core/dns/hostname.cc | 16 + vendor/core/src/core/http/CMakeLists.txt | 12 + .../core/src/core/http/accept_includes_all.cc | 50 + .../src/core/http/content_type_matches.cc | 17 + vendor/core/src/core/http/field_list.cc | 29 + vendor/core/src/core/http/format_link.cc | 83 + vendor/core/src/core/http/from_date.cc | 21 + vendor/core/src/core/http/helpers.h | 243 +++ .../core/http/include/sourcemeta/core/http.h | 252 +++ .../include/sourcemeta/core/http_problem.h | 44 + .../include/sourcemeta/core/http_status.h | 391 ++++ vendor/core/src/core/http/match_accept.cc | 66 + .../src/core/http/match_accept_language.cc | 88 + .../core/src/core/http/negotiate_encoding.cc | 80 + vendor/core/src/core/http/problem.cc | 53 + vendor/core/src/core/idna/codegen.cc | 16 +- .../jsonrpc/include/sourcemeta/core/jsonrpc.h | 31 + vendor/core/src/core/jsonrpc/jsonrpc.cc | 8 + .../core/mcp/include/sourcemeta/core/mcp.h | 15 +- vendor/core/src/core/mcp/mcp.cc | 6 +- vendor/core/src/core/time/CMakeLists.txt | 5 +- vendor/core/src/core/time/asctime.cc | 87 + vendor/core/src/core/time/gmt.cc | 56 - vendor/core/src/core/time/imf_fixdate.cc | 82 + .../core/time/include/sourcemeta/core/time.h | 131 +- .../time/rfc3339_partialtime_no_secfrac.cc | 59 + vendor/core/src/core/time/rfc850_date.cc | 125 ++ vendor/core/src/core/unicode/codegen.cc | 749 ++++---- vendor/core/src/core/uri/CMakeLists.txt | 4 + vendor/core/src/core/uri/canonicalize.cc | 20 +- .../core/uri/include/sourcemeta/core/uri.h | 46 +- vendor/core/src/core/uri/parse.cc | 182 +- .../core/uritemplate/uritemplate_router.cc | 158 +- .../uritemplate/uritemplate_router_view.cc | 75 +- vendor/core/src/lang/io/CMakeLists.txt | 4 +- .../src/lang/io/include/sourcemeta/core/io.h | 1 + .../include/sourcemeta/core/io_bytestream.h | 65 + vendor/core/src/lang/io/io_bytestream.cc | 36 + .../include/sourcemeta/core/numeric_parse.h | 10 +- .../include/sourcemeta/core/numeric_util.h | 21 + vendor/core/src/lang/numeric/parse.cc | 12 + .../lang/text/include/sourcemeta/core/text.h | 118 +- vendor/core/src/lang/text/text.cc | 16 +- 281 files changed, 5850 insertions(+), 2122 deletions(-) delete mode 100644 test/runtime/decode_utils.h delete mode 100644 test/runtime/encode_utils.h delete mode 100644 vendor/blaze/patches/jsonschema-test-suite/0001-draft3-ref-sibling.patch create mode 100644 vendor/blaze/src/alterschema/linter/pattern_non_ecma_regex.h create mode 100644 vendor/blaze/src/alterschema/linter/pattern_properties_non_ecma_regex.h create mode 100644 vendor/core/src/core/crypto/crypto_crc32.cc create mode 100644 vendor/core/src/core/crypto/include/sourcemeta/core/crypto_crc32.h create mode 100644 vendor/core/src/core/css/CMakeLists.txt create mode 100644 vendor/core/src/core/css/css2_color.cc create mode 100644 vendor/core/src/core/css/include/sourcemeta/core/css.h create mode 100644 vendor/core/src/core/http/CMakeLists.txt create mode 100644 vendor/core/src/core/http/accept_includes_all.cc create mode 100644 vendor/core/src/core/http/content_type_matches.cc create mode 100644 vendor/core/src/core/http/field_list.cc create mode 100644 vendor/core/src/core/http/format_link.cc create mode 100644 vendor/core/src/core/http/from_date.cc create mode 100644 vendor/core/src/core/http/helpers.h create mode 100644 vendor/core/src/core/http/include/sourcemeta/core/http.h create mode 100644 vendor/core/src/core/http/include/sourcemeta/core/http_problem.h create mode 100644 vendor/core/src/core/http/include/sourcemeta/core/http_status.h create mode 100644 vendor/core/src/core/http/match_accept.cc create mode 100644 vendor/core/src/core/http/match_accept_language.cc create mode 100644 vendor/core/src/core/http/negotiate_encoding.cc create mode 100644 vendor/core/src/core/http/problem.cc create mode 100644 vendor/core/src/core/time/asctime.cc delete mode 100644 vendor/core/src/core/time/gmt.cc create mode 100644 vendor/core/src/core/time/imf_fixdate.cc create mode 100644 vendor/core/src/core/time/rfc3339_partialtime_no_secfrac.cc create mode 100644 vendor/core/src/core/time/rfc850_date.cc create mode 100644 vendor/core/src/lang/io/include/sourcemeta/core/io_bytestream.h create mode 100644 vendor/core/src/lang/io/io_bytestream.cc diff --git a/DEPENDENCIES b/DEPENDENCIES index 756d9aab4..6590681f7 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,4 +1,4 @@ vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02 -core https://github.com/sourcemeta/core e586f557af367c74d08d2818bc4bd0d07c8b20bc -blaze https://github.com/sourcemeta/blaze bc1f434acafd38803f58a941a756a6f788e556e2 +core https://github.com/sourcemeta/core 9a8c6370c53b4b3b24f4ba0caa2d897a5094ff4e +blaze https://github.com/sourcemeta/blaze 4c311d45803eaeeb17cbd49af4fffdb5f224d180 bootstrap https://github.com/twbs/bootstrap 1a6fdfae6be09b09eaced8f0e442ca6f7680a61e diff --git a/cmake/FindBlaze.cmake b/cmake/FindBlaze.cmake index 73d4f7bcd..53fb3fcc3 100644 --- a/cmake/FindBlaze.cmake +++ b/cmake/FindBlaze.cmake @@ -7,6 +7,9 @@ if(NOT Blaze_FOUND) set(BLAZE_TEST OFF CACHE BOOL "disable") set(BLAZE_CONFIGURATION OFF CACHE BOOL "disable") + set(BLAZE_CODEGEN OFF CACHE BOOL "disable") + set(BLAZE_DOCUMENTATION OFF CACHE BOOL "disable") + set(BLAZE_EDITOR OFF CACHE BOOL "disable") set(BLAZE_CONTRIB OFF CACHE BOOL "disable") add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/blaze") include(Sourcemeta) diff --git a/cmake/FindCore.cmake b/cmake/FindCore.cmake index 41c6c0e3e..6985accb1 100644 --- a/cmake/FindCore.cmake +++ b/cmake/FindCore.cmake @@ -5,13 +5,18 @@ if(NOT Core_FOUND) set(SOURCEMETA_CORE_INSTALL OFF CACHE BOOL "disable installation") endif() - set(SOURCEMETA_CORE_UUID OFF CACHE BOOL "disable") + set(SOURCEMETA_CORE_LANG_PROCESS OFF CACHE BOOL "disable") + set(SOURCEMETA_CORE_LANG_PARALLEL OFF CACHE BOOL "disable") + set(SOURCEMETA_CORE_LANG_ERROR OFF CACHE BOOL "disable") + set(SOURCEMETA_CORE_LANG_STACKTRACE OFF CACHE BOOL "disable") set(SOURCEMETA_CORE_GZIP OFF CACHE BOOL "disable") - set(SOURCEMETA_CORE_MD5 OFF CACHE BOOL "disable") set(SOURCEMETA_CORE_JSONL OFF CACHE BOOL "disable JSONL support") + set(SOURCEMETA_CORE_JSONRPC OFF CACHE BOOL "disable") + set(SOURCEMETA_CORE_MCP OFF CACHE BOOL "disable") + set(SOURCEMETA_CORE_HTTP OFF CACHE BOOL "disable") + set(SOURCEMETA_CORE_SEMVER OFF CACHE BOOL "disable") + set(SOURCEMETA_CORE_MARKDOWN OFF CACHE BOOL "disable") set(SOURCEMETA_CORE_YAML ON CACHE BOOL "needed by Blaze") - set(SOURCEMETA_CORE_EXTENSION_OPTIONS OFF CACHE BOOL "disable") - set(SOURCEMETA_CORE_EXTENSION_BUILD OFF CACHE BOOL "disable") set(SOURCEMETA_CORE_CONTRIB_GOOGLETEST ${JSONBINPACK_TESTS} CACHE BOOL "GoogleTest") set(SOURCEMETA_CORE_CONTRIB_GOOGLEBENCHMARK OFF CACHE BOOL "GoogleBenchmark") add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/core") diff --git a/config.cmake.in b/config.cmake.in index e24ed3748..93c76fb20 100644 --- a/config.cmake.in +++ b/config.cmake.in @@ -9,7 +9,7 @@ if(NOT JSONBINPACK_COMPONENTS) endif() include(CMakeFindDependencyMacro) -find_dependency(Core COMPONENTS numeric regex uri json jsonpointer io) +find_dependency(Core COMPONENTS json uri jsonpointer numeric regex io) find_dependency(Blaze COMPONENTS foundation bundle alterschema) foreach(component ${JSONBINPACK_COMPONENTS}) diff --git a/src/compiler/mapper/enum_8_bit.h b/src/compiler/mapper/enum_8_bit.h index ad16d83d0..ff54aa843 100644 --- a/src/compiler/mapper/enum_8_bit.h +++ b/src/compiler/mapper/enum_8_bit.h @@ -12,7 +12,7 @@ class Enum8Bit final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/enum_8_bit_top_level.h b/src/compiler/mapper/enum_8_bit_top_level.h index e4c17f960..0c0b348c4 100644 --- a/src/compiler/mapper/enum_8_bit_top_level.h +++ b/src/compiler/mapper/enum_8_bit_top_level.h @@ -12,7 +12,7 @@ class Enum8BitTopLevel final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/enum_arbitrary.h b/src/compiler/mapper/enum_arbitrary.h index ad6a258e9..31bfa5a33 100644 --- a/src/compiler/mapper/enum_arbitrary.h +++ b/src/compiler/mapper/enum_arbitrary.h @@ -13,7 +13,7 @@ class EnumArbitrary final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/enum_singleton.h b/src/compiler/mapper/enum_singleton.h index 1098253cc..d1c6d9062 100644 --- a/src/compiler/mapper/enum_singleton.h +++ b/src/compiler/mapper/enum_singleton.h @@ -12,7 +12,7 @@ class EnumSingleton final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_bounded_8_bit.h b/src/compiler/mapper/integer_bounded_8_bit.h index 6f2749cfc..651cd8572 100644 --- a/src/compiler/mapper/integer_bounded_8_bit.h +++ b/src/compiler/mapper/integer_bounded_8_bit.h @@ -12,7 +12,7 @@ class IntegerBounded8Bit final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_bounded_greater_than_8_bit.h b/src/compiler/mapper/integer_bounded_greater_than_8_bit.h index 99fca3fbf..87bc75bd8 100644 --- a/src/compiler/mapper/integer_bounded_greater_than_8_bit.h +++ b/src/compiler/mapper/integer_bounded_greater_than_8_bit.h @@ -14,7 +14,7 @@ class IntegerBoundedGreaterThan8Bit final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_bounded_multiplier_8_bit.h b/src/compiler/mapper/integer_bounded_multiplier_8_bit.h index 77b5c99a7..c63d73534 100644 --- a/src/compiler/mapper/integer_bounded_multiplier_8_bit.h +++ b/src/compiler/mapper/integer_bounded_multiplier_8_bit.h @@ -14,7 +14,7 @@ class IntegerBoundedMultiplier8Bit final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { if (location.dialect != "https://json-schema.org/draft/2020-12/schema" || !vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_bounded_multiplier_greater_than_8_bit.h b/src/compiler/mapper/integer_bounded_multiplier_greater_than_8_bit.h index d4133f992..73f6a4221 100644 --- a/src/compiler/mapper/integer_bounded_multiplier_greater_than_8_bit.h +++ b/src/compiler/mapper/integer_bounded_multiplier_greater_than_8_bit.h @@ -14,7 +14,7 @@ class IntegerBoundedMultiplierGreaterThan8Bit final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { if (location.dialect != "https://json-schema.org/draft/2020-12/schema" || !vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_lower_bound.h b/src/compiler/mapper/integer_lower_bound.h index e8dcceb61..b9c655ef2 100644 --- a/src/compiler/mapper/integer_lower_bound.h +++ b/src/compiler/mapper/integer_lower_bound.h @@ -12,7 +12,7 @@ class IntegerLowerBound final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_lower_bound_multiplier.h b/src/compiler/mapper/integer_lower_bound_multiplier.h index 82b385c64..f22b41bdf 100644 --- a/src/compiler/mapper/integer_lower_bound_multiplier.h +++ b/src/compiler/mapper/integer_lower_bound_multiplier.h @@ -14,7 +14,7 @@ class IntegerLowerBoundMultiplier final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_unbound.h b/src/compiler/mapper/integer_unbound.h index f157ba1bc..f3992eb68 100644 --- a/src/compiler/mapper/integer_unbound.h +++ b/src/compiler/mapper/integer_unbound.h @@ -12,7 +12,7 @@ class IntegerUnbound final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_unbound_multiplier.h b/src/compiler/mapper/integer_unbound_multiplier.h index afba029a4..3125434be 100644 --- a/src/compiler/mapper/integer_unbound_multiplier.h +++ b/src/compiler/mapper/integer_unbound_multiplier.h @@ -14,7 +14,7 @@ class IntegerUnboundMultiplier final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_upper_bound.h b/src/compiler/mapper/integer_upper_bound.h index 01f1fcfa5..b6be2d3e3 100644 --- a/src/compiler/mapper/integer_upper_bound.h +++ b/src/compiler/mapper/integer_upper_bound.h @@ -12,7 +12,7 @@ class IntegerUpperBound final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/integer_upper_bound_multiplier.h b/src/compiler/mapper/integer_upper_bound_multiplier.h index 3a38d2094..de962e64c 100644 --- a/src/compiler/mapper/integer_upper_bound_multiplier.h +++ b/src/compiler/mapper/integer_upper_bound_multiplier.h @@ -14,7 +14,7 @@ class IntegerUpperBoundMultiplier final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/src/compiler/mapper/number_arbitrary.h b/src/compiler/mapper/number_arbitrary.h index 006ff9fda..2b0822e4c 100644 --- a/src/compiler/mapper/number_arbitrary.h +++ b/src/compiler/mapper/number_arbitrary.h @@ -12,7 +12,7 @@ class NumberArbitrary final : public sourcemeta::blaze::SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> sourcemeta::blaze::SchemaTransformRule::Result override { return location.dialect == "https://json-schema.org/draft/2020-12/schema" && vocabularies.contains(sourcemeta::blaze::Vocabularies::Known:: diff --git a/test/runtime/CMakeLists.txt b/test/runtime/CMakeLists.txt index 6fa7c2493..5461044d4 100644 --- a/test/runtime/CMakeLists.txt +++ b/test/runtime/CMakeLists.txt @@ -9,7 +9,6 @@ sourcemeta_googletest(NAMESPACE sourcemeta PROJECT jsonbinpack NAME runtime decode_string_test.cc decode_test.cc decode_traits_test.cc - decode_utils.h encode_any_test.cc encode_array_test.cc encode_cache_test.cc @@ -20,7 +19,6 @@ sourcemeta_googletest(NAMESPACE sourcemeta PROJECT jsonbinpack NAME runtime encode_string_test.cc encode_test.cc encode_traits_test.cc - encode_utils.h input_stream_varint_test.cc output_stream_varint_test.cc encoding_traits_test.cc diff --git a/test/runtime/decode_any_test.cc b/test/runtime/decode_any_test.cc index 20f3674ec..a0db7c0cc 100644 --- a/test/runtime/decode_any_test.cc +++ b/test/runtime/decode_any_test.cc @@ -1,7 +1,5 @@ #include - -#include "decode_utils.h" - +#include #include #include @@ -10,7 +8,7 @@ #include TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_1__1_0_0) { - InputByteStream stream{0x00}; + sourcemeta::core::InputByteStream stream{0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(1); @@ -22,7 +20,7 @@ TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_1__1_0_0) { } TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_1__0_1_0) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(0); @@ -34,7 +32,7 @@ TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_1__0_1_0) { } TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_1__0_0_1) { - InputByteStream stream{0x02}; + sourcemeta::core::InputByteStream stream{0x02}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(0); @@ -46,7 +44,7 @@ TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_1__0_0_1) { } TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_bar__foo_bar_bar) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back("foo"); @@ -58,7 +56,7 @@ TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_bar__foo_bar_bar) { } TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_non_scalar_1) { - InputByteStream stream{0x03}; + sourcemeta::core::InputByteStream stream{0x03}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::parse_json("{ \"foo\": 2 }")); @@ -72,7 +70,7 @@ TEST(JSONBinPack_Decoder, BYTE_CHOICE_INDEX_non_scalar_1) { } TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_1__1_0_0) { - InputByteStream stream{0x00}; + sourcemeta::core::InputByteStream stream{0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(1); @@ -84,7 +82,7 @@ TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_1__1_0_0) { } TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_1__0_1_0) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(0); @@ -96,7 +94,7 @@ TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_1__0_1_0) { } TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_1__0_0_1) { - InputByteStream stream{0x02}; + sourcemeta::core::InputByteStream stream{0x02}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(0); @@ -108,7 +106,7 @@ TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_1__0_0_1) { } TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_bar__foo_bar_bar) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back("foo"); @@ -120,7 +118,7 @@ TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_bar__foo_bar_bar) { } TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_non_scalar_1) { - InputByteStream stream{0x03}; + sourcemeta::core::InputByteStream stream{0x03}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::parse_json("{ \"foo\": 2 }")); @@ -134,7 +132,7 @@ TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_non_scalar_1) { } TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_enum_250) { - InputByteStream stream{0xfa, 0x01}; + sourcemeta::core::InputByteStream stream{0xfa, 0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; @@ -148,7 +146,7 @@ TEST(JSONBinPack_Decoder, LARGE_CHOICE_INDEX_enum_250) { } TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__1_0_0) { - InputByteStream stream{}; + sourcemeta::core::InputByteStream stream{}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(1); @@ -160,7 +158,7 @@ TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__1_0_0) { } TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__0_1_0) { - InputByteStream stream{0x00}; + sourcemeta::core::InputByteStream stream{0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(0); @@ -172,7 +170,7 @@ TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__0_1_0) { } TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__0_0_1) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back(0); @@ -184,7 +182,7 @@ TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__0_0_1) { } TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_bar__foo_bar_bar) { - InputByteStream stream{0x00}; + sourcemeta::core::InputByteStream stream{0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.emplace_back("foo"); @@ -196,7 +194,7 @@ TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_bar__foo_bar_bar) { } TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_non_scalar_1) { - InputByteStream stream{0x02}; + sourcemeta::core::InputByteStream stream{0x02}; sourcemeta::jsonbinpack::Decoder decoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::parse_json("{ \"foo\": 2 }")); @@ -210,7 +208,7 @@ TEST(JSONBinPack_Decoder, TOP_LEVEL_BYTE_CHOICE_INDEX_non_scalar_1) { } TEST(JSONBinPack_Decoder, CONST_NONE_scalar) { - InputByteStream stream{}; + sourcemeta::core::InputByteStream stream{}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.CONST_NONE({sourcemeta::core::JSON{1}}); const sourcemeta::core::JSON expected{1}; @@ -218,7 +216,7 @@ TEST(JSONBinPack_Decoder, CONST_NONE_scalar) { } TEST(JSONBinPack_Decoder, CONST_NONE_complex) { - InputByteStream stream{}; + sourcemeta::core::InputByteStream stream{}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.CONST_NONE({sourcemeta::core::parse_json("{ \"foo\": 1 }")}); @@ -228,7 +226,7 @@ TEST(JSONBinPack_Decoder, CONST_NONE_complex) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__null) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x17}; + sourcemeta::core::InputByteStream stream{0x17}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{nullptr}; @@ -237,7 +235,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__null) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__false) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x07}; + sourcemeta::core::InputByteStream stream{0x07}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{false}; @@ -246,7 +244,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__false) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__true) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x0f}; + sourcemeta::core::InputByteStream stream{0x0f}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{true}; @@ -255,7 +253,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__true) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_3_14) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x2f, 0xf4, 0x04, 0x02}; + sourcemeta::core::InputByteStream stream{0x2f, 0xf4, 0x04, 0x02}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{3.14}; @@ -264,7 +262,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_3_14) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_3_0) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x37, 0x03}; + sourcemeta::core::InputByteStream stream{0x37, 0x03}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); EXPECT_TRUE(result.is_real()); @@ -277,7 +275,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_3_0) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_103_0) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x37, 0x67}; + sourcemeta::core::InputByteStream stream{0x37, 0x67}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); EXPECT_TRUE(result.is_real()); @@ -290,7 +288,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_103_0) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__256) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x1f, 0x80, 0x02}; + sourcemeta::core::InputByteStream stream{0x1f, 0x80, 0x02}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{256}; @@ -299,7 +297,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__256) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_257) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x27, 0x80, 0x02}; + sourcemeta::core::InputByteStream stream{0x27, 0x80, 0x02}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{-257}; @@ -308,7 +306,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_257) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__255) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x05, 0xff}; + sourcemeta::core::InputByteStream stream{0x05, 0xff}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{255}; @@ -317,7 +315,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__255) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_256) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x06, 0xff}; + sourcemeta::core::InputByteStream stream{0x06, 0xff}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{-256}; @@ -326,7 +324,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_256) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__0) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x0d}; + sourcemeta::core::InputByteStream stream{0x0d}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{0}; @@ -335,7 +333,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__0) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_1) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x0e}; + sourcemeta::core::InputByteStream stream{0x0e}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{-1}; @@ -344,7 +342,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_1) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_space) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x11, 0x20}; + sourcemeta::core::InputByteStream stream{0x11, 0x20}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{" "}; @@ -353,7 +351,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_space) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_foo) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x21, 0x66, 0x6f, 0x6f}; + sourcemeta::core::InputByteStream stream{0x21, 0x66, 0x6f, 0x6f}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{"foo"}; @@ -362,10 +360,10 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_foo) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_30_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0xf9, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}; + sourcemeta::core::InputByteStream stream{ + 0xf9, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{std::string(30, 'x')}; @@ -374,7 +372,8 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_30_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__shared_string_foo) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x21, 0x66, 0x6f, 0x6f, 0x20, 0x04, 0x20, 0x06}; + sourcemeta::core::InputByteStream stream{0x21, 0x66, 0x6f, 0x6f, + 0x20, 0x04, 0x20, 0x06}; Decoder decoder{stream}; const sourcemeta::core::JSON result1 = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); @@ -392,10 +391,10 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__shared_string_foo) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_31_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x02, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}; + sourcemeta::core::InputByteStream stream{ + 0x02, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{std::string(31, 'x')}; @@ -404,13 +403,13 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_31_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_61_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0xf2, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}; + sourcemeta::core::InputByteStream stream{ + 0xf2, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{std::string(61, 'x')}; @@ -419,10 +418,10 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_61_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_url) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, - 0x73, 0x6f, 0x75, 0x6e, 0x64, 0x63, 0x6c, 0x6f, 0x75, - 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x61, 0x6e, - 0x64, 0x79, 0x6d, 0x75, 0x73, 0x69, 0x63, 0x6e, 0x6c}; + sourcemeta::core::InputByteStream stream{ + 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x73, 0x6f, 0x75, + 0x6e, 0x64, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x64, 0x61, 0x6e, 0x64, 0x79, 0x6d, 0x75, 0x73, 0x69, 0x63, 0x6e, 0x6c}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); const sourcemeta::core::JSON expected{"https://soundcloud.com/dandymusicnl"}; @@ -431,7 +430,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_url) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_128_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x3f, 0x00, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -451,7 +450,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_128_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_130_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x3f, 0x02, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -471,7 +470,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_130_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_256_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x47, 0x00, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -505,7 +504,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_256_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_258_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x47, 0x02, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -539,7 +538,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_258_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_512_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x4f, 0x00, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -601,7 +600,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_512_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_513_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x4f, 0x01, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -664,7 +663,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_513_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_1024_xs) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x57, 0x00, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -778,7 +777,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_1024_xs) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_62_xs_non_shared) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x01, 0x01, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -794,7 +793,7 @@ TEST(JSONBinPack_Decoder, TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_63_xs_non_shared) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x01, 0x02, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, @@ -809,7 +808,8 @@ TEST(JSONBinPack_Decoder, TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__foo_true_2000) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x24, 0x21, 0x66, 0x6f, 0x6f, 0x0f, 0x1f, 0xd0, 0x0f}; + sourcemeta::core::InputByteStream stream{0x24, 0x21, 0x66, 0x6f, 0x6f, + 0x0f, 0x1f, 0xd0, 0x0f}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); @@ -823,10 +823,10 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__foo_true_2000) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_30) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0xfc, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}; + sourcemeta::core::InputByteStream stream{ + 0xfc, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); @@ -870,10 +870,10 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_30) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_31) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x04, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}; + sourcemeta::core::InputByteStream stream{ + 0x04, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); @@ -919,10 +919,10 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_31) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_32) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x04, 0x01, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}; + sourcemeta::core::InputByteStream stream{ + 0x04, 0x01, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); @@ -970,8 +970,9 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_32) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_foo_bar_baz_1) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x1b, 0x04, 0x66, 0x6f, 0x6f, 0x21, 0x62, - 0x61, 0x72, 0x04, 0x62, 0x61, 0x7a, 0x15}; + sourcemeta::core::InputByteStream stream{0x1b, 0x04, 0x66, 0x6f, 0x6f, + 0x21, 0x62, 0x61, 0x72, 0x04, + 0x62, 0x61, 0x7a, 0x15}; Decoder decoder{stream}; const auto result = decoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX({}); EXPECT_TRUE(result.is_object()); @@ -996,7 +997,7 @@ static auto is_member_true(const sourcemeta::core::JSON &object, TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_30_entries) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0xfb, 0x03, 0x30, 0x30, 0x0f, 0x03, 0x30, 0x31, 0x0f, 0x03, 0x30, 0x32, 0x0f, 0x03, 0x30, 0x33, 0x0f, 0x03, 0x30, 0x34, 0x0f, 0x03, 0x30, 0x35, 0x0f, 0x03, 0x30, 0x36, 0x0f, 0x03, 0x30, 0x37, 0x0f, @@ -1049,7 +1050,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_30_entries) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_31_entries) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x03, 0x00, 0x03, 0x30, 0x30, 0x0f, 0x03, 0x30, 0x31, 0x0f, 0x03, 0x30, 0x32, 0x0f, 0x03, 0x30, 0x33, 0x0f, 0x03, 0x30, 0x34, 0x0f, 0x03, 0x30, 0x35, 0x0f, 0x03, 0x30, 0x36, 0x0f, 0x03, 0x30, 0x37, 0x0f, 0x03, 0x30, @@ -1104,7 +1105,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_31_entries) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_32_entries) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x03, 0x01, 0x03, 0x30, 0x30, 0x0f, 0x03, 0x30, 0x31, 0x0f, 0x03, 0x30, 0x32, 0x0f, 0x03, 0x30, 0x33, 0x0f, 0x03, 0x30, 0x34, 0x0f, 0x03, 0x30, 0x35, 0x0f, 0x03, 0x30, 0x36, 0x0f, 0x03, 0x30, 0x37, 0x0f, 0x03, 0x30, @@ -1161,7 +1162,7 @@ TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_32_entries) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_62_xs_shared) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x1b, 0x04, 0x66, 0x6f, 0x6f, 0x01, 0x01, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, diff --git a/test/runtime/decode_array_test.cc b/test/runtime/decode_array_test.cc index b6638ce33..3c2d92901 100644 --- a/test/runtime/decode_array_test.cc +++ b/test/runtime/decode_array_test.cc @@ -1,7 +1,5 @@ #include - -#include "decode_utils.h" - +#include #include #include @@ -9,7 +7,7 @@ TEST(JSONBinPack_Decoder, FIXED_TYPED_ARRAY_0_1_2__no_prefix_encodings) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x00, 0x01, 0x02}; + sourcemeta::core::InputByteStream stream{0x00, 0x01, 0x02}; Decoder decoder{stream}; const auto result = decoder.FIXED_TYPED_ARRAY( {3, @@ -21,7 +19,7 @@ TEST(JSONBinPack_Decoder, FIXED_TYPED_ARRAY_0_1_2__no_prefix_encodings) { TEST(JSONBinPack_Decoder, FIXED_TYPED_ARRAY_0_1_true__semityped) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x00, 0x01, 0x01}; + sourcemeta::core::InputByteStream stream{0x00, 0x01, 0x01}; Decoder decoder{stream}; std::vector choices; @@ -42,7 +40,7 @@ TEST(JSONBinPack_Decoder, FIXED_TYPED_ARRAY_0_1_true__semityped) { TEST(JSONBinPack_Decoder, FIXED_TYPED_ARRAY_empty__no_prefix_encodings) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{}; + sourcemeta::core::InputByteStream stream{}; Decoder decoder{stream}; const auto result = decoder.FIXED_TYPED_ARRAY( {0, @@ -55,7 +53,7 @@ TEST(JSONBinPack_Decoder, FIXED_TYPED_ARRAY_empty__no_prefix_encodings) { TEST(JSONBinPack_Decoder, BOUNDED_8BITS_TYPED_ARRAY_true_false_true__no_prefix_encodings) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x03, 0x01, 0x00, 0x01}; + sourcemeta::core::InputByteStream stream{0x03, 0x01, 0x00, 0x01}; Decoder decoder{stream}; std::vector choices; @@ -75,7 +73,7 @@ TEST(JSONBinPack_Decoder, TEST(JSONBinPack_Decoder, BOUNDED_8BITS_TYPED_ARRAY_true_false_true__same_max_min) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x00, 0x01, 0x00, 0x01}; + sourcemeta::core::InputByteStream stream{0x00, 0x01, 0x00, 0x01}; Decoder decoder{stream}; std::vector choices; @@ -94,7 +92,7 @@ TEST(JSONBinPack_Decoder, TEST(JSONBinPack_Decoder, BOUNDED_8BITS_TYPED_ARRAY_true_false_5__1_3) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x02, 0x01, 0x00, 0x05}; + sourcemeta::core::InputByteStream stream{0x02, 0x01, 0x00, 0x05}; Decoder decoder{stream}; std::vector choices; @@ -113,7 +111,8 @@ TEST(JSONBinPack_Decoder, BOUNDED_8BITS_TYPED_ARRAY_true_false_5__1_3) { TEST(JSONBinPack_Decoder, BOUNDED_8BITS_TYPED_ARRAY_complex) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x03, 0x01, 0x01, 0x66, 0x6f, 0x6f, 0xfa, 0x01}; + sourcemeta::core::InputByteStream stream{0x03, 0x01, 0x01, 0x66, + 0x6f, 0x6f, 0xfa, 0x01}; Decoder decoder{stream}; std::vector choices; @@ -134,7 +133,7 @@ TEST(JSONBinPack_Decoder, BOUNDED_8BITS_TYPED_ARRAY_complex) { TEST(JSONBinPack_Decoder, FLOOR_TYPED_ARRAY_true_false_true__no_prefix_encodings) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x03, 0x01, 0x00, 0x01}; + sourcemeta::core::InputByteStream stream{0x03, 0x01, 0x00, 0x01}; Decoder decoder{stream}; std::vector choices; @@ -152,7 +151,7 @@ TEST(JSONBinPack_Decoder, TEST(JSONBinPack_Decoder, FLOOR_TYPED_ARRAY_true_false_5__1_3) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x02, 0x01, 0x00, 0x05}; + sourcemeta::core::InputByteStream stream{0x02, 0x01, 0x00, 0x05}; Decoder decoder{stream}; std::vector choices; @@ -170,7 +169,8 @@ TEST(JSONBinPack_Decoder, FLOOR_TYPED_ARRAY_true_false_5__1_3) { TEST(JSONBinPack_Decoder, FLOOR_TYPED_ARRAY_complex) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x03, 0x01, 0x01, 0x66, 0x6f, 0x6f, 0xfa, 0x01}; + sourcemeta::core::InputByteStream stream{0x03, 0x01, 0x01, 0x66, + 0x6f, 0x6f, 0xfa, 0x01}; Decoder decoder{stream}; std::vector choices; @@ -190,7 +190,7 @@ TEST(JSONBinPack_Decoder, FLOOR_TYPED_ARRAY_complex) { TEST(JSONBinPack_Decoder, ROOF_TYPED_ARRAY_true_false_true__no_prefix_encodings) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x03, 0x01, 0x00, 0x01}; + sourcemeta::core::InputByteStream stream{0x03, 0x01, 0x00, 0x01}; Decoder decoder{stream}; std::vector choices; @@ -208,7 +208,7 @@ TEST(JSONBinPack_Decoder, TEST(JSONBinPack_Decoder, ROOF_TYPED_ARRAY_true_false_5__1_3) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x02, 0x01, 0x00, 0x05}; + sourcemeta::core::InputByteStream stream{0x02, 0x01, 0x00, 0x05}; Decoder decoder{stream}; std::vector choices; @@ -226,7 +226,8 @@ TEST(JSONBinPack_Decoder, ROOF_TYPED_ARRAY_true_false_5__1_3) { TEST(JSONBinPack_Decoder, ROOF_TYPED_ARRAY_complex) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x03, 0x01, 0x01, 0x66, 0x6f, 0x6f, 0xfa, 0x01}; + sourcemeta::core::InputByteStream stream{0x03, 0x01, 0x01, 0x66, + 0x6f, 0x6f, 0xfa, 0x01}; Decoder decoder{stream}; std::vector choices; diff --git a/test/runtime/decode_integer_test.cc b/test/runtime/decode_integer_test.cc index 80ff1d61e..77ad0c901 100644 --- a/test/runtime/decode_integer_test.cc +++ b/test/runtime/decode_integer_test.cc @@ -1,7 +1,5 @@ #include - -#include "decode_utils.h" - +#include #include #include @@ -9,7 +7,7 @@ TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__minus_5_minus_5_minus_1_1) { - InputByteStream stream{0x00}; + sourcemeta::core::InputByteStream stream{0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED({-5, -1, 1}); const sourcemeta::core::JSON expected{-5}; @@ -17,7 +15,7 @@ TEST(JSONBinPack_Decoder, } TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__2_minus_5_5_1) { - InputByteStream stream{0x07}; + sourcemeta::core::InputByteStream stream{0x07}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED({-5, 5, 1}); const sourcemeta::core::JSON expected{2}; @@ -25,7 +23,7 @@ TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__2_minus_5_5_1) { } TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__5_2_8_1) { - InputByteStream stream{0x03}; + sourcemeta::core::InputByteStream stream{0x03}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED({2, 8, 1}); const sourcemeta::core::JSON expected{5}; @@ -33,7 +31,7 @@ TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__5_2_8_1) { } TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__5_1_19_5) { - InputByteStream stream{0x00}; + sourcemeta::core::InputByteStream stream{0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED({1, 19, 5}); const sourcemeta::core::JSON expected{5}; @@ -41,7 +39,7 @@ TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__5_1_19_5) { } TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__255_0_255_1) { - InputByteStream stream{0xff}; + sourcemeta::core::InputByteStream stream{0xff}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED({0, 255, 1}); const sourcemeta::core::JSON expected{255}; @@ -49,7 +47,7 @@ TEST(JSONBinPack_Decoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__255_0_255_1) { } TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__minus_3_minus_10_1) { - InputByteStream stream{0x07}; + sourcemeta::core::InputByteStream stream{0x07}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.FLOOR_MULTIPLE_ENUM_VARINT({-10, 1}); const sourcemeta::core::JSON expected{-3}; @@ -57,7 +55,7 @@ TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__minus_3_minus_10_1) { } TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__5_2_1) { - InputByteStream stream{0x03}; + sourcemeta::core::InputByteStream stream{0x03}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.FLOOR_MULTIPLE_ENUM_VARINT({2, 1}); const sourcemeta::core::JSON expected{5}; @@ -65,7 +63,7 @@ TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__5_2_1) { } TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__10_5_5) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.FLOOR_MULTIPLE_ENUM_VARINT({5, 5}); const sourcemeta::core::JSON expected{10}; @@ -73,7 +71,7 @@ TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__10_5_5) { } TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__10_2_5) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.FLOOR_MULTIPLE_ENUM_VARINT({2, 5}); const sourcemeta::core::JSON expected{10}; @@ -81,7 +79,7 @@ TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__10_2_5) { } TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__1000_minus_2_4) { - InputByteStream stream{0xfa, 0x01}; + sourcemeta::core::InputByteStream stream{0xfa, 0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.FLOOR_MULTIPLE_ENUM_VARINT({-2, 4}); const sourcemeta::core::JSON expected{1000}; @@ -89,7 +87,7 @@ TEST(JSONBinPack_Decoder, FLOOR_MULTIPLE_ENUM_VARINT__1000_minus_2_4) { } TEST(JSONBinPack_Decoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__minus_3_minus_2_1) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ROOF_MULTIPLE_MIRROR_ENUM_VARINT({-2, 1}); const sourcemeta::core::JSON expected{-3}; @@ -97,7 +95,7 @@ TEST(JSONBinPack_Decoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__minus_3_minus_2_1) { } TEST(JSONBinPack_Decoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__8_10_1) { - InputByteStream stream{0x02}; + sourcemeta::core::InputByteStream stream{0x02}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ROOF_MULTIPLE_MIRROR_ENUM_VARINT({10, 1}); const sourcemeta::core::JSON expected{8}; @@ -105,7 +103,7 @@ TEST(JSONBinPack_Decoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__8_10_1) { } TEST(JSONBinPack_Decoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__5_16_5) { - InputByteStream stream{0x02}; + sourcemeta::core::InputByteStream stream{0x02}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ROOF_MULTIPLE_MIRROR_ENUM_VARINT({16, 5}); const sourcemeta::core::JSON expected{5}; @@ -113,7 +111,7 @@ TEST(JSONBinPack_Decoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__5_16_5) { } TEST(JSONBinPack_Decoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__10_15_5) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ROOF_MULTIPLE_MIRROR_ENUM_VARINT({15, 5}); const sourcemeta::core::JSON expected{10}; @@ -121,7 +119,7 @@ TEST(JSONBinPack_Decoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__10_15_5) { } TEST(JSONBinPack_Decoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__minus_25200_1) { - InputByteStream stream{0xdf, 0x89, 0x03}; + sourcemeta::core::InputByteStream stream{0xdf, 0x89, 0x03}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ARBITRARY_MULTIPLE_ZIGZAG_VARINT({1}); const sourcemeta::core::JSON expected{-25200}; @@ -129,7 +127,7 @@ TEST(JSONBinPack_Decoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__minus_25200_1) { } TEST(JSONBinPack_Decoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__10_5) { - InputByteStream stream{0x04}; + sourcemeta::core::InputByteStream stream{0x04}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ARBITRARY_MULTIPLE_ZIGZAG_VARINT({5}); const sourcemeta::core::JSON expected{10}; @@ -137,8 +135,8 @@ TEST(JSONBinPack_Decoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__10_5) { } TEST(JSONBinPack_Decoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__int64_max_1) { - InputByteStream stream{0xfe, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x01}; + sourcemeta::core::InputByteStream stream{0xfe, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ARBITRARY_MULTIPLE_ZIGZAG_VARINT({1}); const std::int64_t value = std::numeric_limits::max(); @@ -147,8 +145,8 @@ TEST(JSONBinPack_Decoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__int64_max_1) { } TEST(JSONBinPack_Decoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__int64_min_1) { - InputByteStream stream{0xfd, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x01}; + sourcemeta::core::InputByteStream stream{0xfd, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ARBITRARY_MULTIPLE_ZIGZAG_VARINT({1}); const std::int64_t value = std::numeric_limits::min() + 1; diff --git a/test/runtime/decode_number_test.cc b/test/runtime/decode_number_test.cc index 297acf22d..358ec9d9c 100644 --- a/test/runtime/decode_number_test.cc +++ b/test/runtime/decode_number_test.cc @@ -1,12 +1,10 @@ #include - -#include "decode_utils.h" - +#include #include #include TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_5) { - InputByteStream stream{0x0a, 0x00}; + sourcemeta::core::InputByteStream stream{0x0a, 0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{5.0}; @@ -14,7 +12,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_5) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_minus_3_point_14) { - InputByteStream stream{0xf3, 0x04, 0x02}; + sourcemeta::core::InputByteStream stream{0xf3, 0x04, 0x02}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{-3.14}; @@ -22,7 +20,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_minus_3_point_14) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_minus_5) { - InputByteStream stream{0x09, 0x00}; + sourcemeta::core::InputByteStream stream{0x09, 0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{-5.0}; @@ -30,7 +28,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_minus_5) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_zero) { - InputByteStream stream{0x00, 0x00}; + sourcemeta::core::InputByteStream stream{0x00, 0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{0.0}; @@ -38,7 +36,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_zero) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_1235) { - InputByteStream stream{0xa6, 0x13, 0x00}; + sourcemeta::core::InputByteStream stream{0xa6, 0x13, 0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{1235.0}; @@ -46,7 +44,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_1235) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_1235) { - InputByteStream stream{0xa6, 0x13, 0x04}; + sourcemeta::core::InputByteStream stream{0xa6, 0x13, 0x04}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{0.1235}; @@ -54,7 +52,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_1235) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_1_point_235) { - InputByteStream stream{0xa6, 0x13, 0x03}; + sourcemeta::core::InputByteStream stream{0xa6, 0x13, 0x03}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{1.235}; @@ -62,7 +60,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_1_point_235) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_01235) { - InputByteStream stream{0xa6, 0x13, 0x05}; + sourcemeta::core::InputByteStream stream{0xa6, 0x13, 0x05}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{0.01235}; @@ -70,7 +68,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_01235) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_12_point_35) { - InputByteStream stream{0xa6, 0x13, 0x02}; + sourcemeta::core::InputByteStream stream{0xa6, 0x13, 0x02}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{12.35}; @@ -78,7 +76,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_12_point_35) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_001235) { - InputByteStream stream{0xa6, 0x13, 0x06}; + sourcemeta::core::InputByteStream stream{0xa6, 0x13, 0x06}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{0.001235}; @@ -86,7 +84,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_001235) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_123_point_5) { - InputByteStream stream{0xa6, 0x13, 0x01}; + sourcemeta::core::InputByteStream stream{0xa6, 0x13, 0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{123.5}; @@ -94,7 +92,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_123_point_5) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_314) { - InputByteStream stream{0xf4, 0x04, 0x00}; + sourcemeta::core::InputByteStream stream{0xf4, 0x04, 0x00}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{314.0}; @@ -102,7 +100,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_314) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_314) { - InputByteStream stream{0xf4, 0x04, 0x03}; + sourcemeta::core::InputByteStream stream{0xf4, 0x04, 0x03}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{0.314}; @@ -110,7 +108,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_314) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_3_point_14) { - InputByteStream stream{0xf4, 0x04, 0x02}; + sourcemeta::core::InputByteStream stream{0xf4, 0x04, 0x02}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{3.14}; @@ -118,7 +116,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_3_point_14) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_0314) { - InputByteStream stream{0xf4, 0x04, 0x04}; + sourcemeta::core::InputByteStream stream{0xf4, 0x04, 0x04}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{0.0314}; @@ -126,7 +124,7 @@ TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_0_point_0314) { } TEST(JSONBinPack_Decoder, DOUBLE_VARINT_TUPLE_31_point_4) { - InputByteStream stream{0xf4, 0x04, 0x01}; + sourcemeta::core::InputByteStream stream{0xf4, 0x04, 0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.DOUBLE_VARINT_TUPLE({}); const sourcemeta::core::JSON expected{31.4}; diff --git a/test/runtime/decode_object_test.cc b/test/runtime/decode_object_test.cc index 674d492fe..b62a068ec 100644 --- a/test/runtime/decode_object_test.cc +++ b/test/runtime/decode_object_test.cc @@ -1,15 +1,13 @@ #include - -#include "decode_utils.h" - #include +#include #include TEST(JSONBinPack_Decoder, FIXED_TYPED_ARBITRARY_OBJECT__no_length_string__integer) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x66, 0x6f, 0x6f, // "foo" 0x01, // 1 0x62, 0x61, 0x72, // "bar" @@ -35,7 +33,7 @@ TEST(JSONBinPack_Decoder, TEST(JSONBinPack_Decoder, VARINT_TYPED_ARBITRARY_OBJECT__no_length_string__integer) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ 0x02, // length 2 0x66, 0x6f, 0x6f, // "foo" 0x01, // 1 diff --git a/test/runtime/decode_string_test.cc b/test/runtime/decode_string_test.cc index be0eff0eb..d25e3355d 100644 --- a/test/runtime/decode_string_test.cc +++ b/test/runtime/decode_string_test.cc @@ -1,12 +1,11 @@ #include - -#include "decode_utils.h" - +#include #include #include TEST(JSONBinPack_Decoder, UTF8_STRING_NO_LENGTH_foo_bar) { - InputByteStream stream{0x66, 0x6f, 0x6f, 0x20, 0x62, 0x61, 0x72}; + sourcemeta::core::InputByteStream stream{0x66, 0x6f, 0x6f, 0x20, + 0x62, 0x61, 0x72}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.UTF8_STRING_NO_LENGTH({7}); const sourcemeta::core::JSON expected{"foo bar"}; @@ -14,7 +13,7 @@ TEST(JSONBinPack_Decoder, UTF8_STRING_NO_LENGTH_foo_bar) { } TEST(JSONBinPack_Decoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_foo_3) { - InputByteStream stream{0x01, 0x66, 0x6f, 0x6f}; + sourcemeta::core::InputByteStream stream{0x01, 0x66, 0x6f, 0x6f}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED({3}); const sourcemeta::core::JSON expected{"foo"}; @@ -22,7 +21,8 @@ TEST(JSONBinPack_Decoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_foo_3) { } TEST(JSONBinPack_Decoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_foo_0_foo_3) { - InputByteStream stream{0x04, 0x66, 0x6f, 0x6f, 0x00, 0x01, 0x05}; + sourcemeta::core::InputByteStream stream{0x04, 0x66, 0x6f, 0x6f, + 0x00, 0x01, 0x05}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const sourcemeta::core::JSON result1 = decoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED({0}); @@ -38,7 +38,7 @@ TEST(JSONBinPack_Decoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_foo_0_foo_3) { } TEST(JSONBinPack_Decoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_unicode_1) { - InputByteStream stream{0x04, 0x66, 0x6f, 0xc3, 0xb8}; + sourcemeta::core::InputByteStream stream{0x04, 0x66, 0x6f, 0xc3, 0xb8}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED({1}); const sourcemeta::core::JSON expected{"foø"}; @@ -46,7 +46,7 @@ TEST(JSONBinPack_Decoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_unicode_1) { } TEST(JSONBinPack_Decoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_foo_4) { - InputByteStream stream{0x02, 0x66, 0x6f, 0x6f}; + sourcemeta::core::InputByteStream stream{0x02, 0x66, 0x6f, 0x6f}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.ROOF_VARINT_PREFIX_UTF8_STRING_SHARED({4}); const sourcemeta::core::JSON expected{"foo"}; @@ -54,7 +54,8 @@ TEST(JSONBinPack_Decoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_foo_4) { } TEST(JSONBinPack_Decoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_foo_3_foo_5) { - InputByteStream stream{0x01, 0x66, 0x6f, 0x6f, 0x00, 0x03, 0x05}; + sourcemeta::core::InputByteStream stream{0x01, 0x66, 0x6f, 0x6f, + 0x00, 0x03, 0x05}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const sourcemeta::core::JSON result1 = decoder.ROOF_VARINT_PREFIX_UTF8_STRING_SHARED({3}); @@ -70,7 +71,7 @@ TEST(JSONBinPack_Decoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_foo_3_foo_5) { } TEST(JSONBinPack_Decoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_unicode_4) { - InputByteStream stream{0x01, 0x66, 0x6f, 0xc3, 0xb8}; + sourcemeta::core::InputByteStream stream{0x01, 0x66, 0x6f, 0xc3, 0xb8}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED({4}); const sourcemeta::core::JSON expected{"foø"}; @@ -78,7 +79,7 @@ TEST(JSONBinPack_Decoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_unicode_4) { } TEST(JSONBinPack_Decoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_foo_3_5) { - InputByteStream stream{0x01, 0x66, 0x6f, 0x6f}; + sourcemeta::core::InputByteStream stream{0x01, 0x66, 0x6f, 0x6f}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED({3, 5}); const sourcemeta::core::JSON expected{"foo"}; @@ -86,7 +87,7 @@ TEST(JSONBinPack_Decoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_foo_3_5) { } TEST(JSONBinPack_Decoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_foo_3_3) { - InputByteStream stream{0x01, 0x66, 0x6f, 0x6f}; + sourcemeta::core::InputByteStream stream{0x01, 0x66, 0x6f, 0x6f}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED({3, 3}); const sourcemeta::core::JSON expected{"foo"}; @@ -95,7 +96,8 @@ TEST(JSONBinPack_Decoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_foo_3_3) { TEST(JSONBinPack_Decoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_foo_0_6_foo_3_100) { - InputByteStream stream{0x04, 0x66, 0x6f, 0x6f, 0x00, 0x01, 0x05}; + sourcemeta::core::InputByteStream stream{0x04, 0x66, 0x6f, 0x6f, + 0x00, 0x01, 0x05}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const sourcemeta::core::JSON result1 = decoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED({0, 6}); @@ -111,7 +113,7 @@ TEST(JSONBinPack_Decoder, } TEST(JSONBinPack_Decoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_unicode_0_6) { - InputByteStream stream{0x05, 0x66, 0x6f, 0xc3, 0xb8}; + sourcemeta::core::InputByteStream stream{0x05, 0x66, 0x6f, 0xc3, 0xb8}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED({0, 6}); const sourcemeta::core::JSON expected{"foø"}; @@ -119,7 +121,7 @@ TEST(JSONBinPack_Decoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_unicode_0_6) { } TEST(JSONBinPack_Decoder, RFC3339_DATE_INTEGER_TRIPLET_2014_10_01) { - InputByteStream stream{0xde, 0x07, 0x0a, 0x01}; + sourcemeta::core::InputByteStream stream{0xde, 0x07, 0x0a, 0x01}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.RFC3339_DATE_INTEGER_TRIPLET({}); const sourcemeta::core::JSON expected{"2014-10-01"}; @@ -127,7 +129,7 @@ TEST(JSONBinPack_Decoder, RFC3339_DATE_INTEGER_TRIPLET_2014_10_01) { } TEST(JSONBinPack_Decoder, PREFIX_VARINT_LENGTH_STRING_SHARED_foo) { - InputByteStream stream{0x04, 0x66, 0x6f, 0x6f}; + sourcemeta::core::InputByteStream stream{0x04, 0x66, 0x6f, 0x6f}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.PREFIX_VARINT_LENGTH_STRING_SHARED({}); const sourcemeta::core::JSON expected{"foo"}; @@ -135,8 +137,8 @@ TEST(JSONBinPack_Decoder, PREFIX_VARINT_LENGTH_STRING_SHARED_foo) { } TEST(JSONBinPack_Decoder, PREFIX_VARINT_LENGTH_STRING_SHARED_foo_foo_foo_foo) { - InputByteStream stream{0x04, 0x66, 0x6f, 0x6f, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x03}; + sourcemeta::core::InputByteStream stream{0x04, 0x66, 0x6f, 0x6f, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x03}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const sourcemeta::core::JSON result1 = decoder.PREFIX_VARINT_LENGTH_STRING_SHARED({}); @@ -156,7 +158,8 @@ TEST(JSONBinPack_Decoder, PREFIX_VARINT_LENGTH_STRING_SHARED_foo_foo_foo_foo) { TEST(JSONBinPack_Decoder, PREFIX_VARINT_LENGTH_STRING_SHARED_non_key_foo_key_foo) { - InputByteStream stream{0x01, 0x66, 0x6f, 0x6f, 0x04, 0x66, 0x6f, 0x6f}; + sourcemeta::core::InputByteStream stream{0x01, 0x66, 0x6f, 0x6f, + 0x04, 0x66, 0x6f, 0x6f}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const sourcemeta::core::JSON result1 = decoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED({3}); @@ -169,7 +172,8 @@ TEST(JSONBinPack_Decoder, TEST(JSONBinPack_Decoder, PREFIX_VARINT_LENGTH_STRING_SHARED_key_foo_non_key_foo) { - InputByteStream stream{0x04, 0x66, 0x6f, 0x6f, 0x00, 0x01, 0x05}; + sourcemeta::core::InputByteStream stream{0x04, 0x66, 0x6f, 0x6f, + 0x00, 0x01, 0x05}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const sourcemeta::core::JSON result1 = decoder.PREFIX_VARINT_LENGTH_STRING_SHARED({}); @@ -181,7 +185,7 @@ TEST(JSONBinPack_Decoder, } TEST(JSONBinPack_Decoder, PREFIX_VARINT_LENGTH_STRING_SHARED_unicode) { - InputByteStream stream{0x05, 0x66, 0x6f, 0xc3, 0xb8}; + sourcemeta::core::InputByteStream stream{0x05, 0x66, 0x6f, 0xc3, 0xb8}; sourcemeta::jsonbinpack::Decoder decoder{stream}; const auto result = decoder.PREFIX_VARINT_LENGTH_STRING_SHARED({}); const sourcemeta::core::JSON expected{"foø"}; diff --git a/test/runtime/decode_test.cc b/test/runtime/decode_test.cc index 04f08af73..c1c6c667d 100644 --- a/test/runtime/decode_test.cc +++ b/test/runtime/decode_test.cc @@ -1,13 +1,11 @@ #include - -#include "decode_utils.h" - +#include #include #include TEST(JSONBinPack_Decoder, generic_decode_BOUNDED_MULTIPLE_8BITS_ENUM_FIXED) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x00}; + sourcemeta::core::InputByteStream stream{0x00}; Decoder decoder{stream}; BOUNDED_MULTIPLE_8BITS_ENUM_FIXED options{-5, -1, 1}; const auto result = decoder.read(options); @@ -17,7 +15,7 @@ TEST(JSONBinPack_Decoder, generic_decode_BOUNDED_MULTIPLE_8BITS_ENUM_FIXED) { TEST(JSONBinPack_Decoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX_many) { using namespace sourcemeta::jsonbinpack; - InputByteStream stream{0x15, 0x1d, 0x25}; + sourcemeta::core::InputByteStream stream{0x15, 0x1d, 0x25}; Decoder decoder{stream}; ANY_PACKED_TYPE_TAG_BYTE_PREFIX options; const auto result_1 = decoder.read(options); diff --git a/test/runtime/decode_utils.h b/test/runtime/decode_utils.h deleted file mode 100644 index f0a9deaee..000000000 --- a/test/runtime/decode_utils.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SOURCEMETA_JSONBINPACK_TEST_RUNTIME_DECODE_UTILS_H_ -#define SOURCEMETA_JSONBINPACK_TEST_RUNTIME_DECODE_UTILS_H_ - -#include - -#include // std::uint8_t -#include // std::initializer_list -#include // std::basic_ostringstream, std::basic_istringstream - -static auto bytes_to_string(std::initializer_list bytes) - -> sourcemeta::core::JSON::String { - std::basic_ostringstream - output{}; - for (const auto byte : bytes) { - output.put(static_cast(byte)); - } - return output.str(); -} - -class InputByteStream - : public std::basic_istringstream { -public: - InputByteStream(std::initializer_list bytes) - : std::basic_istringstream{ - bytes_to_string(bytes)} {} -}; - -#endif diff --git a/test/runtime/encode_any_test.cc b/test/runtime/encode_any_test.cc index c13338858..066ed0ab0 100644 --- a/test/runtime/encode_any_test.cc +++ b/test/runtime/encode_any_test.cc @@ -1,66 +1,66 @@ #include +#include // std::equal +#include // std::byte +#include +#include +#include #include #include #include -#include "encode_utils.h" - -#include -#include - TEST(JSONBinPack_Encoder, BYTE_CHOICE_INDEX_1__1_0_0) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{1}); choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{0}); encoder.BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x00}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x00}})); } TEST(JSONBinPack_Encoder, BYTE_CHOICE_INDEX_1__0_1_0) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{1}); choices.push_back(sourcemeta::core::JSON{0}); encoder.BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, BYTE_CHOICE_INDEX_1__0_0_1) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{1}); encoder.BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x02}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x02}})); } TEST(JSONBinPack_Encoder, BYTE_CHOICE_INDEX_bar__foo_bar_bar) { const sourcemeta::core::JSON document{"bar"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{"foo"}); choices.push_back(sourcemeta::core::JSON{"bar"}); choices.push_back(sourcemeta::core::JSON{"bar"}); encoder.BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, BYTE_CHOICE_INDEX_non_scalar_1) { const sourcemeta::core::JSON document = sourcemeta::core::parse_json("{ \"foo\": 1 }"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; @@ -71,61 +71,61 @@ TEST(JSONBinPack_Encoder, BYTE_CHOICE_INDEX_non_scalar_1) { choices.push_back(sourcemeta::core::parse_json("{ \"bar\": 1 }")); encoder.BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x03}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x03}})); } TEST(JSONBinPack_Encoder, LARGE_CHOICE_INDEX_1__1_0_0) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{1}); choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{0}); encoder.LARGE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x00}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x00}})); } TEST(JSONBinPack_Encoder, LARGE_CHOICE_INDEX_1__0_1_0) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{1}); choices.push_back(sourcemeta::core::JSON{0}); encoder.LARGE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, LARGE_CHOICE_INDEX_1__0_0_1) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{1}); encoder.LARGE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x02}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x02}})); } TEST(JSONBinPack_Encoder, LARGE_CHOICE_INDEX_bar__foo_bar_bar) { const sourcemeta::core::JSON document{"bar"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{"foo"}); choices.push_back(sourcemeta::core::JSON{"bar"}); choices.push_back(sourcemeta::core::JSON{"bar"}); encoder.LARGE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, LARGE_CHOICE_INDEX_non_scalar_1) { const sourcemeta::core::JSON document = sourcemeta::core::parse_json("{ \"foo\": 1 }"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; @@ -136,12 +136,12 @@ TEST(JSONBinPack_Encoder, LARGE_CHOICE_INDEX_non_scalar_1) { choices.push_back(sourcemeta::core::parse_json("{ \"bar\": 1 }")); encoder.LARGE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x03}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x03}})); } TEST(JSONBinPack_Encoder, LARGE_CHOICE_INDEX_enum_250) { const sourcemeta::core::JSON document{250}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; for (std::int64_t x = 0; x < 255; x++) { @@ -149,61 +149,62 @@ TEST(JSONBinPack_Encoder, LARGE_CHOICE_INDEX_enum_250) { } encoder.LARGE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0xfa, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xfa}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__1_0_0) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{1}); choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{0}); encoder.TOP_LEVEL_BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {}); + EXPECT_EQ(stream.bytes(), (std::vector{})); } TEST(JSONBinPack_Encoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__0_1_0) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{1}); choices.push_back(sourcemeta::core::JSON{0}); encoder.TOP_LEVEL_BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x00}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x00}})); } TEST(JSONBinPack_Encoder, TOP_LEVEL_BYTE_CHOICE_INDEX_1__0_0_1) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{0}); choices.push_back(sourcemeta::core::JSON{1}); encoder.TOP_LEVEL_BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, TOP_LEVEL_BYTE_CHOICE_INDEX_bar__foo_bar_bar) { const sourcemeta::core::JSON document{"bar"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; choices.push_back(sourcemeta::core::JSON{"foo"}); choices.push_back(sourcemeta::core::JSON{"bar"}); choices.push_back(sourcemeta::core::JSON{"bar"}); encoder.TOP_LEVEL_BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x00}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x00}})); } TEST(JSONBinPack_Encoder, TOP_LEVEL_BYTE_CHOICE_INDEX_non_scalar_1) { const sourcemeta::core::JSON document = sourcemeta::core::parse_json("{ \"foo\": 1 }"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; std::vector choices; @@ -214,640 +215,1087 @@ TEST(JSONBinPack_Encoder, TOP_LEVEL_BYTE_CHOICE_INDEX_non_scalar_1) { choices.push_back(sourcemeta::core::parse_json("{ \"bar\": 1 }")); encoder.TOP_LEVEL_BYTE_CHOICE_INDEX(document, {std::move(choices)}); - EXPECT_BYTES(stream, {0x02}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x02}})); } TEST(JSONBinPack_Encoder, CONST_NONE_scalar) { const sourcemeta::core::JSON document{1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.CONST_NONE(document, {document}); - EXPECT_BYTES(stream, {}); + EXPECT_EQ(stream.bytes(), (std::vector{})); } TEST(JSONBinPack_Encoder, CONST_NONE_complex) { const sourcemeta::core::JSON document = sourcemeta::core::parse_json("{ \"foo\": 1 }"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.CONST_NONE(document, {document}); - EXPECT_BYTES(stream, {}); + EXPECT_EQ(stream.bytes(), (std::vector{})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__null) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{nullptr}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x17}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x17}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__false) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{false}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x07}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x07}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__true) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{true}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x0f}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x0f}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_3_14) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{3.14}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x2f, // tag: real number - 0xf4, 0x04, 0x02 // 3.14 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x2f}, std::byte{0xf4}, + std::byte{0x04}, std::byte{0x02}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_3_0) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{3.0}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x37, // tag: positive real integer byte - 0x03 // 3 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x37}, std::byte{0x03}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__real_103_0) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{103.0}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x37, // tag: positive real integer byte - 0x67 // 103 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x37}, std::byte{0x67}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__256) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{256}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x1f, // tag: positive varint - 0x80, 0x02 // 256 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x1f}, std::byte{0x80}, + std::byte{0x02}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_257) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{-257}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x27, // tag: negative varint - 0x80, 0x02 // 256 = abs(-257) - 1 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x27}, std::byte{0x80}, + std::byte{0x02}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__255) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{255}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x05, // tag: positive byte - 0xff // 255 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x05}, std::byte{0xff}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_256) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{-256}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x06, // tag: negative byte - 0xff // 255 = abs(-256) - 1 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x06}, std::byte{0xff}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__0) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{0}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x0d}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x0d}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__minus_1) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{-1}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x0e}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x0e}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_space) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{" "}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x11, 0x20}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x11}, std::byte{0x20}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_foo) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x21, 0x66, 0x6f, 0x6f}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x21}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_30_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(30, 'x')}; EXPECT_EQ(document.size(), 30); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0xf9, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0xf9}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__shared_string_foo) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x21, // tag: string with length 3 - 0x66, 0x6f, 0x6f, // "foo" - 0x20, // tag: shared string with length 3 - 0x04, // position (5) - offset (1) = 4 - 0x20, // tag: shared string with length 3 - 0x06 // position (7) - offset (1) = 6 - }); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x21}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x20}, std::byte{0x04}, + std::byte{0x20}, std::byte{0x06}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_31_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(31, 'x')}; EXPECT_EQ(document.size(), 31); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x02, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x02}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_61_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(61, 'x')}; EXPECT_EQ(document.size(), 61); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0xf2, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0xf2}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_url) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{"https://soundcloud.com/dandymusicnl"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, {0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, - 0x73, 0x6f, 0x75, 0x6e, 0x64, 0x63, 0x6c, 0x6f, 0x75, - 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x61, 0x6e, - 0x64, 0x79, 0x6d, 0x75, 0x73, 0x69, 0x63, 0x6e, 0x6c}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x22}, std::byte{0x68}, std::byte{0x74}, std::byte{0x74}, + std::byte{0x70}, std::byte{0x73}, std::byte{0x3a}, std::byte{0x2f}, + std::byte{0x2f}, std::byte{0x73}, std::byte{0x6f}, std::byte{0x75}, + std::byte{0x6e}, std::byte{0x64}, std::byte{0x63}, std::byte{0x6c}, + std::byte{0x6f}, std::byte{0x75}, std::byte{0x64}, std::byte{0x2e}, + std::byte{0x63}, std::byte{0x6f}, std::byte{0x6d}, std::byte{0x2f}, + std::byte{0x64}, std::byte{0x61}, std::byte{0x6e}, std::byte{0x64}, + std::byte{0x79}, std::byte{0x6d}, std::byte{0x75}, std::byte{0x73}, + std::byte{0x69}, std::byte{0x63}, std::byte{0x6e}, std::byte{0x6c}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_128_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(128, 'x')}; EXPECT_EQ(document.size(), 128); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, - {0x3f, // tag: long string, minimum 2^7 - 0x00, // length - 2^7 - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x3f}, std::byte{0x00}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_130_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(130, 'x')}; EXPECT_EQ(document.size(), 130); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, - {0x3f, // tag: long string, minimum 2^7 - 0x02, // length - 2^7 - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x3f}, std::byte{0x02}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_256_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(256, 'x')}; EXPECT_EQ(document.size(), 256); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, - {0x47, // tag: long string, minimum 2^8 - 0x00, // length - 2^8 - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x47}, std::byte{0x00}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_258_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(258, 'x')}; EXPECT_EQ(document.size(), 258); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, - {0x47, // tag: long string, minimum 2^8 - 0x02, // length - 2^8 - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x47}, std::byte{0x02}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_512_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(512, 'x')}; EXPECT_EQ(document.size(), 512); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, - {0x4f, // tag: long string, minimum 2^9 - 0x00, // length - 2^9 - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x4f}, std::byte{0x00}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_513_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(513, 'x')}; EXPECT_EQ(document.size(), 513); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, - {0x4f, // tag: long string, minimum 2^9 - 0x01, // length - 2^9 - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x4f}, std::byte{0x01}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_1024_xs) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(1024, 'x')}; EXPECT_EQ(document.size(), 1024); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, - {0x57, // tag: long string, minimum 2^10 - 0x00, // length - 2^10 - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, - - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x57}, std::byte{0x00}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, @@ -855,17 +1303,29 @@ TEST(JSONBinPack_Encoder, using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(62, 'x')}; EXPECT_EQ(document.size(), 62); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, {0x01, 0x01, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x01}, std::byte{0x01}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); } TEST(JSONBinPack_Encoder, @@ -873,33 +1333,45 @@ TEST(JSONBinPack_Encoder, using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{std::string(63, 'x')}; EXPECT_EQ(document.size(), 63); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES( - stream, {0x01, 0x02, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x01}, std::byte{0x02}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__foo_true_2000) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ \"foo\", true, 2000 ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, { - 0x24, // tag: array with length 3 - 0x21, 0x66, 0x6f, 0x6f, // "foo" - 0x0f, // true - 0x1f, 0xd0, 0x0f // 2000 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{ + std::byte{0x24}, std::byte{0x21}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}, std::byte{0x0f}, + std::byte{0x1f}, std::byte{0xd0}, std::byte{0x0f}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_30) { @@ -910,15 +1382,21 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_30) { } EXPECT_EQ(document.size(), 30); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, - {0xfc, // tag: array with length 30 - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0xfc}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_31) { @@ -929,17 +1407,22 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_31) { } EXPECT_EQ(document.size(), 31); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, - {0x04, // tag: array - 0x00, // length 31 - uint5_max - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x04}, std::byte{0x00}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_32) { @@ -950,17 +1433,22 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_32) { } EXPECT_EQ(document.size(), 32); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_BYTES(stream, - {0x04, // tag: array - 0x01, // length 32 - uint5_max - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f}); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x04}, std::byte{0x01}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, + std::byte{0x0f}, std::byte{0x0f}})); } TEST(JSONBinPack_Encoder, @@ -968,30 +1456,28 @@ TEST(JSONBinPack_Encoder, using namespace sourcemeta::jsonbinpack; const sourcemeta::core::JSON document = sourcemeta::core::parse_json("{ \"foo\": \"bar\", \"baz\": 1 }"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); // Deal with object property non-determinism if (document.as_object().cbegin()->first == "foo") { - EXPECT_BYTES(stream, - { - 0x1b, // tag: object (with length 2) - 0x04, 0x66, 0x6f, 0x6f, // String length 3 + "foo" - 0x21, 0x62, 0x61, 0x72, // String tag + length + 'bar' - 0x04, 0x62, 0x61, 0x7a, // String length 3 + 'baz' - 0x15 // Positive integer tag with value 1 - }); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x1b}, std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x21}, std::byte{0x62}, std::byte{0x61}, + std::byte{0x72}, std::byte{0x04}, std::byte{0x62}, std::byte{0x61}, + std::byte{0x7a}, std::byte{0x15}})); } else { - EXPECT_BYTES(stream, - { - 0x1b, // tag: object (with length 2) - 0x04, 0x62, 0x61, 0x7a, // String length 3 + 'baz' - 0x15, // Positive integer tag with value 1 - 0x04, 0x66, 0x6f, 0x6f, // String length 3 + "foo" - 0x21, 0x62, 0x61, 0x72 // String tag + length + 'bar' - }); + EXPECT_EQ( + stream.bytes(), + (std::vector{ + std::byte{0x1b}, std::byte{0x04}, std::byte{0x62}, std::byte{0x61}, + std::byte{0x7a}, std::byte{0x15}, std::byte{0x04}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}, std::byte{0x21}, std::byte{0x62}, + std::byte{0x61}, std::byte{0x72}})); } } @@ -1033,17 +1519,19 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_30_entries) { document.assign("28", value); document.assign("29", value); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); // JSON object ordering is non-deterministic, so its // impractical to validate the actual payload - EXPECT_BYTES_STARTS_WITH(stream, - 121, // prefix (1) + (30 properties * 4 bytes each) - { - 0xfb // Object with size 30 - }); + { + const auto actual_bytes{stream.bytes()}; + const std::vector expected_prefix{std::byte{0xfb}}; + EXPECT_EQ(actual_bytes.size(), 121); + EXPECT_TRUE(std::equal(expected_prefix.begin(), expected_prefix.end(), + actual_bytes.begin())); + } } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_31_entries) { @@ -1086,19 +1574,21 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_31_entries) { document.assign("30", value); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); // JSON object ordering is non-deterministic, so its // impractical to validate the actual payload - EXPECT_BYTES_STARTS_WITH(stream, - 126, // prefix (2) + (31 properties * 4 bytes each) - { - 0x03, // tag: object - 0x00 // length 31 - uint5_max - }); + { + const auto actual_bytes{stream.bytes()}; + const std::vector expected_prefix{std::byte{0x03}, + std::byte{0x00}}; + EXPECT_EQ(actual_bytes.size(), 126); + EXPECT_TRUE(std::equal(expected_prefix.begin(), expected_prefix.end(), + actual_bytes.begin())); + } } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_32_entries) { @@ -1142,19 +1632,21 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__object_32_entries) { document.assign("30", value); document.assign("31", value); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); // JSON object ordering is non-deterministic, so its // impractical to validate the actual payload - EXPECT_BYTES_STARTS_WITH(stream, - 130, // prefix (2) + (32 properties * 4 bytes each) - { - 0x03, // tag: object - 0x01 // length 32 - uint5_max - }); + { + const auto actual_bytes{stream.bytes()}; + const std::vector expected_prefix{std::byte{0x03}, + std::byte{0x01}}; + EXPECT_EQ(actual_bytes.size(), 130); + EXPECT_TRUE(std::equal(expected_prefix.begin(), expected_prefix.end(), + actual_bytes.begin())); + } } TEST(JSONBinPack_Encoder, @@ -1165,55 +1657,69 @@ TEST(JSONBinPack_Encoder, document.assign("foo", sourcemeta::core::JSON{std::string(62, 'x')}); document.assign("bar", sourcemeta::core::JSON{std::string(62, 'x')}); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); // Deal with object property non-determinism if (document.as_object().cbegin()->first == "foo") { - EXPECT_BYTES(stream, - { - 0x1b, // tag: object (with length 2) - 0x04, 0x66, 0x6f, 0x6f, // String length 3 + "foo" - 0x01, // tag: string - 0x01, // length 62 (with uint5_max as minimum) - - // 62 "x"s - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, - - 0x04, 0x62, 0x61, 0x72, // String tag + length + 'bar' - 0x00, // tag: shared string - 0x01, // length 62 (with uint5_max as minimum) - 0x44 // pointer: 75 - 7 = 68 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{ + std::byte{0x1b}, std::byte{0x04}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}, std::byte{0x01}, + std::byte{0x01}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x04}, std::byte{0x62}, std::byte{0x61}, + std::byte{0x72}, std::byte{0x00}, std::byte{0x01}, + std::byte{0x44}})); } else { - EXPECT_BYTES(stream, - { - 0x1b, // tag: object (with length 2) - 0x04, 0x62, 0x61, 0x72, // String tag + length + 'bar' - 0x01, // tag: string - 0x01, // length 62 (with uint5_max as minimum) - - // 62 "x"s - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, - - 0x04, 0x66, 0x6f, 0x6f, // String length 3 + "foo" - 0x00, // tag: shared string - 0x01, // length 62 (with uint5_max as minimum) - 0x44 // pointer: 75 - 7 = 68 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{ + std::byte{0x1b}, std::byte{0x04}, std::byte{0x62}, + std::byte{0x61}, std::byte{0x72}, std::byte{0x01}, + std::byte{0x01}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x00}, std::byte{0x01}, + std::byte{0x44}})); } } diff --git a/test/runtime/encode_array_test.cc b/test/runtime/encode_array_test.cc index 7b0c6db3e..4f167cdbe 100644 --- a/test/runtime/encode_array_test.cc +++ b/test/runtime/encode_array_test.cc @@ -1,17 +1,16 @@ #include +#include // std::byte #include #include +#include #include - -#include "encode_utils.h" - TEST(JSONBinPack_Encoder, FIXED_TYPED_ARRAY_0_1_2__no_prefix_encodings) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ 0, 1, 2 ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.FIXED_TYPED_ARRAY( @@ -19,14 +18,16 @@ TEST(JSONBinPack_Encoder, FIXED_TYPED_ARRAY_0_1_2__no_prefix_encodings) { {3, std::make_shared(BOUNDED_MULTIPLE_8BITS_ENUM_FIXED{0, 10, 1}), {}}); - EXPECT_BYTES(stream, {0x00, 0x01, 0x02}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x00}, std::byte{0x01}, + std::byte{0x02}})); } TEST(JSONBinPack_Encoder, FIXED_TYPED_ARRAY_0_1_true__semityped) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ 0, 1, true ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -41,13 +42,15 @@ TEST(JSONBinPack_Encoder, FIXED_TYPED_ARRAY_0_1_true__semityped) { {3, std::make_shared(BYTE_CHOICE_INDEX{std::move(choices)}), {std::move(first), std::move(second)}}); - EXPECT_BYTES(stream, {0x00, 0x01, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x00}, std::byte{0x01}, + std::byte{0x01}})); } TEST(JSONBinPack_Encoder, FIXED_TYPED_ARRAY_empty__no_prefix_encodings) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document{sourcemeta::core::JSON::Array{}}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.FIXED_TYPED_ARRAY( @@ -55,7 +58,7 @@ TEST(JSONBinPack_Encoder, FIXED_TYPED_ARRAY_empty__no_prefix_encodings) { {0, std::make_shared(BOUNDED_MULTIPLE_8BITS_ENUM_FIXED{0, 10, 1}), {}}); - EXPECT_BYTES(stream, {}); + EXPECT_EQ(stream.bytes(), (std::vector{})); } TEST(JSONBinPack_Encoder, @@ -63,7 +66,7 @@ TEST(JSONBinPack_Encoder, using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, false, true ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -76,7 +79,9 @@ TEST(JSONBinPack_Encoder, 3, std::make_shared(BYTE_CHOICE_INDEX{std::move(choices)}), {}}); - EXPECT_BYTES(stream, {0x03, 0x01, 0x00, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x03}, std::byte{0x01}, + std::byte{0x00}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, @@ -84,7 +89,7 @@ TEST(JSONBinPack_Encoder, using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, false, true ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -97,14 +102,16 @@ TEST(JSONBinPack_Encoder, 3, std::make_shared(BYTE_CHOICE_INDEX{std::move(choices)}), {}}); - EXPECT_BYTES(stream, {0x00, 0x01, 0x00, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x00}, std::byte{0x01}, + std::byte{0x00}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, BOUNDED_8BITS_TYPED_ARRAY_true_false_5__1_3) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, false, 5 ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -117,14 +124,16 @@ TEST(JSONBinPack_Encoder, BOUNDED_8BITS_TYPED_ARRAY_true_false_5__1_3) { 3, std::make_shared(BOUNDED_MULTIPLE_8BITS_ENUM_FIXED{0, 255, 1}), {BYTE_CHOICE_INDEX{choices}, BYTE_CHOICE_INDEX{choices}}}); - EXPECT_BYTES(stream, {0x02, 0x01, 0x00, 0x05}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x02}, std::byte{0x01}, + std::byte{0x00}, std::byte{0x05}})); } TEST(JSONBinPack_Encoder, BOUNDED_8BITS_TYPED_ARRAY_complex) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, \"foo\", 1000 ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -137,7 +146,11 @@ TEST(JSONBinPack_Encoder, BOUNDED_8BITS_TYPED_ARRAY_complex) { std::make_shared(FLOOR_MULTIPLE_ENUM_VARINT{-2, 4}), {BYTE_CHOICE_INDEX{choices}, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED{3}}}); - EXPECT_BYTES(stream, {0x03, 0x01, 0x01, 0x66, 0x6f, 0x6f, 0xfa, 0x01}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x03}, std::byte{0x01}, std::byte{0x01}, + std::byte{0x66}, std::byte{0x6f}, std::byte{0x6f}, + std::byte{0xfa}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, @@ -145,7 +158,7 @@ TEST(JSONBinPack_Encoder, using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, false, true ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -157,14 +170,16 @@ TEST(JSONBinPack_Encoder, {0, std::make_shared(BYTE_CHOICE_INDEX{std::move(choices)}), {}}); - EXPECT_BYTES(stream, {0x03, 0x01, 0x00, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x03}, std::byte{0x01}, + std::byte{0x00}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, FLOOR_TYPED_ARRAY_true_false_5__1_3) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, false, 5 ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -176,14 +191,16 @@ TEST(JSONBinPack_Encoder, FLOOR_TYPED_ARRAY_true_false_5__1_3) { {1, std::make_shared(BOUNDED_MULTIPLE_8BITS_ENUM_FIXED{0, 255, 1}), {BYTE_CHOICE_INDEX{choices}, BYTE_CHOICE_INDEX{choices}}}); - EXPECT_BYTES(stream, {0x02, 0x01, 0x00, 0x05}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x02}, std::byte{0x01}, + std::byte{0x00}, std::byte{0x05}})); } TEST(JSONBinPack_Encoder, FLOOR_TYPED_ARRAY_complex) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, \"foo\", 1000 ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -195,7 +212,11 @@ TEST(JSONBinPack_Encoder, FLOOR_TYPED_ARRAY_complex) { std::make_shared(FLOOR_MULTIPLE_ENUM_VARINT{-2, 4}), {BYTE_CHOICE_INDEX{choices}, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED{3}}}); - EXPECT_BYTES(stream, {0x03, 0x01, 0x01, 0x66, 0x6f, 0x6f, 0xfa, 0x01}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x03}, std::byte{0x01}, std::byte{0x01}, + std::byte{0x66}, std::byte{0x6f}, std::byte{0x6f}, + std::byte{0xfa}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, @@ -203,7 +224,7 @@ TEST(JSONBinPack_Encoder, using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, false, true ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -215,14 +236,16 @@ TEST(JSONBinPack_Encoder, {6, std::make_shared(BYTE_CHOICE_INDEX{std::move(choices)}), {}}); - EXPECT_BYTES(stream, {0x03, 0x01, 0x00, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x03}, std::byte{0x01}, + std::byte{0x00}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, ROOF_TYPED_ARRAY_true_false_5__1_3) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, false, 5 ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -234,14 +257,16 @@ TEST(JSONBinPack_Encoder, ROOF_TYPED_ARRAY_true_false_5__1_3) { {5, std::make_shared(BOUNDED_MULTIPLE_8BITS_ENUM_FIXED{0, 255, 1}), {BYTE_CHOICE_INDEX{choices}, BYTE_CHOICE_INDEX{choices}}}); - EXPECT_BYTES(stream, {0x02, 0x01, 0x00, 0x05}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x02}, std::byte{0x01}, + std::byte{0x00}, std::byte{0x05}})); } TEST(JSONBinPack_Encoder, ROOF_TYPED_ARRAY_complex) { using namespace sourcemeta::jsonbinpack; sourcemeta::core::JSON document = sourcemeta::core::parse_json("[ true, \"foo\", 1000 ]"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; std::vector choices; choices.push_back(sourcemeta::core::JSON(false)); @@ -253,5 +278,9 @@ TEST(JSONBinPack_Encoder, ROOF_TYPED_ARRAY_complex) { {6, std::make_shared(FLOOR_MULTIPLE_ENUM_VARINT{-2, 4}), {BYTE_CHOICE_INDEX{choices}, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED{3}}}); - EXPECT_BYTES(stream, {0x03, 0x01, 0x01, 0x66, 0x6f, 0x6f, 0xfa, 0x01}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x03}, std::byte{0x01}, std::byte{0x01}, + std::byte{0x66}, std::byte{0x6f}, std::byte{0x6f}, + std::byte{0xfa}, std::byte{0x01}})); } diff --git a/test/runtime/encode_integer_test.cc b/test/runtime/encode_integer_test.cc index 12e466c20..abd801cfe 100644 --- a/test/runtime/encode_integer_test.cc +++ b/test/runtime/encode_integer_test.cc @@ -1,164 +1,176 @@ #include -#include // std::numeric_limits - -#include "encode_utils.h" +#include // std::byte +#include // std::numeric_limits +#include #include #include +#include // std::vector TEST(JSONBinPack_Encoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__minus_5_minus_5_minus_1_1) { const sourcemeta::core::JSON document{-5}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED(document, {-5, -1, 1}); - EXPECT_BYTES(stream, {0x00}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x00}})); } TEST(JSONBinPack_Encoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__2_minus_5_5_1) { const sourcemeta::core::JSON document{2}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED(document, {-5, 5, 1}); - EXPECT_BYTES(stream, {0x07}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x07}})); } TEST(JSONBinPack_Encoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__5_2_8_1) { const sourcemeta::core::JSON document{5}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED(document, {2, 8, 1}); - EXPECT_BYTES(stream, {0x03}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x03}})); } TEST(JSONBinPack_Encoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__5_1_19_5) { const sourcemeta::core::JSON document{5}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED(document, {1, 19, 5}); - EXPECT_BYTES(stream, {0x00}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x00}})); } TEST(JSONBinPack_Encoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__15_1_19_5) { const sourcemeta::core::JSON document{15}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED(document, {1, 19, 5}); - EXPECT_BYTES(stream, {0x02}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x02}})); } TEST(JSONBinPack_Encoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__255_0_255_1) { const sourcemeta::core::JSON document{255}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_MULTIPLE_8BITS_ENUM_FIXED(document, {0, 255, 1}); - EXPECT_BYTES(stream, {0xff}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0xff}})); } TEST(JSONBinPack_Encoder, FLOOR_MULTIPLE_ENUM_VARINT__minus_3_minus_10_1) { const sourcemeta::core::JSON document{-3}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_MULTIPLE_ENUM_VARINT(document, {-10, 1}); - EXPECT_BYTES(stream, {0x07}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x07}})); } TEST(JSONBinPack_Encoder, FLOOR_MULTIPLE_ENUM_VARINT__5_2_1) { const sourcemeta::core::JSON document{5}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_MULTIPLE_ENUM_VARINT(document, {2, 1}); - EXPECT_BYTES(stream, {0x03}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x03}})); } TEST(JSONBinPack_Encoder, FLOOR_MULTIPLE_ENUM_VARINT__10_5_5) { const sourcemeta::core::JSON document{10}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_MULTIPLE_ENUM_VARINT(document, {5, 5}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, FLOOR_MULTIPLE_ENUM_VARINT__10_2_5) { const sourcemeta::core::JSON document{10}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_MULTIPLE_ENUM_VARINT(document, {2, 5}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, FLOOR_MULTIPLE_ENUM_VARINT__1000_minus_2_4) { const sourcemeta::core::JSON document{1000}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_MULTIPLE_ENUM_VARINT(document, {-2, 4}); - EXPECT_BYTES(stream, {0xfa, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xfa}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__minus_3_minus_2_1) { const sourcemeta::core::JSON document{-3}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ROOF_MULTIPLE_MIRROR_ENUM_VARINT(document, {-2, 1}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__8_10_1) { const sourcemeta::core::JSON document{8}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ROOF_MULTIPLE_MIRROR_ENUM_VARINT(document, {10, 1}); - EXPECT_BYTES(stream, {0x02}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x02}})); } TEST(JSONBinPack_Encoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__5_16_5) { const sourcemeta::core::JSON document{5}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ROOF_MULTIPLE_MIRROR_ENUM_VARINT(document, {15, 5}); - EXPECT_BYTES(stream, {0x02}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x02}})); } TEST(JSONBinPack_Encoder, ROOF_MULTIPLE_MIRROR_ENUM_VARINT__10_15_5) { const sourcemeta::core::JSON document{10}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ROOF_MULTIPLE_MIRROR_ENUM_VARINT(document, {15, 5}); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_Encoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__minus_25200_1) { const sourcemeta::core::JSON document{-25200}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ARBITRARY_MULTIPLE_ZIGZAG_VARINT(document, {1}); - EXPECT_BYTES(stream, {0xdf, 0x89, 0x03}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xdf}, std::byte{0x89}, + std::byte{0x03}})); } TEST(JSONBinPack_Encoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__10_5) { const sourcemeta::core::JSON document{10}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ARBITRARY_MULTIPLE_ZIGZAG_VARINT(document, {5}); - EXPECT_BYTES(stream, {0x04}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x04}})); } TEST(JSONBinPack_Encoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__int64_max_1) { const std::int64_t value = std::numeric_limits::max(); const sourcemeta::core::JSON document{value}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ARBITRARY_MULTIPLE_ZIGZAG_VARINT(document, {1}); - EXPECT_BYTES(stream, - {0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0xfe}, std::byte{0xff}, std::byte{0xff}, + std::byte{0xff}, std::byte{0xff}, std::byte{0xff}, + std::byte{0xff}, std::byte{0xff}, std::byte{0xff}, + std::byte{0x01}})); } TEST(JSONBinPack_Encoder, ARBITRARY_MULTIPLE_ZIGZAG_VARINT__int64_min_1) { const std::int64_t value = std::numeric_limits::min() + 1; const sourcemeta::core::JSON document{value}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ARBITRARY_MULTIPLE_ZIGZAG_VARINT(document, {1}); - EXPECT_BYTES(stream, - {0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0xfd}, std::byte{0xff}, std::byte{0xff}, + std::byte{0xff}, std::byte{0xff}, std::byte{0xff}, + std::byte{0xff}, std::byte{0xff}, std::byte{0xff}, + std::byte{0x01}})); } diff --git a/test/runtime/encode_number_test.cc b/test/runtime/encode_number_test.cc index 43d963bce..90b57702f 100644 --- a/test/runtime/encode_number_test.cc +++ b/test/runtime/encode_number_test.cc @@ -1,133 +1,163 @@ +#include // std::byte #include - -#include "encode_utils.h" +#include #include #include +#include // std::vector TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_5) { const sourcemeta::core::JSON document{5.0}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0x0a, 0x00}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x0a}, std::byte{0x00}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_minus_3_point_14) { const sourcemeta::core::JSON document{-3.14}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xf3, 0x04, 0x02}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xf3}, std::byte{0x04}, + std::byte{0x02}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_minus_5) { const sourcemeta::core::JSON document{-5.0}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0x09, 0x00}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x09}, std::byte{0x00}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_zero) { const sourcemeta::core::JSON document{0.0}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0x00, 0x00}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x00}, std::byte{0x00}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_1235) { const sourcemeta::core::JSON document{1235.0}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xa6, 0x13, 0x00}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xa6}, std::byte{0x13}, + std::byte{0x00}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_0_point_1235) { const sourcemeta::core::JSON document{0.1235}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xa6, 0x13, 0x04}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xa6}, std::byte{0x13}, + std::byte{0x04}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_1_point_235) { const sourcemeta::core::JSON document{1.235}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xa6, 0x13, 0x03}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xa6}, std::byte{0x13}, + std::byte{0x03}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_0_point_01235) { const sourcemeta::core::JSON document{0.01235}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xa6, 0x13, 0x05}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xa6}, std::byte{0x13}, + std::byte{0x05}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_12_35) { const sourcemeta::core::JSON document{12.35}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xa6, 0x13, 0x02}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xa6}, std::byte{0x13}, + std::byte{0x02}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_0_point_001235) { const sourcemeta::core::JSON document{0.001235}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xa6, 0x13, 0x06}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xa6}, std::byte{0x13}, + std::byte{0x06}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_123_point_5) { const sourcemeta::core::JSON document{123.5}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xa6, 0x13, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xa6}, std::byte{0x13}, + std::byte{0x01}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_314) { const sourcemeta::core::JSON document{314.0}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xf4, 0x04, 0x00}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xf4}, std::byte{0x04}, + std::byte{0x00}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_0_point_314) { const sourcemeta::core::JSON document{0.314}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xf4, 0x04, 0x03}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xf4}, std::byte{0x04}, + std::byte{0x03}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_3_point_14) { const sourcemeta::core::JSON document{3.14}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xf4, 0x04, 0x02}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xf4}, std::byte{0x04}, + std::byte{0x02}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_0_point_0314) { const sourcemeta::core::JSON document{0.0314}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xf4, 0x04, 0x04}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xf4}, std::byte{0x04}, + std::byte{0x04}})); } TEST(JSONBinPack_Encoder, DOUBLE_VARINT_TUPLE_31_point_4) { const sourcemeta::core::JSON document{31.4}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.DOUBLE_VARINT_TUPLE(document, {}); - EXPECT_BYTES(stream, {0xf4, 0x04, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xf4}, std::byte{0x04}, + std::byte{0x01}})); } diff --git a/test/runtime/encode_object_test.cc b/test/runtime/encode_object_test.cc index 51eff8bfd..89b537d3a 100644 --- a/test/runtime/encode_object_test.cc +++ b/test/runtime/encode_object_test.cc @@ -1,17 +1,17 @@ +#include // std::byte #include +#include // std::vector #include +#include #include - -#include "encode_utils.h" - TEST(JSONBinPack_Encoder, FIXED_TYPED_ARBITRARY_OBJECT__no_length_string__integer) { using namespace sourcemeta::jsonbinpack; const sourcemeta::core::JSON document = sourcemeta::core::parse_json("{\"foo\":1,\"bar\":2}"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.FIXED_TYPED_ARBITRARY_OBJECT( @@ -21,19 +21,17 @@ TEST(JSONBinPack_Encoder, // Deal with object property non-determinism if (document.as_object().cbegin()->first == "foo") { - EXPECT_BYTES(stream, { - 0x66, 0x6f, 0x6f, // "foo" - 0x01, // 1 - 0x62, 0x61, 0x72, // "bar" - 0x02 // 2 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x01}, + std::byte{0x62}, std::byte{0x61}, + std::byte{0x72}, std::byte{0x02}})); } else { - EXPECT_BYTES(stream, { - 0x62, 0x61, 0x72, // "bar" - 0x02, // 2 - 0x66, 0x6f, 0x6f, // "foo" - 0x01 // 1 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x62}, std::byte{0x61}, + std::byte{0x72}, std::byte{0x02}, + std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x01}})); } } @@ -42,7 +40,7 @@ TEST(JSONBinPack_Encoder, using namespace sourcemeta::jsonbinpack; const sourcemeta::core::JSON document = sourcemeta::core::parse_json("{\"foo\":1,\"bar\":2}"); - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; encoder.VARINT_TYPED_ARBITRARY_OBJECT( @@ -52,20 +50,16 @@ TEST(JSONBinPack_Encoder, // Deal with object property non-determinism if (document.as_object().cbegin()->first == "foo") { - EXPECT_BYTES(stream, { - 0x02, // length 2 - 0x66, 0x6f, 0x6f, // "foo" - 0x01, // 1 - 0x62, 0x61, 0x72, // "bar" - 0x02 // 2 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{ + std::byte{0x02}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x01}, std::byte{0x62}, + std::byte{0x61}, std::byte{0x72}, std::byte{0x02}})); } else { - EXPECT_BYTES(stream, { - 0x02, // length 2 - 0x62, 0x61, 0x72, // "bar" - 0x02, // 2 - 0x66, 0x6f, 0x6f, // "foo" - 0x01 // 1 - }); + EXPECT_EQ(stream.bytes(), + (std::vector{ + std::byte{0x02}, std::byte{0x62}, std::byte{0x61}, + std::byte{0x72}, std::byte{0x02}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}, std::byte{0x01}})); } } diff --git a/test/runtime/encode_string_test.cc b/test/runtime/encode_string_test.cc index a104cf22e..42d810a6b 100644 --- a/test/runtime/encode_string_test.cc +++ b/test/runtime/encode_string_test.cc @@ -1,178 +1,209 @@ +#include // std::byte #include - -#include "encode_utils.h" +#include #include #include +#include // std::vector TEST(JSONBinPack_Encoder, UTF8_STRING_NO_LENGTH_foo_bar) { const sourcemeta::core::JSON document{"foo bar"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.UTF8_STRING_NO_LENGTH(document, {7}); - EXPECT_BYTES(stream, {0x66, 0x6f, 0x6f, 0x20, 0x62, 0x61, 0x72}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x66}, std::byte{0x6f}, std::byte{0x6f}, + std::byte{0x20}, std::byte{0x62}, std::byte{0x61}, + std::byte{0x72}})); } TEST(JSONBinPack_Encoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_foo_3) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED(document, {3}); - EXPECT_BYTES(stream, {0x01, 0x66, 0x6f, 0x6f}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x01}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}})); } TEST(JSONBinPack_Encoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_foo_0_foo_3) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED(document, {0}); encoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED(document, {3}); - EXPECT_BYTES(stream, {0x04, 0x66, 0x6f, 0x6f, 0x00, 0x01, 0x05}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x00}, std::byte{0x01}, + std::byte{0x05}})); } TEST(JSONBinPack_Encoder, FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED_unicode_1) { const sourcemeta::core::JSON document{"foø"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED(document, {1}); - EXPECT_BYTES(stream, {0x04, 0x66, 0x6f, 0xc3, 0xb8}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0xc3}, std::byte{0xb8}})); } TEST(JSONBinPack_Encoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_foo_4) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ROOF_VARINT_PREFIX_UTF8_STRING_SHARED(document, {4}); - EXPECT_BYTES(stream, {0x02, 0x66, 0x6f, 0x6f}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x02}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}})); } TEST(JSONBinPack_Encoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_foo_3_foo_5) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ROOF_VARINT_PREFIX_UTF8_STRING_SHARED(document, {3}); encoder.ROOF_VARINT_PREFIX_UTF8_STRING_SHARED(document, {5}); - EXPECT_BYTES(stream, {0x01, 0x66, 0x6f, 0x6f, 0x00, 0x03, 0x05}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x01}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x00}, std::byte{0x03}, + std::byte{0x05}})); } TEST(JSONBinPack_Encoder, ROOF_VARINT_PREFIX_UTF8_STRING_SHARED_unicode_4) { const sourcemeta::core::JSON document{"foø"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.ROOF_VARINT_PREFIX_UTF8_STRING_SHARED(document, {4}); - EXPECT_BYTES(stream, {0x01, 0x66, 0x6f, 0xc3, 0xb8}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x01}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0xc3}, std::byte{0xb8}})); } TEST(JSONBinPack_Encoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_foo_3_5) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED(document, {3, 5}); - EXPECT_BYTES(stream, {0x01, 0x66, 0x6f, 0x6f}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x01}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}})); } TEST(JSONBinPack_Encoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_foo_3_3) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED(document, {3, 3}); - EXPECT_BYTES(stream, {0x01, 0x66, 0x6f, 0x6f}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x01}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}})); } TEST(JSONBinPack_Encoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_foo_0_6_foo_3_100) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED(document, {0, 6}); encoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED(document, {3, 100}); - EXPECT_BYTES(stream, {0x04, 0x66, 0x6f, 0x6f, 0x00, 0x01, 0x05}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x00}, std::byte{0x01}, + std::byte{0x05}})); } TEST(JSONBinPack_Encoder, BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED_unicode_0_6) { const sourcemeta::core::JSON document{"foø"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED(document, {0, 6}); - EXPECT_BYTES(stream, {0x05, 0x66, 0x6f, 0xc3, 0xb8}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x05}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0xc3}, std::byte{0xb8}})); } TEST(JSONBinPack_Encoder, RFC3339_DATE_INTEGER_TRIPLET_2014_10_01) { const sourcemeta::core::JSON document{"2014-10-01"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.RFC3339_DATE_INTEGER_TRIPLET(document, {}); - EXPECT_BYTES(stream, {0xde, 0x07, 0x0a, 0x01}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xde}, std::byte{0x07}, + std::byte{0x0a}, std::byte{0x01}})); } TEST(JSONBinPack_Encoder, PREFIX_VARINT_LENGTH_STRING_SHARED_foo) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.PREFIX_VARINT_LENGTH_STRING_SHARED(document, {}); - EXPECT_BYTES(stream, { - 0x04, // String length + 1 - 0x66, 0x6f, 0x6f // "foo" - }); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x04}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}})); } TEST(JSONBinPack_Encoder, PREFIX_VARINT_LENGTH_STRING_SHARED_foo_foo_foo_foo) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.PREFIX_VARINT_LENGTH_STRING_SHARED(document, {}); encoder.PREFIX_VARINT_LENGTH_STRING_SHARED(document, {}); encoder.PREFIX_VARINT_LENGTH_STRING_SHARED(document, {}); encoder.PREFIX_VARINT_LENGTH_STRING_SHARED(document, {}); - EXPECT_BYTES(stream, { - 0x04, // String length + 1 - 0x66, 0x6f, 0x6f, // "foo" - 0x00, // Start of pointer - 0x05, // Pointer (current = 5 - location = 0) - 0x00, // Start of pointer - 0x03, // Pointer (current = 7 - location = 3) - 0x00, // Start of pointer - 0x03 // Pointer (current = 9 - location = 3) - }); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x00}, std::byte{0x05}, + std::byte{0x00}, std::byte{0x03}, std::byte{0x00}, + std::byte{0x03}})); } TEST(JSONBinPack_Encoder, PREFIX_VARINT_LENGTH_STRING_SHARED_non_key_foo_key_foo) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED(document, {3}); encoder.PREFIX_VARINT_LENGTH_STRING_SHARED(document, {}); - EXPECT_BYTES(stream, { - 0x01, // String length + 1 - 3 - 0x66, 0x6f, 0x6f, // "foo" - 0x04, // String length + 1 - 0x66, 0x6f, 0x6f // "foo" - }); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x01}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x04}, std::byte{0x66}, + std::byte{0x6f}, std::byte{0x6f}})); } TEST(JSONBinPack_Encoder, PREFIX_VARINT_LENGTH_STRING_SHARED_key_foo_non_key_foo) { const sourcemeta::core::JSON document{"foo"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.PREFIX_VARINT_LENGTH_STRING_SHARED(document, {}); encoder.FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED(document, {3}); - EXPECT_BYTES(stream, { - 0x04, // String length + 1 - 0x66, 0x6f, 0x6f, // "foo" - 0x00, // Start of pointer - 0x01, // String length + 1 - 3 - 0x05 // Pointer (6 - 1 = 5) - }); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x00}, std::byte{0x01}, + std::byte{0x05}})); } TEST(JSONBinPack_Encoder, PREFIX_VARINT_LENGTH_STRING_SHARED_unicode) { const sourcemeta::core::JSON document{"foø"}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::Encoder encoder{stream}; encoder.PREFIX_VARINT_LENGTH_STRING_SHARED(document, {}); - EXPECT_BYTES(stream, {0x05, 0x66, 0x6f, 0xc3, 0xb8}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0x05}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0xc3}, std::byte{0xb8}})); } diff --git a/test/runtime/encode_test.cc b/test/runtime/encode_test.cc index c431deb76..5728108a6 100644 --- a/test/runtime/encode_test.cc +++ b/test/runtime/encode_test.cc @@ -1,26 +1,29 @@ +#include // std::byte #include - -#include "encode_utils.h" +#include #include #include +#include // std::vector TEST(JSONBinPack_Encoder, generic_encode_BOUNDED_MULTIPLE_8BITS_ENUM_FIXED) { using namespace sourcemeta::jsonbinpack; const sourcemeta::core::JSON document{-5}; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; BOUNDED_MULTIPLE_8BITS_ENUM_FIXED options{-5, -1, 1}; encoder.write(document, options); - EXPECT_BYTES(stream, {0x00}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x00}})); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX_many) { using namespace sourcemeta::jsonbinpack; - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; Encoder encoder{stream}; ANY_PACKED_TYPE_TAG_BYTE_PREFIX options; encoder.write(sourcemeta::core::JSON{1}, options); encoder.write(sourcemeta::core::JSON{2}, options); encoder.write(sourcemeta::core::JSON{3}, options); - EXPECT_BYTES(stream, {0x15, 0x1d, 0x25}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0x15}, std::byte{0x1d}, + std::byte{0x25}})); } diff --git a/test/runtime/encode_utils.h b/test/runtime/encode_utils.h deleted file mode 100644 index 57daf6347..000000000 --- a/test/runtime/encode_utils.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef SOURCEMETA_JSONBINPACK_TEST_RUNTIME_ENCODE_UTILS_H_ -#define SOURCEMETA_JSONBINPACK_TEST_RUNTIME_ENCODE_UTILS_H_ - -#include - -#include - -#include // std::transform -#include // assert -#include // std::byte -#include // std::uint8_t -#include // std::initializer_list -#include // std::back_inserter -#include // std::basic_ostringstream -#include // std::vector - -static inline auto to_byte(const std::uint8_t input) -> std::byte { - return std::byte{input}; -} - -class OutputByteStream - : public std::basic_ostringstream { -public: - // Convert the stream into an array of bytes - auto bytes() const -> const std::vector { - std::vector result{}; - const sourcemeta::core::JSON::String string{this->str()}; - std::transform(string.cbegin(), string.cend(), std::back_inserter(result), - [](const auto character) { - return to_byte(static_cast(character)); - }); - return result; - } -}; - -inline auto EXPECT_BYTES(const OutputByteStream &stream, - std::initializer_list bytes) -> void { - const std::vector actual{stream.bytes()}; - std::vector expected{}; - std::transform(bytes.begin(), bytes.end(), std::back_inserter(expected), - [](const auto character) { - return to_byte(static_cast(character)); - }); - EXPECT_EQ(actual, expected); -} - -inline auto EXPECT_BYTES_STARTS_WITH(const OutputByteStream &stream, - const std::size_t total, - std::initializer_list bytes) - -> void { - const std::vector actual{stream.bytes()}; - EXPECT_EQ(actual.size(), total); - std::vector expected{}; - std::transform(bytes.begin(), bytes.end(), std::back_inserter(expected), - [](const auto character) { - return to_byte(static_cast(character)); - }); - assert(total > expected.size()); - auto iterator{actual.cbegin()}; - std::advance(iterator, expected.size()); - const std::vector prefix{actual.cbegin(), iterator}; - EXPECT_EQ(prefix, expected); -} - -#endif diff --git a/test/runtime/input_stream_varint_test.cc b/test/runtime/input_stream_varint_test.cc index 804520a6a..b64878f1d 100644 --- a/test/runtime/input_stream_varint_test.cc +++ b/test/runtime/input_stream_varint_test.cc @@ -1,37 +1,35 @@ #include #include // std::numeric_limits - -#include "decode_utils.h" - +#include #include TEST(JSONBinPack_InputStream, varint_0x01) { - InputByteStream stream{0x01}; + sourcemeta::core::InputByteStream stream{0x01}; sourcemeta::jsonbinpack::InputStream decoder{stream}; EXPECT_EQ(decoder.get_varint(), 1); } TEST(JSONBinPack_InputStream, varint_0x17) { - InputByteStream stream{0x17}; + sourcemeta::core::InputByteStream stream{0x17}; sourcemeta::jsonbinpack::InputStream decoder{stream}; EXPECT_EQ(decoder.get_varint(), 23); } TEST(JSONBinPack_InputStream, varint_0xac_0x02) { - InputByteStream stream{{0xac, 0x02}}; + sourcemeta::core::InputByteStream stream{{0xac, 0x02}}; sourcemeta::jsonbinpack::InputStream decoder{stream}; EXPECT_EQ(decoder.get_varint(), 300); } TEST(JSONBinPack_InputStream, varint_0xdf_0x89_0x03) { - InputByteStream stream{{0xdf, 0x89, 0x03}}; + sourcemeta::core::InputByteStream stream{{0xdf, 0x89, 0x03}}; sourcemeta::jsonbinpack::InputStream decoder{stream}; EXPECT_EQ(decoder.get_varint(), 50399); } TEST(JSONBinPack_InputStream, varint_0xfe_0xff_0xff_0xff_0x0f) { - InputByteStream stream{{0xfe, 0xff, 0xff, 0xff, 0x0f}}; + sourcemeta::core::InputByteStream stream{{0xfe, 0xff, 0xff, 0xff, 0x0f}}; sourcemeta::jsonbinpack::InputStream decoder{stream}; const std::uint64_t result{decoder.get_varint()}; const std::uint64_t expected{4294967294}; @@ -41,7 +39,7 @@ TEST(JSONBinPack_InputStream, varint_0xfe_0xff_0xff_0xff_0x0f) { TEST(JSONBinPack_InputStream, varint_uint64_max) { // In Base-128: (1)1111111 (1)1111111 (1)1111111 (1)1111111 // (1)1111111 (1)1111111 (1)1111111 (1)1111111 (1)1111111 (0)0000001 - InputByteStream stream{ + sourcemeta::core::InputByteStream stream{ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01}}; sourcemeta::jsonbinpack::InputStream decoder{stream}; const std::uint64_t result{decoder.get_varint()}; diff --git a/test/runtime/output_stream_varint_test.cc b/test/runtime/output_stream_varint_test.cc index 9e3853d87..d4d8052a9 100644 --- a/test/runtime/output_stream_varint_test.cc +++ b/test/runtime/output_stream_varint_test.cc @@ -1,48 +1,54 @@ #include -#include // std::numeric_limits - -#include "encode_utils.h" - +#include // std::byte +#include // std::numeric_limits +#include #include +#include // std::vector TEST(JSONBinPack_OutputStream, varint_1) { - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::OutputStream encoder{stream}; encoder.put_varint(1); - EXPECT_BYTES(stream, {0x01}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x01}})); } TEST(JSONBinPack_OutputStream, varint_23) { - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::OutputStream encoder{stream}; encoder.put_varint(23); - EXPECT_BYTES(stream, {0x17}); + EXPECT_EQ(stream.bytes(), (std::vector{std::byte{0x17}})); } TEST(JSONBinPack_OutputStream, varint_300) { - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::OutputStream encoder{stream}; encoder.put_varint(300); - EXPECT_BYTES(stream, {0xac, 0x02}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xac}, std::byte{0x02}})); } TEST(JSONBinPack_OutputStream, varint_50399) { - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::OutputStream encoder{stream}; encoder.put_varint(50399); - EXPECT_BYTES(stream, {0xdf, 0x89, 0x03}); + EXPECT_EQ(stream.bytes(), + (std::vector{std::byte{0xdf}, std::byte{0x89}, + std::byte{0x03}})); } TEST(JSONBinPack_OutputStream, varint_4294967294) { - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; sourcemeta::jsonbinpack::OutputStream encoder{stream}; encoder.put_varint(4294967294); - EXPECT_BYTES(stream, {0xfe, 0xff, 0xff, 0xff, 0x0f}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0xfe}, std::byte{0xff}, std::byte{0xff}, + std::byte{0xff}, std::byte{0x0f}})); } TEST(JSONBinPack_OutputStream, varint_uint64_max) { - OutputByteStream stream{}; + sourcemeta::core::OutputByteStream stream{}; const std::uint64_t value = std::numeric_limits::max(); sourcemeta::jsonbinpack::OutputStream encoder{stream}; encoder.put_varint(value); @@ -52,6 +58,10 @@ TEST(JSONBinPack_OutputStream, varint_uint64_max) { // 11111111 // In Base-128: (1)1111111 (1)1111111 (1)1111111 (1)1111111 // (1)1111111 (1)1111111 (1)1111111 (1)1111111 (1)1111111 (0)0000001 - EXPECT_BYTES(stream, - {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01}); + EXPECT_EQ( + stream.bytes(), + (std::vector{std::byte{0xff}, std::byte{0xff}, std::byte{0xff}, + std::byte{0xff}, std::byte{0xff}, std::byte{0xff}, + std::byte{0xff}, std::byte{0xff}, std::byte{0xff}, + std::byte{0x01}})); } diff --git a/vendor/blaze/DEPENDENCIES b/vendor/blaze/DEPENDENCIES index 30df177fd..9ae6e513f 100644 --- a/vendor/blaze/DEPENDENCIES +++ b/vendor/blaze/DEPENDENCIES @@ -1,6 +1,6 @@ vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02 -core https://github.com/sourcemeta/core 8018e9d85ef6fc0fd9ccd11c2ae438789214b00a -jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite c7257e92580678a086f0b9243a1903ed88bd27f7 +core https://github.com/sourcemeta/core 5d187a796444fef1b5e044c659800085a4be7ef4 +jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite 60755c1097769e313fae3ec4d63bcc9d49b5d2d5 jsonschema-2020-12 https://github.com/json-schema-org/json-schema-spec 769daad75a9553562333a8937a187741cb708c72 jsonschema-2019-09 https://github.com/json-schema-org/json-schema-spec 41014ea723120ce70b314d72f863c6929d9f3cfd jsonschema-draft7 https://github.com/json-schema-org/json-schema-spec 567f768506aaa33a38e552c85bf0586029ef1b32 diff --git a/vendor/blaze/config.cmake.in b/vendor/blaze/config.cmake.in index 499cd43c2..cd9163c56 100644 --- a/vendor/blaze/config.cmake.in +++ b/vendor/blaze/config.cmake.in @@ -20,7 +20,9 @@ if(NOT BLAZE_COMPONENTS) endif() include(CMakeFindDependencyMacro) -find_dependency(Core COMPONENTS regex uri uritemplate json jsonpointer io yaml crypto html email ip dns time) +find_dependency(Core COMPONENTS + unicode punycode idna regex uri uritemplate json + jsonpointer io yaml crypto html email ip dns time css) foreach(component ${BLAZE_COMPONENTS}) if(component STREQUAL "foundation") diff --git a/vendor/blaze/patches/jsonschema-test-suite/0001-draft3-ref-sibling.patch b/vendor/blaze/patches/jsonschema-test-suite/0001-draft3-ref-sibling.patch deleted file mode 100644 index 8c41d471b..000000000 --- a/vendor/blaze/patches/jsonschema-test-suite/0001-draft3-ref-sibling.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 95fec2442e66b3de6651972e5f7d4635ca6f7ff9 Mon Sep 17 00:00:00 2001 -From: Juan Cruz Viotti -Date: Tue, 5 May 2026 09:15:10 -0400 -Subject: [PATCH] Do not use `definitions` sibling to `$ref` in `ref.json` for - Draft 3 - -I'm extending Blaze to support Draft 3. As per the spec (applies to all drafts up to 7), a `$ref` overrides any sibling keyword. This seems to be the only case in the test suite where we do this. ---- - tests/draft3/ref.json | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/tests/draft3/ref.json b/tests/draft3/ref.json -index 609eaa46..6686c78e 100644 ---- a/tests/draft3/ref.json -+++ b/tests/draft3/ref.json -@@ -127,7 +127,9 @@ - "b": {"$ref": "#/definitions/a"}, - "c": {"$ref": "#/definitions/b"} - }, -- "$ref": "#/definitions/c" -+ "extends": { -+ "$ref": "#/definitions/c" -+ } - }, - "tests": [ - { diff --git a/vendor/blaze/ports/javascript/README.md b/vendor/blaze/ports/javascript/README.md index 1d1b8789f..57135f76b 100644 --- a/vendor/blaze/ports/javascript/README.md +++ b/vendor/blaze/ports/javascript/README.md @@ -133,3 +133,7 @@ Numeric keywords like `multipleOf` that depend on exact decimal arithmetic may produce incorrect results for real values that lose precision during parsing. The TC39 [Decimal proposal](https://github.com/tc39/proposal-decimal) (Stage 2) aims to address this in the future. + +**No Format Assertion vocabulary support.** While the C++ implementation of +Blaze fully implements the Format Assertion vocabulary, no such option exists +for JavaScript yet. Contributions in this area are welcomed. diff --git a/vendor/blaze/ports/javascript/describe.mjs b/vendor/blaze/ports/javascript/describe.mjs index 4f3b1050a..621e03038 100644 --- a/vendor/blaze/ports/javascript/describe.mjs +++ b/vendor/blaze/ports/javascript/describe.mjs @@ -83,6 +83,37 @@ function escapeString(input) { return '"' + String(input).replaceAll('"', '\\"') + '"'; } +function describeExtras(valid, target, allowed) { + if (valid || target === null || typeof target !== 'object' || + Array.isArray(target)) { + return ''; + } + + const extras = []; + for (const key in target) { + if (!allowed.has(key)) { + extras.push(key); + } + } + + if (extras.length === 0) return ''; + extras.sort(); + + if (extras.length === 1) { + return ', but it also defines the property ' + escapeString(extras[0]); + } + + let message = ', but it also defines properties '; + for (let index = 0; index < extras.length; index++) { + if (index === extras.length - 1) { + message += 'and ' + escapeString(extras[index]); + } else { + message += escapeString(extras[index]) + ', '; + } + } + return message; +} + function stringifyValue(value) { if (typeof value === 'bigint') return String(value); return JSON.stringify(value, (key, current) => @@ -944,7 +975,7 @@ export function describe(valid, instruction, evaluatePath, message += escapeString(sorted[index]) + ', '; } } - return message; + return message + describeExtras(valid, target, new Set(value)); } if (opcode === ASSERTION_DEFINES_EXACTLY_STRICT) { @@ -958,13 +989,15 @@ export function describe(valid, instruction, evaluatePath, message += escapeString(sorted[index]) + ', '; } } - return message; + return message + describeExtras(valid, target, new Set(value)); } if (opcode === ASSERTION_DEFINES_EXACTLY_STRICT_HASH3) { const entries = value[0]; - return 'The value was expected to be an object that only defines the ' + + const message = 'The value was expected to be an object that only defines the ' + entries.length + ' given properties'; + return message + describeExtras(valid, target, + new Set(entries.map(entry => entry[1]))); } if (opcode === ASSERTION_TYPE || opcode === ASSERTION_TYPE_STRICT) { diff --git a/vendor/blaze/src/alterschema/alterschema.cc b/vendor/blaze/src/alterschema/alterschema.cc index 2f1a6cb76..4e511019c 100644 --- a/vendor/blaze/src/alterschema/alterschema.cc +++ b/vendor/blaze/src/alterschema/alterschema.cc @@ -253,7 +253,9 @@ auto WALK_UP_IN_PLACE_APPLICATORS(const JSON &root, const SchemaFrame &frame, #include "linter/items_array_default.h" #include "linter/items_schema_default.h" #include "linter/multiple_of_default.h" +#include "linter/pattern_non_ecma_regex.h" #include "linter/pattern_properties_default.h" +#include "linter/pattern_properties_non_ecma_regex.h" #include "linter/portable_anchor_names.h" #include "linter/properties_default.h" #include "linter/property_names_default.h" @@ -459,6 +461,8 @@ auto add(SchemaTransformer &bundle, const AlterSchemaMode mode) -> void { bundle.add(); bundle.add(); bundle.add(); + bundle.add(); + bundle.add(); bundle.add(); bundle.add(); bundle.add(); diff --git a/vendor/blaze/src/alterschema/canonicalizer/additional_items_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/additional_items_implicit.h index 74a38f8f7..9badd20a7 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/additional_items_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/additional_items_implicit.h @@ -12,7 +12,7 @@ class AdditionalItemsImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/canonicalizer/allof_merge_compatible_branches.h b/vendor/blaze/src/alterschema/canonicalizer/allof_merge_compatible_branches.h index b79d88c25..507bcd497 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/allof_merge_compatible_branches.h +++ b/vendor/blaze/src/alterschema/canonicalizer/allof_merge_compatible_branches.h @@ -12,7 +12,7 @@ class AllOfMergeCompatibleBranches final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"allOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/comment_drop.h b/vendor/blaze/src/alterschema/canonicalizer/comment_drop.h index 8c12e8ec1..713eca547 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/comment_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/comment_drop.h @@ -11,7 +11,7 @@ class CommentDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_7, diff --git a/vendor/blaze/src/alterschema/canonicalizer/const_as_enum.h b/vendor/blaze/src/alterschema/canonicalizer/const_as_enum.h index 4d65ac9e0..f4ec73653 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/const_as_enum.h +++ b/vendor/blaze/src/alterschema/canonicalizer/const_as_enum.h @@ -14,7 +14,7 @@ class ConstAsEnum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/canonicalizer/dependencies_to_any_of.h b/vendor/blaze/src/alterschema/canonicalizer/dependencies_to_any_of.h index 29cd2c731..06945a467 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/dependencies_to_any_of.h +++ b/vendor/blaze/src/alterschema/canonicalizer/dependencies_to_any_of.h @@ -11,7 +11,7 @@ class DependenciesToAnyOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_4, diff --git a/vendor/blaze/src/alterschema/canonicalizer/dependencies_to_extends_disallow.h b/vendor/blaze/src/alterschema/canonicalizer/dependencies_to_extends_disallow.h index 488784522..24a27b0a5 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/dependencies_to_extends_disallow.h +++ b/vendor/blaze/src/alterschema/canonicalizer/dependencies_to_extends_disallow.h @@ -12,7 +12,7 @@ class DependenciesToExtendsDisallow final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_3) && diff --git a/vendor/blaze/src/alterschema/canonicalizer/dependent_required_to_any_of.h b/vendor/blaze/src/alterschema/canonicalizer/dependent_required_to_any_of.h index 59fc087e2..2bf641b4f 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/dependent_required_to_any_of.h +++ b/vendor/blaze/src/alterschema/canonicalizer/dependent_required_to_any_of.h @@ -12,7 +12,7 @@ class DependentRequiredToAnyOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/dependent_schemas_to_any_of.h b/vendor/blaze/src/alterschema/canonicalizer/dependent_schemas_to_any_of.h index 6420a49c8..9ea0aa69a 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/dependent_schemas_to_any_of.h +++ b/vendor/blaze/src/alterschema/canonicalizer/dependent_schemas_to_any_of.h @@ -12,7 +12,7 @@ class DependentSchemasToAnyOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/deprecated_false_drop.h b/vendor/blaze/src/alterschema/canonicalizer/deprecated_false_drop.h index 4fe2cc14b..d9218527b 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/deprecated_false_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/deprecated_false_drop.h @@ -11,7 +11,7 @@ class DeprecatedFalseDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/disallow_to_array_of_schemas.h b/vendor/blaze/src/alterschema/canonicalizer/disallow_to_array_of_schemas.h index b9fbc4258..a81b779d3 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/disallow_to_array_of_schemas.h +++ b/vendor/blaze/src/alterschema/canonicalizer/disallow_to_array_of_schemas.h @@ -12,7 +12,7 @@ class DisallowToArrayOfSchemas final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/divisible_by_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/divisible_by_implicit.h index 5a65c46c4..e6a0fdcd1 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/divisible_by_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/divisible_by_implicit.h @@ -11,7 +11,7 @@ class DivisibleByImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_2, diff --git a/vendor/blaze/src/alterschema/canonicalizer/draft3_type_any.h b/vendor/blaze/src/alterschema/canonicalizer/draft3_type_any.h index fcf2833ec..d16c1b73b 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/draft3_type_any.h +++ b/vendor/blaze/src/alterschema/canonicalizer/draft3_type_any.h @@ -11,7 +11,7 @@ class Draft3TypeAny final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_3) && diff --git a/vendor/blaze/src/alterschema/canonicalizer/empty_definitions_drop.h b/vendor/blaze/src/alterschema/canonicalizer/empty_definitions_drop.h index 74a40d866..a2fff0e0b 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/empty_definitions_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/empty_definitions_drop.h @@ -11,7 +11,7 @@ class EmptyDefinitionsDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_4, diff --git a/vendor/blaze/src/alterschema/canonicalizer/empty_defs_drop.h b/vendor/blaze/src/alterschema/canonicalizer/empty_defs_drop.h index 2e013dfe7..ad0e80eb0 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/empty_defs_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/empty_defs_drop.h @@ -11,7 +11,7 @@ class EmptyDefsDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2019_09_Core, diff --git a/vendor/blaze/src/alterschema/canonicalizer/empty_dependencies_drop.h b/vendor/blaze/src/alterschema/canonicalizer/empty_dependencies_drop.h index c1d91f3a5..249bdb7b5 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/empty_dependencies_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/empty_dependencies_drop.h @@ -12,7 +12,7 @@ class EmptyDependenciesDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/canonicalizer/empty_dependent_required_drop.h b/vendor/blaze/src/alterschema/canonicalizer/empty_dependent_required_drop.h index cdf3967ac..6e04d1fa8 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/empty_dependent_required_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/empty_dependent_required_drop.h @@ -12,7 +12,7 @@ class EmptyDependentRequiredDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/empty_dependent_schemas_drop.h b/vendor/blaze/src/alterschema/canonicalizer/empty_dependent_schemas_drop.h index 24900ff11..794fb530b 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/empty_dependent_schemas_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/empty_dependent_schemas_drop.h @@ -12,7 +12,7 @@ class EmptyDependentSchemasDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/enum_drop_redundant_validation.h b/vendor/blaze/src/alterschema/canonicalizer/enum_drop_redundant_validation.h index 78fe1081b..8a4d9b515 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/enum_drop_redundant_validation.h +++ b/vendor/blaze/src/alterschema/canonicalizer/enum_drop_redundant_validation.h @@ -12,7 +12,7 @@ class EnumDropRedundantValidation final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/enum_filter_by_type.h b/vendor/blaze/src/alterschema/canonicalizer/enum_filter_by_type.h index 9e3098b48..685ccc1ad 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/enum_filter_by_type.h +++ b/vendor/blaze/src/alterschema/canonicalizer/enum_filter_by_type.h @@ -11,7 +11,7 @@ class EnumFilterByType final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/exclusive_maximum_boolean_integer_fold.h b/vendor/blaze/src/alterschema/canonicalizer/exclusive_maximum_boolean_integer_fold.h index e1cc9b47c..585e8dd28 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/exclusive_maximum_boolean_integer_fold.h +++ b/vendor/blaze/src/alterschema/canonicalizer/exclusive_maximum_boolean_integer_fold.h @@ -12,7 +12,7 @@ class ExclusiveMaximumBooleanIntegerFold final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/canonicalizer/exclusive_maximum_integer_to_maximum.h b/vendor/blaze/src/alterschema/canonicalizer/exclusive_maximum_integer_to_maximum.h index 148b82eb2..02bd609d5 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/exclusive_maximum_integer_to_maximum.h +++ b/vendor/blaze/src/alterschema/canonicalizer/exclusive_maximum_integer_to_maximum.h @@ -15,7 +15,7 @@ class ExclusiveMaximumIntegerToMaximum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/canonicalizer/exclusive_minimum_boolean_integer_fold.h b/vendor/blaze/src/alterschema/canonicalizer/exclusive_minimum_boolean_integer_fold.h index fcdd42d59..b16a78d93 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/exclusive_minimum_boolean_integer_fold.h +++ b/vendor/blaze/src/alterschema/canonicalizer/exclusive_minimum_boolean_integer_fold.h @@ -12,7 +12,7 @@ class ExclusiveMinimumBooleanIntegerFold final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/canonicalizer/exclusive_minimum_integer_to_minimum.h b/vendor/blaze/src/alterschema/canonicalizer/exclusive_minimum_integer_to_minimum.h index 31fc5534e..9adaae611 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/exclusive_minimum_integer_to_minimum.h +++ b/vendor/blaze/src/alterschema/canonicalizer/exclusive_minimum_integer_to_minimum.h @@ -15,7 +15,7 @@ class ExclusiveMinimumIntegerToMinimum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/canonicalizer/extends_to_array.h b/vendor/blaze/src/alterschema/canonicalizer/extends_to_array.h index 10c0b0b49..7799efd48 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/extends_to_array.h +++ b/vendor/blaze/src/alterschema/canonicalizer/extends_to_array.h @@ -11,7 +11,7 @@ class ExtendsToArray final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/if_then_else_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/if_then_else_implicit.h index 9b9c66fe6..0a2658adc 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/if_then_else_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/if_then_else_implicit.h @@ -11,7 +11,7 @@ class IfThenElseImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/implicit_contains_keywords.h b/vendor/blaze/src/alterschema/canonicalizer/implicit_contains_keywords.h index 263f7a3b7..1f9a579c1 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/implicit_contains_keywords.h +++ b/vendor/blaze/src/alterschema/canonicalizer/implicit_contains_keywords.h @@ -12,7 +12,7 @@ class ImplicitContainsKeywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/implicit_object_keywords.h b/vendor/blaze/src/alterschema/canonicalizer/implicit_object_keywords.h index 5fc4ed22b..b0bf42d83 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/implicit_object_keywords.h +++ b/vendor/blaze/src/alterschema/canonicalizer/implicit_object_keywords.h @@ -12,7 +12,7 @@ class ImplicitObjectKeywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object()); diff --git a/vendor/blaze/src/alterschema/canonicalizer/inline_single_use_ref.h b/vendor/blaze/src/alterschema/canonicalizer/inline_single_use_ref.h index 3dbe6b251..2ea6bf44b 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/inline_single_use_ref.h +++ b/vendor/blaze/src/alterschema/canonicalizer/inline_single_use_ref.h @@ -11,7 +11,7 @@ class InlineSingleUseRef final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object() && schema.size() == 1); diff --git a/vendor/blaze/src/alterschema/canonicalizer/items_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/items_implicit.h index 7436e72f1..9ff3db9b1 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/items_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/items_implicit.h @@ -14,7 +14,7 @@ class ItemsImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( ((vocabularies.contains( diff --git a/vendor/blaze/src/alterschema/canonicalizer/max_contains_covered_by_max_items.h b/vendor/blaze/src/alterschema/canonicalizer/max_contains_covered_by_max_items.h index c4a2f7ba8..30a964036 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/max_contains_covered_by_max_items.h +++ b/vendor/blaze/src/alterschema/canonicalizer/max_contains_covered_by_max_items.h @@ -16,7 +16,7 @@ class MaxContainsCoveredByMaxItems final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/max_decimal_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/max_decimal_implicit.h index cc705a520..d90985420 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/max_decimal_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/max_decimal_implicit.h @@ -11,7 +11,7 @@ class MaxDecimalImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/maximum_can_equal_integer_fold.h b/vendor/blaze/src/alterschema/canonicalizer/maximum_can_equal_integer_fold.h index fc00372a8..c98f20f15 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/maximum_can_equal_integer_fold.h +++ b/vendor/blaze/src/alterschema/canonicalizer/maximum_can_equal_integer_fold.h @@ -12,7 +12,7 @@ class MaximumCanEqualIntegerFold final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/maximum_can_equal_true_drop.h b/vendor/blaze/src/alterschema/canonicalizer/maximum_can_equal_true_drop.h index 58fa43e70..ee2faaa90 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/maximum_can_equal_true_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/maximum_can_equal_true_drop.h @@ -12,7 +12,7 @@ class MaximumCanEqualTrueDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/min_items_given_min_contains.h b/vendor/blaze/src/alterschema/canonicalizer/min_items_given_min_contains.h index 89684d9cf..26bcb141b 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/min_items_given_min_contains.h +++ b/vendor/blaze/src/alterschema/canonicalizer/min_items_given_min_contains.h @@ -15,7 +15,7 @@ class MinItemsGivenMinContains final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/min_length_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/min_length_implicit.h index 7f90c7714..931671832 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/min_length_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/min_length_implicit.h @@ -14,7 +14,7 @@ class MinLengthImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/canonicalizer/min_properties_covered_by_required.h b/vendor/blaze/src/alterschema/canonicalizer/min_properties_covered_by_required.h index d2b19a74a..e74625955 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/min_properties_covered_by_required.h +++ b/vendor/blaze/src/alterschema/canonicalizer/min_properties_covered_by_required.h @@ -15,7 +15,7 @@ class MinPropertiesCoveredByRequired final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/canonicalizer/minimum_can_equal_integer_fold.h b/vendor/blaze/src/alterschema/canonicalizer/minimum_can_equal_integer_fold.h index 05e010e7c..48460e63e 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/minimum_can_equal_integer_fold.h +++ b/vendor/blaze/src/alterschema/canonicalizer/minimum_can_equal_integer_fold.h @@ -12,7 +12,7 @@ class MinimumCanEqualIntegerFold final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/minimum_can_equal_true_drop.h b/vendor/blaze/src/alterschema/canonicalizer/minimum_can_equal_true_drop.h index 53f6cf16c..4085eb0db 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/minimum_can_equal_true_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/minimum_can_equal_true_drop.h @@ -12,7 +12,7 @@ class MinimumCanEqualTrueDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/multiple_of_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/multiple_of_implicit.h index d17cea25e..aa59e3401 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/multiple_of_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/multiple_of_implicit.h @@ -13,7 +13,7 @@ class MultipleOfImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/canonicalizer/optional_property_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/optional_property_implicit.h index 0931e3a66..bf9efb626 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/optional_property_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/optional_property_implicit.h @@ -12,7 +12,7 @@ class OptionalPropertyImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/recursive_anchor_false_drop.h b/vendor/blaze/src/alterschema/canonicalizer/recursive_anchor_false_drop.h index 5d26fb878..d9b9310ba 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/recursive_anchor_false_drop.h +++ b/vendor/blaze/src/alterschema/canonicalizer/recursive_anchor_false_drop.h @@ -12,7 +12,7 @@ class RecursiveAnchorFalseDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_2019_09_Core) && diff --git a/vendor/blaze/src/alterschema/canonicalizer/required_property_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/required_property_implicit.h index 56924c85d..ffc862da1 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/required_property_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/required_property_implicit.h @@ -12,7 +12,7 @@ class RequiredPropertyImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_3) && diff --git a/vendor/blaze/src/alterschema/canonicalizer/single_branch_allof.h b/vendor/blaze/src/alterschema/canonicalizer/single_branch_allof.h index 424adfc43..1182d3805 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/single_branch_allof.h +++ b/vendor/blaze/src/alterschema/canonicalizer/single_branch_allof.h @@ -11,7 +11,7 @@ class SingleBranchAllOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"allOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/single_branch_anyof.h b/vendor/blaze/src/alterschema/canonicalizer/single_branch_anyof.h index 09f87461a..7d1edf13e 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/single_branch_anyof.h +++ b/vendor/blaze/src/alterschema/canonicalizer/single_branch_anyof.h @@ -11,7 +11,7 @@ class SingleBranchAnyOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"anyOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/single_branch_oneof.h b/vendor/blaze/src/alterschema/canonicalizer/single_branch_oneof.h index 0d0f130f3..ca989b2bd 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/single_branch_oneof.h +++ b/vendor/blaze/src/alterschema/canonicalizer/single_branch_oneof.h @@ -11,7 +11,7 @@ class SingleBranchOneOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"oneOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/type_array_to_any_of.h b/vendor/blaze/src/alterschema/canonicalizer/type_array_to_any_of.h index 3eb2ad4e9..5dbedf63b 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/type_array_to_any_of.h +++ b/vendor/blaze/src/alterschema/canonicalizer/type_array_to_any_of.h @@ -15,7 +15,7 @@ class TypeArrayToAnyOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/type_boolean_as_enum.h b/vendor/blaze/src/alterschema/canonicalizer/type_boolean_as_enum.h index 010746958..8dea52de6 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/type_boolean_as_enum.h +++ b/vendor/blaze/src/alterschema/canonicalizer/type_boolean_as_enum.h @@ -15,7 +15,7 @@ class TypeBooleanAsEnum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/canonicalizer/type_inherit_in_place.h b/vendor/blaze/src/alterschema/canonicalizer/type_inherit_in_place.h index bbaa021be..c13edb81b 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/type_inherit_in_place.h +++ b/vendor/blaze/src/alterschema/canonicalizer/type_inherit_in_place.h @@ -15,7 +15,7 @@ class TypeInheritInPlace final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { using namespace sourcemeta::core; ONLY_CONTINUE_IF(schema.is_object()); diff --git a/vendor/blaze/src/alterschema/canonicalizer/type_null_as_enum.h b/vendor/blaze/src/alterschema/canonicalizer/type_null_as_enum.h index ef007dfa9..e8b4e62f8 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/type_null_as_enum.h +++ b/vendor/blaze/src/alterschema/canonicalizer/type_null_as_enum.h @@ -15,7 +15,7 @@ class TypeNullAsEnum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/canonicalizer/type_union_implicit.h b/vendor/blaze/src/alterschema/canonicalizer/type_union_implicit.h index 81ccfbdc5..4d40c9b2c 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/type_union_implicit.h +++ b/vendor/blaze/src/alterschema/canonicalizer/type_union_implicit.h @@ -14,7 +14,7 @@ class TypeUnionImplicit final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { using namespace sourcemeta::core; ONLY_CONTINUE_IF(schema.is_object() && !schema.empty()); diff --git a/vendor/blaze/src/alterschema/canonicalizer/type_union_to_schemas.h b/vendor/blaze/src/alterschema/canonicalizer/type_union_to_schemas.h index 6a277796a..dd914cbc9 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/type_union_to_schemas.h +++ b/vendor/blaze/src/alterschema/canonicalizer/type_union_to_schemas.h @@ -11,7 +11,7 @@ class TypeUnionToSchemas final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/type_with_applicator_to_allof.h b/vendor/blaze/src/alterschema/canonicalizer/type_with_applicator_to_allof.h index c85f09348..11831cfe8 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/type_with_applicator_to_allof.h +++ b/vendor/blaze/src/alterschema/canonicalizer/type_with_applicator_to_allof.h @@ -12,7 +12,7 @@ class TypeWithApplicatorToAllOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/type_with_applicator_to_extends.h b/vendor/blaze/src/alterschema/canonicalizer/type_with_applicator_to_extends.h index fc31d2801..97482a858 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/type_with_applicator_to_extends.h +++ b/vendor/blaze/src/alterschema/canonicalizer/type_with_applicator_to_extends.h @@ -12,7 +12,7 @@ class TypeWithApplicatorToExtends final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_0, diff --git a/vendor/blaze/src/alterschema/canonicalizer/unevaluated_items_to_items.h b/vendor/blaze/src/alterschema/canonicalizer/unevaluated_items_to_items.h index 146095014..36716bc0e 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/unevaluated_items_to_items.h +++ b/vendor/blaze/src/alterschema/canonicalizer/unevaluated_items_to_items.h @@ -12,7 +12,7 @@ class UnevaluatedItemsToItems final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/unevaluated_properties_to_additional_properties.h b/vendor/blaze/src/alterschema/canonicalizer/unevaluated_properties_to_additional_properties.h index 39cf18028..d309d75b1 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/unevaluated_properties_to_additional_properties.h +++ b/vendor/blaze/src/alterschema/canonicalizer/unevaluated_properties_to_additional_properties.h @@ -14,7 +14,7 @@ class UnevaluatedPropertiesToAdditionalProperties final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_can_equal_bounds.h b/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_can_equal_bounds.h index f38ba240a..c2c85dbd1 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_can_equal_bounds.h +++ b/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_can_equal_bounds.h @@ -12,7 +12,7 @@ class UnsatisfiableCanEqualBounds final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_2) && diff --git a/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_exclusive_equal_bounds.h b/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_exclusive_equal_bounds.h index c0f411868..5f694ac29 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_exclusive_equal_bounds.h +++ b/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_exclusive_equal_bounds.h @@ -12,7 +12,7 @@ class UnsatisfiableExclusiveEqualBounds final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_type_and_enum.h b/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_type_and_enum.h index a90df7e0e..8d74ed3ee 100644 --- a/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_type_and_enum.h +++ b/vendor/blaze/src/alterschema/canonicalizer/unsatisfiable_type_and_enum.h @@ -12,7 +12,7 @@ class UnsatisfiableTypeAndEnum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/allof_false_simplify.h b/vendor/blaze/src/alterschema/common/allof_false_simplify.h index fc4111df0..890f1da30 100644 --- a/vendor/blaze/src/alterschema/common/allof_false_simplify.h +++ b/vendor/blaze/src/alterschema/common/allof_false_simplify.h @@ -14,7 +14,7 @@ class AllOfFalseSimplify final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"allOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/anyof_false_simplify.h b/vendor/blaze/src/alterschema/common/anyof_false_simplify.h index 1bfb77f9f..e6888b3a3 100644 --- a/vendor/blaze/src/alterschema/common/anyof_false_simplify.h +++ b/vendor/blaze/src/alterschema/common/anyof_false_simplify.h @@ -14,7 +14,7 @@ class AnyOfFalseSimplify final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"anyOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/anyof_remove_false_schemas.h b/vendor/blaze/src/alterschema/common/anyof_remove_false_schemas.h index 4670da1b4..38e22bd56 100644 --- a/vendor/blaze/src/alterschema/common/anyof_remove_false_schemas.h +++ b/vendor/blaze/src/alterschema/common/anyof_remove_false_schemas.h @@ -15,7 +15,7 @@ class AnyOfRemoveFalseSchemas final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"anyOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/anyof_true_simplify.h b/vendor/blaze/src/alterschema/common/anyof_true_simplify.h index b79a4e96f..40c0af0e5 100644 --- a/vendor/blaze/src/alterschema/common/anyof_true_simplify.h +++ b/vendor/blaze/src/alterschema/common/anyof_true_simplify.h @@ -14,7 +14,7 @@ class AnyOfTrueSimplify final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"anyOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/const_in_enum.h b/vendor/blaze/src/alterschema/common/const_in_enum.h index baaeb2f38..305d96ffc 100644 --- a/vendor/blaze/src/alterschema/common/const_in_enum.h +++ b/vendor/blaze/src/alterschema/common/const_in_enum.h @@ -15,7 +15,7 @@ class ConstInEnum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/const_with_type.h b/vendor/blaze/src/alterschema/common/const_with_type.h index 4fc2dfefa..118184f97 100644 --- a/vendor/blaze/src/alterschema/common/const_with_type.h +++ b/vendor/blaze/src/alterschema/common/const_with_type.h @@ -15,7 +15,7 @@ class ConstWithType final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/content_media_type_without_encoding.h b/vendor/blaze/src/alterschema/common/content_media_type_without_encoding.h index 23aa9a74a..d40c84578 100644 --- a/vendor/blaze/src/alterschema/common/content_media_type_without_encoding.h +++ b/vendor/blaze/src/alterschema/common/content_media_type_without_encoding.h @@ -15,7 +15,7 @@ class ContentMediaTypeWithoutEncoding final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Content, diff --git a/vendor/blaze/src/alterschema/common/content_schema_without_media_type.h b/vendor/blaze/src/alterschema/common/content_schema_without_media_type.h index c4b376e0f..2e0012dc9 100644 --- a/vendor/blaze/src/alterschema/common/content_schema_without_media_type.h +++ b/vendor/blaze/src/alterschema/common/content_schema_without_media_type.h @@ -18,7 +18,7 @@ class ContentSchemaWithoutMediaType final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Content, diff --git a/vendor/blaze/src/alterschema/common/dependencies_property_tautology.h b/vendor/blaze/src/alterschema/common/dependencies_property_tautology.h index 22b503307..0c094a6a8 100644 --- a/vendor/blaze/src/alterschema/common/dependencies_property_tautology.h +++ b/vendor/blaze/src/alterschema/common/dependencies_property_tautology.h @@ -16,7 +16,7 @@ class DependenciesPropertyTautology final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_7, diff --git a/vendor/blaze/src/alterschema/common/dependent_required_tautology.h b/vendor/blaze/src/alterschema/common/dependent_required_tautology.h index 8d344457d..ccf74fb30 100644 --- a/vendor/blaze/src/alterschema/common/dependent_required_tautology.h +++ b/vendor/blaze/src/alterschema/common/dependent_required_tautology.h @@ -16,7 +16,7 @@ class DependentRequiredTautology final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/disallow_narrows_type.h b/vendor/blaze/src/alterschema/common/disallow_narrows_type.h index 54c32a8b1..95e554863 100644 --- a/vendor/blaze/src/alterschema/common/disallow_narrows_type.h +++ b/vendor/blaze/src/alterschema/common/disallow_narrows_type.h @@ -16,7 +16,7 @@ class DisallowNarrowsType final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"disallow"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/double_negation_elimination.h b/vendor/blaze/src/alterschema/common/double_negation_elimination.h index 17e5d4ea1..3e6a25e8c 100644 --- a/vendor/blaze/src/alterschema/common/double_negation_elimination.h +++ b/vendor/blaze/src/alterschema/common/double_negation_elimination.h @@ -15,7 +15,7 @@ class DoubleNegationElimination final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"not"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/draft_official_dialect_with_https.h b/vendor/blaze/src/alterschema/common/draft_official_dialect_with_https.h index afbdf755e..e14002838 100644 --- a/vendor/blaze/src/alterschema/common/draft_official_dialect_with_https.h +++ b/vendor/blaze/src/alterschema/common/draft_official_dialect_with_https.h @@ -15,7 +15,7 @@ class DraftOfficialDialectWithHttps final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { using sourcemeta::blaze::SchemaBaseDialect; ONLY_CONTINUE_IF( diff --git a/vendor/blaze/src/alterschema/common/draft_official_dialect_without_empty_fragment.h b/vendor/blaze/src/alterschema/common/draft_official_dialect_without_empty_fragment.h index 99159c330..18938fcdf 100644 --- a/vendor/blaze/src/alterschema/common/draft_official_dialect_without_empty_fragment.h +++ b/vendor/blaze/src/alterschema/common/draft_official_dialect_without_empty_fragment.h @@ -14,7 +14,8 @@ class DraftOfficialDialectWithoutEmptyFragment final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, + const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object()); const auto *schema_keyword{schema.try_at("$schema")}; diff --git a/vendor/blaze/src/alterschema/common/draft_ref_siblings.h b/vendor/blaze/src/alterschema/common/draft_ref_siblings.h index 749b281e1..9b1818247 100644 --- a/vendor/blaze/src/alterschema/common/draft_ref_siblings.h +++ b/vendor/blaze/src/alterschema/common/draft_ref_siblings.h @@ -14,7 +14,7 @@ class DraftRefSiblings final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_7, diff --git a/vendor/blaze/src/alterschema/common/drop_allof_empty_schemas.h b/vendor/blaze/src/alterschema/common/drop_allof_empty_schemas.h index f256f03dd..10e0f596b 100644 --- a/vendor/blaze/src/alterschema/common/drop_allof_empty_schemas.h +++ b/vendor/blaze/src/alterschema/common/drop_allof_empty_schemas.h @@ -10,7 +10,7 @@ class DropAllOfEmptySchemas final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &, const SchemaFrame::Location &, - const SchemaWalker &, const SchemaResolver &) const + const SchemaWalker &, const SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/common/drop_extends_empty_schemas.h b/vendor/blaze/src/alterschema/common/drop_extends_empty_schemas.h index 5e990fd36..53c358ffc 100644 --- a/vendor/blaze/src/alterschema/common/drop_extends_empty_schemas.h +++ b/vendor/blaze/src/alterschema/common/drop_extends_empty_schemas.h @@ -14,7 +14,7 @@ class DropExtendsEmptySchemas final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"extends"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/duplicate_allof_branches.h b/vendor/blaze/src/alterschema/common/duplicate_allof_branches.h index 7ef75d20e..f2c972263 100644 --- a/vendor/blaze/src/alterschema/common/duplicate_allof_branches.h +++ b/vendor/blaze/src/alterschema/common/duplicate_allof_branches.h @@ -17,7 +17,7 @@ class DuplicateAllOfBranches final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/common/duplicate_anyof_branches.h b/vendor/blaze/src/alterschema/common/duplicate_anyof_branches.h index ff0b03044..9dbd4c3d9 100644 --- a/vendor/blaze/src/alterschema/common/duplicate_anyof_branches.h +++ b/vendor/blaze/src/alterschema/common/duplicate_anyof_branches.h @@ -17,7 +17,7 @@ class DuplicateAnyOfBranches final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/common/duplicate_enum_values.h b/vendor/blaze/src/alterschema/common/duplicate_enum_values.h index 561fb19a9..c6ffea469 100644 --- a/vendor/blaze/src/alterschema/common/duplicate_enum_values.h +++ b/vendor/blaze/src/alterschema/common/duplicate_enum_values.h @@ -14,7 +14,7 @@ class DuplicateEnumValues final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/duplicate_required_values.h b/vendor/blaze/src/alterschema/common/duplicate_required_values.h index 657afa4b4..e5aae340c 100644 --- a/vendor/blaze/src/alterschema/common/duplicate_required_values.h +++ b/vendor/blaze/src/alterschema/common/duplicate_required_values.h @@ -15,7 +15,7 @@ class DuplicateRequiredValues final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/dynamic_ref_to_static_ref.h b/vendor/blaze/src/alterschema/common/dynamic_ref_to_static_ref.h index babd3baf4..628d58a9a 100644 --- a/vendor/blaze/src/alterschema/common/dynamic_ref_to_static_ref.h +++ b/vendor/blaze/src/alterschema/common/dynamic_ref_to_static_ref.h @@ -19,7 +19,7 @@ class DynamicRefToStaticRef final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object() && !schema.defines("$ref")); diff --git a/vendor/blaze/src/alterschema/common/else_without_if.h b/vendor/blaze/src/alterschema/common/else_without_if.h index 38fcdf73d..11a7bc45d 100644 --- a/vendor/blaze/src/alterschema/common/else_without_if.h +++ b/vendor/blaze/src/alterschema/common/else_without_if.h @@ -17,7 +17,7 @@ class ElseWithoutIf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/common/empty_object_as_true.h b/vendor/blaze/src/alterschema/common/empty_object_as_true.h index 3266747bd..30b12ca7f 100644 --- a/vendor/blaze/src/alterschema/common/empty_object_as_true.h +++ b/vendor/blaze/src/alterschema/common/empty_object_as_true.h @@ -15,7 +15,7 @@ class EmptyObjectAsTrue final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Core, diff --git a/vendor/blaze/src/alterschema/common/enum_with_type.h b/vendor/blaze/src/alterschema/common/enum_with_type.h index a04d36a3f..c9a7d5452 100644 --- a/vendor/blaze/src/alterschema/common/enum_with_type.h +++ b/vendor/blaze/src/alterschema/common/enum_with_type.h @@ -15,7 +15,7 @@ class EnumWithType final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/equal_numeric_bounds_to_enum.h b/vendor/blaze/src/alterschema/common/equal_numeric_bounds_to_enum.h index bc20685b1..af38676fc 100644 --- a/vendor/blaze/src/alterschema/common/equal_numeric_bounds_to_enum.h +++ b/vendor/blaze/src/alterschema/common/equal_numeric_bounds_to_enum.h @@ -15,7 +15,7 @@ class EqualNumericBoundsToEnum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_4, diff --git a/vendor/blaze/src/alterschema/common/exclusive_bounds_false_drop.h b/vendor/blaze/src/alterschema/common/exclusive_bounds_false_drop.h index 37d0062b9..e2748bfaf 100644 --- a/vendor/blaze/src/alterschema/common/exclusive_bounds_false_drop.h +++ b/vendor/blaze/src/alterschema/common/exclusive_bounds_false_drop.h @@ -15,7 +15,7 @@ class ExclusiveBoundsFalseDrop final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/common/exclusive_maximum_number_and_maximum.h b/vendor/blaze/src/alterschema/common/exclusive_maximum_number_and_maximum.h index 9e53efcdc..c5c5704b8 100644 --- a/vendor/blaze/src/alterschema/common/exclusive_maximum_number_and_maximum.h +++ b/vendor/blaze/src/alterschema/common/exclusive_maximum_number_and_maximum.h @@ -15,7 +15,7 @@ class ExclusiveMaximumNumberAndMaximum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/exclusive_minimum_number_and_minimum.h b/vendor/blaze/src/alterschema/common/exclusive_minimum_number_and_minimum.h index 46a1b10d0..85c6ef111 100644 --- a/vendor/blaze/src/alterschema/common/exclusive_minimum_number_and_minimum.h +++ b/vendor/blaze/src/alterschema/common/exclusive_minimum_number_and_minimum.h @@ -15,7 +15,7 @@ class ExclusiveMinimumNumberAndMinimum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/flatten_nested_allof.h b/vendor/blaze/src/alterschema/common/flatten_nested_allof.h index ca0aa3a29..bdd05eda9 100644 --- a/vendor/blaze/src/alterschema/common/flatten_nested_allof.h +++ b/vendor/blaze/src/alterschema/common/flatten_nested_allof.h @@ -15,7 +15,7 @@ class FlattenNestedAllOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"allOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/flatten_nested_anyof.h b/vendor/blaze/src/alterschema/common/flatten_nested_anyof.h index d0c04ca5d..fda43228b 100644 --- a/vendor/blaze/src/alterschema/common/flatten_nested_anyof.h +++ b/vendor/blaze/src/alterschema/common/flatten_nested_anyof.h @@ -15,7 +15,7 @@ class FlattenNestedAnyOf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"anyOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/flatten_nested_extends.h b/vendor/blaze/src/alterschema/common/flatten_nested_extends.h index 187ffc36b..9863cd548 100644 --- a/vendor/blaze/src/alterschema/common/flatten_nested_extends.h +++ b/vendor/blaze/src/alterschema/common/flatten_nested_extends.h @@ -15,7 +15,7 @@ class FlattenNestedExtends final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"extends"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/if_without_then_else.h b/vendor/blaze/src/alterschema/common/if_without_then_else.h index 790a49a70..eb646ecde 100644 --- a/vendor/blaze/src/alterschema/common/if_without_then_else.h +++ b/vendor/blaze/src/alterschema/common/if_without_then_else.h @@ -18,7 +18,7 @@ class IfWithoutThenElse final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/common/ignored_metaschema.h b/vendor/blaze/src/alterschema/common/ignored_metaschema.h index 181a39ef5..12e6f181d 100644 --- a/vendor/blaze/src/alterschema/common/ignored_metaschema.h +++ b/vendor/blaze/src/alterschema/common/ignored_metaschema.h @@ -15,7 +15,7 @@ class IgnoredMetaschema final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object()); const auto *schema_keyword{schema.try_at("$schema")}; diff --git a/vendor/blaze/src/alterschema/common/max_contains_without_contains.h b/vendor/blaze/src/alterschema/common/max_contains_without_contains.h index afacf26e2..599425d4d 100644 --- a/vendor/blaze/src/alterschema/common/max_contains_without_contains.h +++ b/vendor/blaze/src/alterschema/common/max_contains_without_contains.h @@ -15,7 +15,7 @@ class MaxContainsWithoutContains final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/maximum_real_for_integer.h b/vendor/blaze/src/alterschema/common/maximum_real_for_integer.h index 17b25cf5f..0ad243134 100644 --- a/vendor/blaze/src/alterschema/common/maximum_real_for_integer.h +++ b/vendor/blaze/src/alterschema/common/maximum_real_for_integer.h @@ -15,7 +15,7 @@ class MaximumRealForInteger final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/min_contains_without_contains.h b/vendor/blaze/src/alterschema/common/min_contains_without_contains.h index b202ec8e5..0859c0678 100644 --- a/vendor/blaze/src/alterschema/common/min_contains_without_contains.h +++ b/vendor/blaze/src/alterschema/common/min_contains_without_contains.h @@ -15,7 +15,7 @@ class MinContainsWithoutContains final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/minimum_real_for_integer.h b/vendor/blaze/src/alterschema/common/minimum_real_for_integer.h index a3e894993..a3a6f692e 100644 --- a/vendor/blaze/src/alterschema/common/minimum_real_for_integer.h +++ b/vendor/blaze/src/alterschema/common/minimum_real_for_integer.h @@ -15,7 +15,7 @@ class MinimumRealForInteger final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/modern_official_dialect_with_empty_fragment.h b/vendor/blaze/src/alterschema/common/modern_official_dialect_with_empty_fragment.h index cedd25239..dad940c02 100644 --- a/vendor/blaze/src/alterschema/common/modern_official_dialect_with_empty_fragment.h +++ b/vendor/blaze/src/alterschema/common/modern_official_dialect_with_empty_fragment.h @@ -15,7 +15,8 @@ class ModernOfficialDialectWithEmptyFragment final const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, + const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object()); const auto *schema_keyword{schema.try_at("$schema")}; diff --git a/vendor/blaze/src/alterschema/common/modern_official_dialect_with_http.h b/vendor/blaze/src/alterschema/common/modern_official_dialect_with_http.h index 2efde16de..0f34bc725 100644 --- a/vendor/blaze/src/alterschema/common/modern_official_dialect_with_http.h +++ b/vendor/blaze/src/alterschema/common/modern_official_dialect_with_http.h @@ -15,7 +15,7 @@ class ModernOfficialDialectWithHttp final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { using sourcemeta::blaze::SchemaBaseDialect; ONLY_CONTINUE_IF( diff --git a/vendor/blaze/src/alterschema/common/non_applicable_additional_items.h b/vendor/blaze/src/alterschema/common/non_applicable_additional_items.h index 894af50a7..3f9d988ca 100644 --- a/vendor/blaze/src/alterschema/common/non_applicable_additional_items.h +++ b/vendor/blaze/src/alterschema/common/non_applicable_additional_items.h @@ -18,7 +18,7 @@ class NonApplicableAdditionalItems final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2019_09_Applicator, diff --git a/vendor/blaze/src/alterschema/common/non_applicable_disallow_types.h b/vendor/blaze/src/alterschema/common/non_applicable_disallow_types.h index d267dd729..dc31b6b7f 100644 --- a/vendor/blaze/src/alterschema/common/non_applicable_disallow_types.h +++ b/vendor/blaze/src/alterschema/common/non_applicable_disallow_types.h @@ -15,7 +15,7 @@ class NonApplicableDisallowTypes final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"disallow"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/non_applicable_enum_validation_keywords.h b/vendor/blaze/src/alterschema/common/non_applicable_enum_validation_keywords.h index 25f0c981e..71bab3e89 100644 --- a/vendor/blaze/src/alterschema/common/non_applicable_enum_validation_keywords.h +++ b/vendor/blaze/src/alterschema/common/non_applicable_enum_validation_keywords.h @@ -15,7 +15,7 @@ class NonApplicableEnumValidationKeywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/non_applicable_type_specific_keywords.h b/vendor/blaze/src/alterschema/common/non_applicable_type_specific_keywords.h index 5a5f23b1e..5b7ec0502 100644 --- a/vendor/blaze/src/alterschema/common/non_applicable_type_specific_keywords.h +++ b/vendor/blaze/src/alterschema/common/non_applicable_type_specific_keywords.h @@ -14,7 +14,7 @@ class NonApplicableTypeSpecificKeywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object()); diff --git a/vendor/blaze/src/alterschema/common/not_false.h b/vendor/blaze/src/alterschema/common/not_false.h index 65de31f6c..c01122c92 100644 --- a/vendor/blaze/src/alterschema/common/not_false.h +++ b/vendor/blaze/src/alterschema/common/not_false.h @@ -14,7 +14,7 @@ class NotFalse final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &frame, const SchemaFrame::Location &location, - const SchemaWalker &, const SchemaResolver &) const + const SchemaWalker &, const SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/common/oneof_false_simplify.h b/vendor/blaze/src/alterschema/common/oneof_false_simplify.h index ed31814b1..61a2b8ecf 100644 --- a/vendor/blaze/src/alterschema/common/oneof_false_simplify.h +++ b/vendor/blaze/src/alterschema/common/oneof_false_simplify.h @@ -14,7 +14,7 @@ class OneOfFalseSimplify final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"oneOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/oneof_to_anyof_disjoint_types.h b/vendor/blaze/src/alterschema/common/oneof_to_anyof_disjoint_types.h index 66a39dcdf..3aabdd593 100644 --- a/vendor/blaze/src/alterschema/common/oneof_to_anyof_disjoint_types.h +++ b/vendor/blaze/src/alterschema/common/oneof_to_anyof_disjoint_types.h @@ -15,7 +15,7 @@ class OneOfToAnyOfDisjointTypes final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { static const JSON::String KEYWORD{"oneOf"}; ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/common/orphan_definitions.h b/vendor/blaze/src/alterschema/common/orphan_definitions.h index 5b2d1e85f..5a047c89a 100644 --- a/vendor/blaze/src/alterschema/common/orphan_definitions.h +++ b/vendor/blaze/src/alterschema/common/orphan_definitions.h @@ -15,7 +15,7 @@ class OrphanDefinitions final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object()); const bool has_modern_core{ diff --git a/vendor/blaze/src/alterschema/common/required_properties_in_properties.h b/vendor/blaze/src/alterschema/common/required_properties_in_properties.h index 266c166df..b23399adf 100644 --- a/vendor/blaze/src/alterschema/common/required_properties_in_properties.h +++ b/vendor/blaze/src/alterschema/common/required_properties_in_properties.h @@ -15,7 +15,7 @@ class RequiredPropertiesInProperties final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( ((vocabularies.contains( diff --git a/vendor/blaze/src/alterschema/common/single_type_array.h b/vendor/blaze/src/alterschema/common/single_type_array.h index 569481d61..d4fad3e73 100644 --- a/vendor/blaze/src/alterschema/common/single_type_array.h +++ b/vendor/blaze/src/alterschema/common/single_type_array.h @@ -14,7 +14,7 @@ class SingleTypeArray final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/common/then_without_if.h b/vendor/blaze/src/alterschema/common/then_without_if.h index 58bf32cda..85e1d0cbb 100644 --- a/vendor/blaze/src/alterschema/common/then_without_if.h +++ b/vendor/blaze/src/alterschema/common/then_without_if.h @@ -17,7 +17,7 @@ class ThenWithoutIf final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/common/unknown_keywords_prefix.h b/vendor/blaze/src/alterschema/common/unknown_keywords_prefix.h index 46f1eba51..2ad2ba1da 100644 --- a/vendor/blaze/src/alterschema/common/unknown_keywords_prefix.h +++ b/vendor/blaze/src/alterschema/common/unknown_keywords_prefix.h @@ -12,8 +12,8 @@ class UnknownKeywordsPrefix final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &, const SchemaFrame::Location &, - const SchemaWalker &walker, const SchemaResolver &) const - -> SchemaTransformRule::Result override { + const SchemaWalker &walker, const SchemaResolver &, + const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object()); std::vector locations; for (const auto &entry : schema.as_object()) { diff --git a/vendor/blaze/src/alterschema/common/unknown_local_ref.h b/vendor/blaze/src/alterschema/common/unknown_local_ref.h index 7bc76a391..00042760a 100644 --- a/vendor/blaze/src/alterschema/common/unknown_local_ref.h +++ b/vendor/blaze/src/alterschema/common/unknown_local_ref.h @@ -14,7 +14,7 @@ class UnknownLocalRef final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &frame, const SchemaFrame::Location &location, - const SchemaWalker &, const SchemaResolver &) const + const SchemaWalker &, const SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Core, diff --git a/vendor/blaze/src/alterschema/common/unnecessary_allof_ref_wrapper_draft.h b/vendor/blaze/src/alterschema/common/unnecessary_allof_ref_wrapper_draft.h index 5f0bc2f08..06f9b76c4 100644 --- a/vendor/blaze/src/alterschema/common/unnecessary_allof_ref_wrapper_draft.h +++ b/vendor/blaze/src/alterschema/common/unnecessary_allof_ref_wrapper_draft.h @@ -14,7 +14,7 @@ class UnnecessaryAllOfRefWrapperDraft final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any({Vocabularies::Known::JSON_Schema_Draft_7, diff --git a/vendor/blaze/src/alterschema/common/unnecessary_extends_ref_wrapper.h b/vendor/blaze/src/alterschema/common/unnecessary_extends_ref_wrapper.h index 8c60d8aa3..93428b640 100644 --- a/vendor/blaze/src/alterschema/common/unnecessary_extends_ref_wrapper.h +++ b/vendor/blaze/src/alterschema/common/unnecessary_extends_ref_wrapper.h @@ -14,7 +14,7 @@ class UnnecessaryExtendsRefWrapper final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/common/unsatisfiable_drop_validation.h b/vendor/blaze/src/alterschema/common/unsatisfiable_drop_validation.h index 2ee105d86..b8f7048c7 100644 --- a/vendor/blaze/src/alterschema/common/unsatisfiable_drop_validation.h +++ b/vendor/blaze/src/alterschema/common/unsatisfiable_drop_validation.h @@ -14,7 +14,7 @@ class UnsatisfiableDropValidation final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/common/unsatisfiable_in_place_applicator_type.h b/vendor/blaze/src/alterschema/common/unsatisfiable_in_place_applicator_type.h index a4b35ce65..5070eac76 100644 --- a/vendor/blaze/src/alterschema/common/unsatisfiable_in_place_applicator_type.h +++ b/vendor/blaze/src/alterschema/common/unsatisfiable_in_place_applicator_type.h @@ -15,7 +15,7 @@ class UnsatisfiableInPlaceApplicatorType final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object() && schema.defines("type")); ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/include/sourcemeta/blaze/alterschema.h b/vendor/blaze/src/alterschema/include/sourcemeta/blaze/alterschema.h index e1fa7ea6b..fbe0d2c92 100644 --- a/vendor/blaze/src/alterschema/include/sourcemeta/blaze/alterschema.h +++ b/vendor/blaze/src/alterschema/include/sourcemeta/blaze/alterschema.h @@ -111,13 +111,13 @@ class SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT SchemaRule final const Compiler &compiler, const std::string_view default_dialect = "", const std::optional &tweaks = std::nullopt); - [[nodiscard]] auto condition(const sourcemeta::core::JSON &, - const sourcemeta::core::JSON &, - const sourcemeta::blaze::Vocabularies &, - const sourcemeta::blaze::SchemaFrame &, - const sourcemeta::blaze::SchemaFrame::Location &, - const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + [[nodiscard]] auto + condition(const sourcemeta::core::JSON &, const sourcemeta::core::JSON &, + const sourcemeta::blaze::Vocabularies &, + const sourcemeta::blaze::SchemaFrame &, + const sourcemeta::blaze::SchemaFrame::Location &, + const sourcemeta::blaze::SchemaWalker &, + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override; private: diff --git a/vendor/blaze/src/alterschema/include/sourcemeta/blaze/alterschema_transformer.h b/vendor/blaze/src/alterschema/include/sourcemeta/blaze/alterschema_transformer.h index 1dec5e413..c0b957cca 100644 --- a/vendor/blaze/src/alterschema/include/sourcemeta/blaze/alterschema_transformer.h +++ b/vendor/blaze/src/alterschema/include/sourcemeta/blaze/alterschema_transformer.h @@ -96,7 +96,8 @@ class SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT SchemaTransformRule { const sourcemeta::blaze::SchemaResolver &resolver, const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, - const sourcemeta::core::JSON::String &exclude_keyword) const -> Result; + const sourcemeta::core::JSON::String &exclude_keyword, + const bool is_metaschema) const -> Result; /// A method to optionally fix any reference location that was affected by the /// transformation @@ -108,13 +109,15 @@ class SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT SchemaTransformRule { -> sourcemeta::core::Pointer; /// The rule condition - [[nodiscard]] virtual auto condition( - const sourcemeta::core::JSON &schema, const sourcemeta::core::JSON &root, - const sourcemeta::blaze::Vocabularies &vocabularies, - const sourcemeta::blaze::SchemaFrame &frame, - const sourcemeta::blaze::SchemaFrame::Location &location, - const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const -> Result = 0; + [[nodiscard]] virtual auto + condition(const sourcemeta::core::JSON &schema, + const sourcemeta::core::JSON &root, + const sourcemeta::blaze::Vocabularies &vocabularies, + const sourcemeta::blaze::SchemaFrame &frame, + const sourcemeta::blaze::SchemaFrame::Location &location, + const sourcemeta::blaze::SchemaWalker &walker, + const sourcemeta::blaze::SchemaResolver &resolver, + const bool is_metaschema) const -> Result = 0; /// The rule transformation. If this virtual method is not overriden, /// then the rule is considered to not mutate the schema @@ -182,17 +185,20 @@ class SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT SchemaTransformer { const sourcemeta::blaze::SchemaResolver &resolver, const Callback &callback, std::string_view default_dialect = "", std::string_view default_id = "", - const sourcemeta::core::JSON::String &exclude_keyword = "") const + const sourcemeta::core::JSON::String &exclude_keyword = "", + const bool is_metaschema = false) const -> std::pair; - /// Report back the rules from the bundle that need to be applied to a schema + /// Report back the rules from the bundle that need to be applied to a + /// schema [[nodiscard]] auto check(const sourcemeta::core::JSON &schema, const sourcemeta::blaze::SchemaWalker &walker, const sourcemeta::blaze::SchemaResolver &resolver, const Callback &callback, std::string_view default_dialect = "", std::string_view default_id = "", - const sourcemeta::core::JSON::String &exclude_keyword = "") const + const sourcemeta::core::JSON::String &exclude_keyword = "", + const bool is_metaschema = false) const -> std::pair; [[nodiscard]] auto begin() const -> auto { return this->rules.cbegin(); } diff --git a/vendor/blaze/src/alterschema/linter/comment_trim.h b/vendor/blaze/src/alterschema/linter/comment_trim.h index cb9d11e70..d72283517 100644 --- a/vendor/blaze/src/alterschema/linter/comment_trim.h +++ b/vendor/blaze/src/alterschema/linter/comment_trim.h @@ -14,7 +14,7 @@ class CommentTrim final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Core, diff --git a/vendor/blaze/src/alterschema/linter/conflicting_readonly_writeonly.h b/vendor/blaze/src/alterschema/linter/conflicting_readonly_writeonly.h index e79828a9d..ffe2707b1 100644 --- a/vendor/blaze/src/alterschema/linter/conflicting_readonly_writeonly.h +++ b/vendor/blaze/src/alterschema/linter/conflicting_readonly_writeonly.h @@ -14,7 +14,7 @@ class ConflictingReadOnlyWriteOnly final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Meta_Data, diff --git a/vendor/blaze/src/alterschema/linter/const_not_in_enum.h b/vendor/blaze/src/alterschema/linter/const_not_in_enum.h index 538691768..33e0eea3b 100644 --- a/vendor/blaze/src/alterschema/linter/const_not_in_enum.h +++ b/vendor/blaze/src/alterschema/linter/const_not_in_enum.h @@ -15,7 +15,7 @@ class ConstNotInEnum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/linter/content_schema_default.h b/vendor/blaze/src/alterschema/linter/content_schema_default.h index 1ae69204a..d2761f9da 100644 --- a/vendor/blaze/src/alterschema/linter/content_schema_default.h +++ b/vendor/blaze/src/alterschema/linter/content_schema_default.h @@ -18,7 +18,7 @@ class ContentSchemaDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/definitions_to_defs.h b/vendor/blaze/src/alterschema/linter/definitions_to_defs.h index 2e7a5177e..1c4197c8f 100644 --- a/vendor/blaze/src/alterschema/linter/definitions_to_defs.h +++ b/vendor/blaze/src/alterschema/linter/definitions_to_defs.h @@ -14,7 +14,7 @@ class DefinitionsToDefs final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Core, diff --git a/vendor/blaze/src/alterschema/linter/dependencies_default.h b/vendor/blaze/src/alterschema/linter/dependencies_default.h index 0df7feec6..721db34fd 100644 --- a/vendor/blaze/src/alterschema/linter/dependencies_default.h +++ b/vendor/blaze/src/alterschema/linter/dependencies_default.h @@ -18,7 +18,7 @@ class DependenciesDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_7, diff --git a/vendor/blaze/src/alterschema/linter/dependent_required_default.h b/vendor/blaze/src/alterschema/linter/dependent_required_default.h index d151e7732..0b9c61536 100644 --- a/vendor/blaze/src/alterschema/linter/dependent_required_default.h +++ b/vendor/blaze/src/alterschema/linter/dependent_required_default.h @@ -15,7 +15,7 @@ class DependentRequiredDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/description_trailing_period.h b/vendor/blaze/src/alterschema/linter/description_trailing_period.h index b2fc6ef48..6a204f9bf 100644 --- a/vendor/blaze/src/alterschema/linter/description_trailing_period.h +++ b/vendor/blaze/src/alterschema/linter/description_trailing_period.h @@ -15,7 +15,7 @@ class DescriptionTrailingPeriod final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Meta_Data, diff --git a/vendor/blaze/src/alterschema/linter/description_trim.h b/vendor/blaze/src/alterschema/linter/description_trim.h index ff1f81b80..53d42951a 100644 --- a/vendor/blaze/src/alterschema/linter/description_trim.h +++ b/vendor/blaze/src/alterschema/linter/description_trim.h @@ -15,7 +15,7 @@ class DescriptionTrim final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Meta_Data, diff --git a/vendor/blaze/src/alterschema/linter/disallow_default.h b/vendor/blaze/src/alterschema/linter/disallow_default.h index 8459adbdd..675b3a443 100644 --- a/vendor/blaze/src/alterschema/linter/disallow_default.h +++ b/vendor/blaze/src/alterschema/linter/disallow_default.h @@ -14,7 +14,7 @@ class DisallowDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/linter/divisible_by_default.h b/vendor/blaze/src/alterschema/linter/divisible_by_default.h index 0d95fe0cc..b5c432048 100644 --- a/vendor/blaze/src/alterschema/linter/divisible_by_default.h +++ b/vendor/blaze/src/alterschema/linter/divisible_by_default.h @@ -15,7 +15,7 @@ class DivisibleByDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_3, diff --git a/vendor/blaze/src/alterschema/linter/duplicate_examples.h b/vendor/blaze/src/alterschema/linter/duplicate_examples.h index 3604ece7b..71e4067a9 100644 --- a/vendor/blaze/src/alterschema/linter/duplicate_examples.h +++ b/vendor/blaze/src/alterschema/linter/duplicate_examples.h @@ -14,7 +14,7 @@ class DuplicateExamples final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Meta_Data, diff --git a/vendor/blaze/src/alterschema/linter/else_empty.h b/vendor/blaze/src/alterschema/linter/else_empty.h index cddc20c21..532c808c0 100644 --- a/vendor/blaze/src/alterschema/linter/else_empty.h +++ b/vendor/blaze/src/alterschema/linter/else_empty.h @@ -13,7 +13,7 @@ class ElseEmpty final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &frame, const SchemaFrame::Location &location, - const SchemaWalker &, const SchemaResolver &) const + const SchemaWalker &, const SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/enum_to_const.h b/vendor/blaze/src/alterschema/linter/enum_to_const.h index 35d9d4989..2e04b8a7b 100644 --- a/vendor/blaze/src/alterschema/linter/enum_to_const.h +++ b/vendor/blaze/src/alterschema/linter/enum_to_const.h @@ -14,7 +14,7 @@ class EnumToConst final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/linter/equal_numeric_bounds_to_const.h b/vendor/blaze/src/alterschema/linter/equal_numeric_bounds_to_const.h index dea26fa29..ebfd32634 100644 --- a/vendor/blaze/src/alterschema/linter/equal_numeric_bounds_to_const.h +++ b/vendor/blaze/src/alterschema/linter/equal_numeric_bounds_to_const.h @@ -15,7 +15,7 @@ class EqualNumericBoundsToConst final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any({ Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/linter/forbid_empty_enum.h b/vendor/blaze/src/alterschema/linter/forbid_empty_enum.h index 17026c404..8fc9bac07 100644 --- a/vendor/blaze/src/alterschema/linter/forbid_empty_enum.h +++ b/vendor/blaze/src/alterschema/linter/forbid_empty_enum.h @@ -14,7 +14,7 @@ class ForbidEmptyEnum final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/linter/incoherent_min_max_contains.h b/vendor/blaze/src/alterschema/linter/incoherent_min_max_contains.h index 863116759..c37593ce1 100644 --- a/vendor/blaze/src/alterschema/linter/incoherent_min_max_contains.h +++ b/vendor/blaze/src/alterschema/linter/incoherent_min_max_contains.h @@ -15,7 +15,7 @@ class IncoherentMinMaxContains final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/invalid_external_ref.h b/vendor/blaze/src/alterschema/linter/invalid_external_ref.h index 7828ebc0e..5a722e07b 100644 --- a/vendor/blaze/src/alterschema/linter/invalid_external_ref.h +++ b/vendor/blaze/src/alterschema/linter/invalid_external_ref.h @@ -11,8 +11,8 @@ class InvalidExternalRef final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &frame, const SchemaFrame::Location &location, - const SchemaWalker &walker, const SchemaResolver &resolver) const - -> SchemaTransformRule::Result override { + const SchemaWalker &walker, const SchemaResolver &resolver, + const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(!frame.standalone()); ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Core, diff --git a/vendor/blaze/src/alterschema/linter/items_array_default.h b/vendor/blaze/src/alterschema/linter/items_array_default.h index b20627a4b..267570504 100644 --- a/vendor/blaze/src/alterschema/linter/items_array_default.h +++ b/vendor/blaze/src/alterschema/linter/items_array_default.h @@ -14,7 +14,7 @@ class ItemsArrayDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2019_09_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/items_schema_default.h b/vendor/blaze/src/alterschema/linter/items_schema_default.h index ebd84902c..48949c48b 100644 --- a/vendor/blaze/src/alterschema/linter/items_schema_default.h +++ b/vendor/blaze/src/alterschema/linter/items_schema_default.h @@ -17,7 +17,7 @@ class ItemsSchemaDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/multiple_of_default.h b/vendor/blaze/src/alterschema/linter/multiple_of_default.h index 7e5429248..d13508995 100644 --- a/vendor/blaze/src/alterschema/linter/multiple_of_default.h +++ b/vendor/blaze/src/alterschema/linter/multiple_of_default.h @@ -14,7 +14,7 @@ class MultipleOfDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/linter/pattern_non_ecma_regex.h b/vendor/blaze/src/alterschema/linter/pattern_non_ecma_regex.h new file mode 100644 index 000000000..3af00f622 --- /dev/null +++ b/vendor/blaze/src/alterschema/linter/pattern_non_ecma_regex.h @@ -0,0 +1,46 @@ +class PatternNonEcmaRegex final : public SchemaTransformRule { +public: + using mutates = std::false_type; + using reframe_after_transform = std::false_type; + PatternNonEcmaRegex() + : SchemaTransformRule{ + "pattern_non_ecma_regex", + "For interoperability reasons, only set this keyword to a regular " + "expression that strictly adheres to the ECMA-262 dialect"} {}; + + [[nodiscard]] auto + condition(const sourcemeta::core::JSON &schema, + const sourcemeta::core::JSON &, + const sourcemeta::blaze::Vocabularies &vocabularies, + const sourcemeta::blaze::SchemaFrame &, + const sourcemeta::blaze::SchemaFrame::Location &, + const sourcemeta::blaze::SchemaWalker &, + const sourcemeta::blaze::SchemaResolver &, const bool) const + -> SchemaTransformRule::Result override { + ONLY_CONTINUE_IF(vocabularies.contains_any( + {Vocabularies::Known::JSON_Schema_2020_12_Validation, + Vocabularies::Known::JSON_Schema_2019_09_Validation, + Vocabularies::Known::JSON_Schema_Draft_7, + Vocabularies::Known::JSON_Schema_Draft_7_Hyper, + Vocabularies::Known::JSON_Schema_Draft_6, + Vocabularies::Known::JSON_Schema_Draft_6_Hyper, + Vocabularies::Known::JSON_Schema_Draft_4, + Vocabularies::Known::JSON_Schema_Draft_4_Hyper, + Vocabularies::Known::JSON_Schema_Draft_3, + Vocabularies::Known::JSON_Schema_Draft_3_Hyper, + Vocabularies::Known::JSON_Schema_Draft_2, + Vocabularies::Known::JSON_Schema_Draft_2_Hyper, + Vocabularies::Known::JSON_Schema_Draft_1, + Vocabularies::Known::JSON_Schema_Draft_1_Hyper, + Vocabularies::Known::JSON_Schema_Draft_0, + Vocabularies::Known::JSON_Schema_Draft_0_Hyper})); + ONLY_CONTINUE_IF(schema.is_object()); + + const auto *pattern_value{schema.try_at("pattern")}; + ONLY_CONTINUE_IF(pattern_value && pattern_value->is_string()); + + ONLY_CONTINUE_IF( + !sourcemeta::core::is_regex_ecma(pattern_value->to_string())); + return APPLIES_TO_KEYWORDS("pattern"); + } +}; diff --git a/vendor/blaze/src/alterschema/linter/pattern_properties_default.h b/vendor/blaze/src/alterschema/linter/pattern_properties_default.h index a2165505e..890f0383f 100644 --- a/vendor/blaze/src/alterschema/linter/pattern_properties_default.h +++ b/vendor/blaze/src/alterschema/linter/pattern_properties_default.h @@ -15,7 +15,7 @@ class PatternPropertiesDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/pattern_properties_non_ecma_regex.h b/vendor/blaze/src/alterschema/linter/pattern_properties_non_ecma_regex.h new file mode 100644 index 000000000..d38a17ae4 --- /dev/null +++ b/vendor/blaze/src/alterschema/linter/pattern_properties_non_ecma_regex.h @@ -0,0 +1,48 @@ +class PatternPropertiesNonEcmaRegex final : public SchemaTransformRule { +public: + using mutates = std::false_type; + using reframe_after_transform = std::false_type; + PatternPropertiesNonEcmaRegex() + : SchemaTransformRule{ + "pattern_properties_non_ecma_regex", + "For interoperability reasons, only set the keys of this keyword " + "to regular expressions that strictly adhere to the ECMA-262 " + "dialect"} {}; + + [[nodiscard]] auto + condition(const sourcemeta::core::JSON &schema, + const sourcemeta::core::JSON &, + const sourcemeta::blaze::Vocabularies &vocabularies, + const sourcemeta::blaze::SchemaFrame &, + const sourcemeta::blaze::SchemaFrame::Location &, + const sourcemeta::blaze::SchemaWalker &, + const sourcemeta::blaze::SchemaResolver &, const bool) const + -> SchemaTransformRule::Result override { + ONLY_CONTINUE_IF(vocabularies.contains_any( + {Vocabularies::Known::JSON_Schema_2020_12_Applicator, + Vocabularies::Known::JSON_Schema_2019_09_Applicator, + Vocabularies::Known::JSON_Schema_Draft_7, + Vocabularies::Known::JSON_Schema_Draft_7_Hyper, + Vocabularies::Known::JSON_Schema_Draft_6, + Vocabularies::Known::JSON_Schema_Draft_6_Hyper, + Vocabularies::Known::JSON_Schema_Draft_4, + Vocabularies::Known::JSON_Schema_Draft_4_Hyper, + Vocabularies::Known::JSON_Schema_Draft_3, + Vocabularies::Known::JSON_Schema_Draft_3_Hyper})); + ONLY_CONTINUE_IF(schema.is_object()); + + const auto *pattern_properties{schema.try_at("patternProperties")}; + ONLY_CONTINUE_IF(pattern_properties && pattern_properties->is_object() && + !pattern_properties->empty()); + + std::vector offenders; + for (const auto &entry : pattern_properties->as_object()) { + if (!sourcemeta::core::is_regex_ecma(entry.first)) { + offenders.push_back(Pointer{"patternProperties", entry.first}); + } + } + + ONLY_CONTINUE_IF(!offenders.empty()); + return APPLIES_TO_POINTERS(std::move(offenders)); + } +}; diff --git a/vendor/blaze/src/alterschema/linter/portable_anchor_names.h b/vendor/blaze/src/alterschema/linter/portable_anchor_names.h index 4835b41cb..9fe660f4a 100644 --- a/vendor/blaze/src/alterschema/linter/portable_anchor_names.h +++ b/vendor/blaze/src/alterschema/linter/portable_anchor_names.h @@ -15,7 +15,7 @@ class PortableAnchorNames final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Core, diff --git a/vendor/blaze/src/alterschema/linter/properties_default.h b/vendor/blaze/src/alterschema/linter/properties_default.h index 64aad5f7c..e7165e8e6 100644 --- a/vendor/blaze/src/alterschema/linter/properties_default.h +++ b/vendor/blaze/src/alterschema/linter/properties_default.h @@ -15,7 +15,7 @@ class PropertiesDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/property_names_default.h b/vendor/blaze/src/alterschema/linter/property_names_default.h index ba10aa4c1..5a2b75e05 100644 --- a/vendor/blaze/src/alterschema/linter/property_names_default.h +++ b/vendor/blaze/src/alterschema/linter/property_names_default.h @@ -18,7 +18,7 @@ class PropertyNamesDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/property_names_type_default.h b/vendor/blaze/src/alterschema/linter/property_names_type_default.h index 645a2cb62..320a50868 100644 --- a/vendor/blaze/src/alterschema/linter/property_names_type_default.h +++ b/vendor/blaze/src/alterschema/linter/property_names_type_default.h @@ -15,7 +15,7 @@ class PropertyNamesTypeDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/simple_properties_identifiers.h b/vendor/blaze/src/alterschema/linter/simple_properties_identifiers.h index 2454ba0c0..503266dc1 100644 --- a/vendor/blaze/src/alterschema/linter/simple_properties_identifiers.h +++ b/vendor/blaze/src/alterschema/linter/simple_properties_identifiers.h @@ -17,7 +17,7 @@ class SimplePropertiesIdentifiers final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/then_empty.h b/vendor/blaze/src/alterschema/linter/then_empty.h index 647da3ee1..921849993 100644 --- a/vendor/blaze/src/alterschema/linter/then_empty.h +++ b/vendor/blaze/src/alterschema/linter/then_empty.h @@ -13,7 +13,7 @@ class ThenEmpty final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &frame, const SchemaFrame::Location &location, - const SchemaWalker &, const SchemaResolver &) const + const SchemaWalker &, const SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/title_description_equal.h b/vendor/blaze/src/alterschema/linter/title_description_equal.h index b2cfcdd04..c857073c0 100644 --- a/vendor/blaze/src/alterschema/linter/title_description_equal.h +++ b/vendor/blaze/src/alterschema/linter/title_description_equal.h @@ -15,7 +15,7 @@ class TitleDescriptionEqual final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Meta_Data, diff --git a/vendor/blaze/src/alterschema/linter/title_trailing_period.h b/vendor/blaze/src/alterschema/linter/title_trailing_period.h index ea3052e3f..374ab4a96 100644 --- a/vendor/blaze/src/alterschema/linter/title_trailing_period.h +++ b/vendor/blaze/src/alterschema/linter/title_trailing_period.h @@ -15,7 +15,7 @@ class TitleTrailingPeriod final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Meta_Data, diff --git a/vendor/blaze/src/alterschema/linter/title_trim.h b/vendor/blaze/src/alterschema/linter/title_trim.h index 8758d8964..528b52707 100644 --- a/vendor/blaze/src/alterschema/linter/title_trim.h +++ b/vendor/blaze/src/alterschema/linter/title_trim.h @@ -14,7 +14,7 @@ class TitleTrim final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Meta_Data, diff --git a/vendor/blaze/src/alterschema/linter/top_level_description.h b/vendor/blaze/src/alterschema/linter/top_level_description.h index fb9996954..3d69f0bbd 100644 --- a/vendor/blaze/src/alterschema/linter/top_level_description.h +++ b/vendor/blaze/src/alterschema/linter/top_level_description.h @@ -15,7 +15,7 @@ class TopLevelDescription final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(location.pointer.empty()); ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/top_level_examples.h b/vendor/blaze/src/alterschema/linter/top_level_examples.h index bee363b41..28c0d9719 100644 --- a/vendor/blaze/src/alterschema/linter/top_level_examples.h +++ b/vendor/blaze/src/alterschema/linter/top_level_examples.h @@ -15,7 +15,7 @@ class TopLevelExamples final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(location.pointer.empty()); ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/top_level_title.h b/vendor/blaze/src/alterschema/linter/top_level_title.h index 9509cdf4e..74f8ed416 100644 --- a/vendor/blaze/src/alterschema/linter/top_level_title.h +++ b/vendor/blaze/src/alterschema/linter/top_level_title.h @@ -15,7 +15,7 @@ class TopLevelTitle final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(location.pointer.empty()); ONLY_CONTINUE_IF(vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/unevaluated_items_default.h b/vendor/blaze/src/alterschema/linter/unevaluated_items_default.h index 57f9e0481..b4912bc56 100644 --- a/vendor/blaze/src/alterschema/linter/unevaluated_items_default.h +++ b/vendor/blaze/src/alterschema/linter/unevaluated_items_default.h @@ -18,7 +18,7 @@ class UnevaluatedItemsDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/unevaluated_properties_default.h b/vendor/blaze/src/alterschema/linter/unevaluated_properties_default.h index 20cec0e02..fb1753b0e 100644 --- a/vendor/blaze/src/alterschema/linter/unevaluated_properties_default.h +++ b/vendor/blaze/src/alterschema/linter/unevaluated_properties_default.h @@ -18,7 +18,7 @@ class UnevaluatedPropertiesDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/unknown_format_prefix.h b/vendor/blaze/src/alterschema/linter/unknown_format_prefix.h index 339d3609f..2f423feca 100644 --- a/vendor/blaze/src/alterschema/linter/unknown_format_prefix.h +++ b/vendor/blaze/src/alterschema/linter/unknown_format_prefix.h @@ -17,7 +17,7 @@ class UnknownFormatPrefix final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(schema.is_object() && schema.defines("format")); const auto &format_value{schema.at("format")}; diff --git a/vendor/blaze/src/alterschema/linter/unnecessary_allof_ref_wrapper_modern.h b/vendor/blaze/src/alterschema/linter/unnecessary_allof_ref_wrapper_modern.h index 218990a74..bf2d2d0d4 100644 --- a/vendor/blaze/src/alterschema/linter/unnecessary_allof_ref_wrapper_modern.h +++ b/vendor/blaze/src/alterschema/linter/unnecessary_allof_ref_wrapper_modern.h @@ -14,7 +14,7 @@ class UnnecessaryAllOfRefWrapperModern final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/unnecessary_allof_wrapper.h b/vendor/blaze/src/alterschema/linter/unnecessary_allof_wrapper.h index faa1fb8d3..f2e20d872 100644 --- a/vendor/blaze/src/alterschema/linter/unnecessary_allof_wrapper.h +++ b/vendor/blaze/src/alterschema/linter/unnecessary_allof_wrapper.h @@ -13,8 +13,8 @@ class UnnecessaryAllOfWrapper final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &frame, const SchemaFrame::Location &location, - const SchemaWalker &walker, const SchemaResolver &) const - -> SchemaTransformRule::Result override { + const SchemaWalker &walker, const SchemaResolver &, + const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Applicator, Vocabularies::Known::JSON_Schema_2019_09_Applicator, diff --git a/vendor/blaze/src/alterschema/linter/unnecessary_extends_wrapper.h b/vendor/blaze/src/alterschema/linter/unnecessary_extends_wrapper.h index af175e5d6..e5334b2c3 100644 --- a/vendor/blaze/src/alterschema/linter/unnecessary_extends_wrapper.h +++ b/vendor/blaze/src/alterschema/linter/unnecessary_extends_wrapper.h @@ -13,8 +13,8 @@ class UnnecessaryExtendsWrapper final : public SchemaTransformRule { [[nodiscard]] auto condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies, const SchemaFrame &frame, const SchemaFrame::Location &location, - const SchemaWalker &walker, const SchemaResolver &) const - -> SchemaTransformRule::Result override { + const SchemaWalker &walker, const SchemaResolver &, + const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_Draft_3, Vocabularies::Known::JSON_Schema_Draft_3_Hyper})); diff --git a/vendor/blaze/src/alterschema/linter/unsatisfiable_max_contains.h b/vendor/blaze/src/alterschema/linter/unsatisfiable_max_contains.h index ccf7b0029..24141fa25 100644 --- a/vendor/blaze/src/alterschema/linter/unsatisfiable_max_contains.h +++ b/vendor/blaze/src/alterschema/linter/unsatisfiable_max_contains.h @@ -16,7 +16,7 @@ class UnsatisfiableMaxContains final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains_any( diff --git a/vendor/blaze/src/alterschema/linter/unsatisfiable_min_properties.h b/vendor/blaze/src/alterschema/linter/unsatisfiable_min_properties.h index 1b3521e31..e75dcbff1 100644 --- a/vendor/blaze/src/alterschema/linter/unsatisfiable_min_properties.h +++ b/vendor/blaze/src/alterschema/linter/unsatisfiable_min_properties.h @@ -15,7 +15,7 @@ class UnsatisfiableMinProperties final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(vocabularies.contains_any( {Vocabularies::Known::JSON_Schema_2020_12_Validation, diff --git a/vendor/blaze/src/alterschema/linter/valid_default.h b/vendor/blaze/src/alterschema/linter/valid_default.h index c2ea6f206..f9e6b1994 100644 --- a/vendor/blaze/src/alterschema/linter/valid_default.h +++ b/vendor/blaze/src/alterschema/linter/valid_default.h @@ -14,7 +14,7 @@ class ValidDefault final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { using Known = Vocabularies::Known; // Technically, the `default` keyword goes back to Draft 1, but Blaze diff --git a/vendor/blaze/src/alterschema/linter/valid_examples.h b/vendor/blaze/src/alterschema/linter/valid_examples.h index 1d3328804..a7b0fe25e 100644 --- a/vendor/blaze/src/alterschema/linter/valid_examples.h +++ b/vendor/blaze/src/alterschema/linter/valid_examples.h @@ -15,7 +15,7 @@ class ValidExamples final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { using Known = Vocabularies::Known; ONLY_CONTINUE_IF( diff --git a/vendor/blaze/src/alterschema/schema_rule.cc b/vendor/blaze/src/alterschema/schema_rule.cc index 4c5a9937b..74072ac61 100644 --- a/vendor/blaze/src/alterschema/schema_rule.cc +++ b/vendor/blaze/src/alterschema/schema_rule.cc @@ -79,8 +79,8 @@ auto SchemaRule::condition(const sourcemeta::core::JSON &schema, const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const - -> SchemaTransformRule::Result { + const sourcemeta::blaze::SchemaResolver &, + const bool) const -> SchemaTransformRule::Result { SimpleOutput output{schema}; Evaluator evaluator; const auto result{ diff --git a/vendor/blaze/src/alterschema/transformer.cc b/vendor/blaze/src/alterschema/transformer.cc index 68e1f54cf..aaf811c30 100644 --- a/vendor/blaze/src/alterschema/transformer.cc +++ b/vendor/blaze/src/alterschema/transformer.cc @@ -48,7 +48,8 @@ auto check_rules( const sourcemeta::blaze::SchemaResolver &resolver, const sourcemeta::blaze::SchemaTransformer::Callback &callback, const sourcemeta::core::JSON::String &exclude_keyword, - const bool non_mutating_only) -> std::pair { + const bool non_mutating_only, const bool is_metaschema) + -> std::pair { std::unordered_set visited; @@ -84,7 +85,7 @@ auto check_rules( const auto outcome{rule->check(current, schema, current_vocabularies, walker, resolver, frame, entry.second, - exclude_keyword)}; + exclude_keyword, is_metaschema)}; if (outcome.applies) { subschema_failed = true; callback(entry_pointer, rule->name(), rule->message(), outcome, @@ -150,17 +151,15 @@ auto SchemaTransformRule::rereference(const std::string_view reference, "The reference broke after transformation"); } -auto SchemaTransformRule::check(const core::JSON &schema, - const core::JSON &root, - const blaze::Vocabularies &vocabularies, - const blaze::SchemaWalker &walker, - const blaze::SchemaResolver &resolver, - const blaze::SchemaFrame &frame, - const blaze::SchemaFrame::Location &location, - const core::JSON::String &exclude_keyword) const +auto SchemaTransformRule::check( + const core::JSON &schema, const core::JSON &root, + const blaze::Vocabularies &vocabularies, const blaze::SchemaWalker &walker, + const blaze::SchemaResolver &resolver, const blaze::SchemaFrame &frame, + const blaze::SchemaFrame::Location &location, + const core::JSON::String &exclude_keyword, const bool is_metaschema) const -> SchemaTransformRule::Result { auto result{this->condition(schema, root, vocabularies, frame, location, - walker, resolver)}; + walker, resolver, is_metaschema)}; if (result.applies && !exclude_keyword.empty() && schema.is_object()) { const auto *exclude_value{schema.try_at(exclude_keyword)}; @@ -182,12 +181,13 @@ auto SchemaTransformer::check(const core::JSON &schema, const SchemaTransformer::Callback &callback, std::string_view default_dialect, std::string_view default_id, - const core::JSON::String &exclude_keyword) const + const core::JSON::String &exclude_keyword, + const bool is_metaschema) const -> std::pair { blaze::SchemaFrame frame{blaze::SchemaFrame::Mode::References}; analyse_frame(frame, schema, walker, resolver, default_dialect, default_id); return check_rules(schema, frame, this->rules, walker, resolver, callback, - exclude_keyword, false); + exclude_keyword, false, is_metaschema); } auto SchemaTransformer::apply(core::JSON &schema, @@ -196,7 +196,8 @@ auto SchemaTransformer::apply(core::JSON &schema, const SchemaTransformer::Callback &callback, std::string_view default_dialect, std::string_view default_id, - const core::JSON::String &exclude_keyword) const + const core::JSON::String &exclude_keyword, + const bool is_metaschema) const -> std::pair { assert(!this->rules.empty()); std::unordered_set, @@ -251,8 +252,8 @@ auto SchemaTransformer::apply(core::JSON &schema, } auto outcome{rule->check(current, schema, current_vocabularies, walker, - resolver, frame, entry.second, - exclude_keyword)}; + resolver, frame, entry.second, exclude_keyword, + is_metaschema)}; if (!outcome.applies) { continue; @@ -353,7 +354,8 @@ auto SchemaTransformer::apply(core::JSON &schema, frame.vocabularies(new_location.value().get(), resolver)}; if (rule->check(current, schema, new_vocabularies, walker, resolver, - frame, new_location.value().get(), exclude_keyword) + frame, new_location.value().get(), exclude_keyword, + is_metaschema) .applies) { std::ostringstream error; error << "Rule condition holds after application: " << rule->name(); @@ -394,7 +396,7 @@ auto SchemaTransformer::apply(core::JSON &schema, } return check_rules(schema, frame, this->rules, walker, resolver, callback, - exclude_keyword, true); + exclude_keyword, true, is_metaschema); } auto SchemaTransformer::remove(const std::string_view name) -> bool { diff --git a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_2020_12_keywords.h b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_2020_12_keywords.h index 585e5617a..ebeaee8d0 100644 --- a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_2020_12_keywords.h +++ b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_2020_12_keywords.h @@ -12,7 +12,7 @@ class PrefixPromoted202012Keywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_2019_09_Core) && diff --git a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_2019_09_keywords.h b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_2019_09_keywords.h index a123738a5..961845a6b 100644 --- a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_2019_09_keywords.h +++ b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_2019_09_keywords.h @@ -12,7 +12,7 @@ class PrefixPromoted201909Keywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_7) && diff --git a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_4_keywords.h b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_4_keywords.h index aa049986d..9ba5de908 100644 --- a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_4_keywords.h +++ b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_4_keywords.h @@ -12,7 +12,7 @@ class PrefixPromotedDraft4Keywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_3) && diff --git a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_6_keywords.h b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_6_keywords.h index 7d9aeb843..0fd8ec4f3 100644 --- a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_6_keywords.h +++ b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_6_keywords.h @@ -12,7 +12,7 @@ class PrefixPromotedDraft6Keywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_4) && diff --git a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_7_keywords.h b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_7_keywords.h index e0a129967..764997913 100644 --- a/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_7_keywords.h +++ b/vendor/blaze/src/alterschema/upgrade/prefix_promoted_draft_7_keywords.h @@ -12,7 +12,7 @@ class PrefixPromotedDraft7Keywords final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_6) && diff --git a/vendor/blaze/src/alterschema/upgrade/upgrade_2019_09_to_2020_12.h b/vendor/blaze/src/alterschema/upgrade/upgrade_2019_09_to_2020_12.h index f2b2c501d..794612846 100644 --- a/vendor/blaze/src/alterschema/upgrade/upgrade_2019_09_to_2020_12.h +++ b/vendor/blaze/src/alterschema/upgrade/upgrade_2019_09_to_2020_12.h @@ -12,7 +12,7 @@ class Upgrade201909To202012 final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &walker, - const sourcemeta::blaze::SchemaResolver &resolver) const + const sourcemeta::blaze::SchemaResolver &resolver, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_2019_09_Core) && @@ -156,6 +156,8 @@ class Upgrade201909To202012 final : public SchemaTransformRule { } } + rewrite_vocabulary(schema); + if (schema.defines("$schema") && schema.at("$schema").is_string() && schema.at("$schema").to_string() == DRAFT_2019_09_URL) { schema.assign("$schema", sourcemeta::core::JSON{DRAFT_2020_12_URL}); @@ -186,6 +188,89 @@ class Upgrade201909To202012 final : public SchemaTransformRule { "https://json-schema.org/draft/2019-09/schema"}; static constexpr std::string_view DRAFT_2020_12_URL{ "https://json-schema.org/draft/2020-12/schema"}; + static constexpr std::string_view APPLICATOR_2019_09_URI{ + "https://json-schema.org/draft/2019-09/vocab/applicator"}; + static constexpr std::string_view APPLICATOR_2020_12_URI{ + "https://json-schema.org/draft/2020-12/vocab/applicator"}; + static constexpr std::string_view UNEVALUATED_2020_12_URI{ + "https://json-schema.org/draft/2020-12/vocab/unevaluated"}; + + static inline const std::unordered_map + VOCAB_URI_MAP_2019_09_TO_2020_12{ + {"https://json-schema.org/draft/2019-09/vocab/core", + "https://json-schema.org/draft/2020-12/vocab/core"}, + {"https://json-schema.org/draft/2019-09/vocab/applicator", + "https://json-schema.org/draft/2020-12/vocab/applicator"}, + {"https://json-schema.org/draft/2019-09/vocab/validation", + "https://json-schema.org/draft/2020-12/vocab/validation"}, + {"https://json-schema.org/draft/2019-09/vocab/meta-data", + "https://json-schema.org/draft/2020-12/vocab/meta-data"}, + {"https://json-schema.org/draft/2019-09/vocab/format", + "https://json-schema.org/draft/2020-12/vocab/format-annotation"}, + {"https://json-schema.org/draft/2019-09/vocab/content", + "https://json-schema.org/draft/2020-12/vocab/content"}}; + + static auto + vocabulary_has_mappable_uri(const sourcemeta::core::JSON &subschema) -> bool { + if (!subschema.is_object() || !subschema.defines("$vocabulary") || + !subschema.at("$vocabulary").is_object()) { + return false; + } + for (const auto &entry : subschema.at("$vocabulary").as_object()) { + if (VOCAB_URI_MAP_2019_09_TO_2020_12.contains(entry.first)) { + return true; + } + } + return false; + } + + static auto rewrite_vocabulary(sourcemeta::core::JSON &schema) -> void { + if (!schema.is_object() || !schema.defines("$vocabulary") || + !schema.at("$vocabulary").is_object()) { + return; + } + + std::unordered_set source_keys; + std::optional applicator_2019_09_value; + for (const auto &entry : schema.at("$vocabulary").as_object()) { + source_keys.insert(entry.first); + if (entry.first == APPLICATOR_2019_09_URI) { + applicator_2019_09_value = entry.second; + } + } + + const bool unevaluated_already_present{ + source_keys.contains(std::string{UNEVALUATED_2020_12_URI})}; + const bool should_inline_unevaluated{applicator_2019_09_value.has_value() && + !unevaluated_already_present}; + + auto fresh{sourcemeta::core::JSON::make_object()}; + + for (const auto &entry : schema.at("$vocabulary").as_object()) { + const auto iter{VOCAB_URI_MAP_2019_09_TO_2020_12.find(entry.first)}; + if (iter == VOCAB_URI_MAP_2019_09_TO_2020_12.cend()) { + fresh.assign(entry.first, entry.second); + if (entry.first == APPLICATOR_2020_12_URI && + should_inline_unevaluated) { + fresh.assign(std::string{UNEVALUATED_2020_12_URI}, + applicator_2019_09_value.value()); + } + continue; + } + + if (source_keys.contains(iter->second)) { + continue; + } + + fresh.assign(iter->second, entry.second); + + if (entry.first == APPLICATOR_2019_09_URI && should_inline_unevaluated) { + fresh.assign(std::string{UNEVALUATED_2020_12_URI}, entry.second); + } + } + + schema.at("$vocabulary").into(std::move(fresh)); + } struct AnchorRename { sourcemeta::core::Pointer subschema_pointer; @@ -311,7 +396,8 @@ class Upgrade201909To202012 final : public SchemaTransformRule { return false; } if (!subschema.defines_any({"$schema", "$recursiveAnchor", "$recursiveRef", - "items", "additionalItems", "contains"})) { + "items", "additionalItems", "contains", + "$vocabulary"})) { return false; } if (subschema.defines("$schema") && subschema.at("$schema").is_string() && @@ -329,6 +415,9 @@ class Upgrade201909To202012 final : public SchemaTransformRule { !location_inside_contains_wrapper(location)) { return true; } + if (vocabulary_has_mappable_uri(subschema)) { + return true; + } return false; } diff --git a/vendor/blaze/src/alterschema/upgrade/upgrade_dialect_override_cleanup.h b/vendor/blaze/src/alterschema/upgrade/upgrade_dialect_override_cleanup.h index e1752b075..2ca21cc7f 100644 --- a/vendor/blaze/src/alterschema/upgrade/upgrade_dialect_override_cleanup.h +++ b/vendor/blaze/src/alterschema/upgrade/upgrade_dialect_override_cleanup.h @@ -12,7 +12,7 @@ class UpgradeDialectOverrideCleanup final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF(location.pointer.empty() && schema.is_object()); diff --git a/vendor/blaze/src/alterschema/upgrade/upgrade_draft_3_to_draft_4.h b/vendor/blaze/src/alterschema/upgrade/upgrade_draft_3_to_draft_4.h index 5261d5b38..b7967ab72 100644 --- a/vendor/blaze/src/alterschema/upgrade/upgrade_draft_3_to_draft_4.h +++ b/vendor/blaze/src/alterschema/upgrade/upgrade_draft_3_to_draft_4.h @@ -12,7 +12,7 @@ class UpgradeDraft3ToDraft4 final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_3) && diff --git a/vendor/blaze/src/alterschema/upgrade/upgrade_draft_4_to_draft_6.h b/vendor/blaze/src/alterschema/upgrade/upgrade_draft_4_to_draft_6.h index 4db59d961..ecda996cd 100644 --- a/vendor/blaze/src/alterschema/upgrade/upgrade_draft_4_to_draft_6.h +++ b/vendor/blaze/src/alterschema/upgrade/upgrade_draft_4_to_draft_6.h @@ -12,7 +12,7 @@ class UpgradeDraft4ToDraft6 final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_4) && diff --git a/vendor/blaze/src/alterschema/upgrade/upgrade_draft_6_to_draft_7.h b/vendor/blaze/src/alterschema/upgrade/upgrade_draft_6_to_draft_7.h index 92295b58d..6b62e2033 100644 --- a/vendor/blaze/src/alterschema/upgrade/upgrade_draft_6_to_draft_7.h +++ b/vendor/blaze/src/alterschema/upgrade/upgrade_draft_6_to_draft_7.h @@ -12,7 +12,7 @@ class UpgradeDraft6ToDraft7 final : public SchemaTransformRule { const sourcemeta::blaze::SchemaFrame &frame, const sourcemeta::blaze::SchemaFrame::Location &location, const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + const sourcemeta::blaze::SchemaResolver &, const bool) const -> SchemaTransformRule::Result override { ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_6) && diff --git a/vendor/blaze/src/alterschema/upgrade/upgrade_draft_7_to_draft_2019_09.h b/vendor/blaze/src/alterschema/upgrade/upgrade_draft_7_to_draft_2019_09.h index be536e682..0f45ca4db 100644 --- a/vendor/blaze/src/alterschema/upgrade/upgrade_draft_7_to_draft_2019_09.h +++ b/vendor/blaze/src/alterschema/upgrade/upgrade_draft_7_to_draft_2019_09.h @@ -5,23 +5,31 @@ class UpgradeDraft7To201909 final : public SchemaTransformRule { UpgradeDraft7To201909() : SchemaTransformRule{"upgrade_draft_7_to_2019_09", ""} {}; - [[nodiscard]] auto - condition(const sourcemeta::core::JSON &schema, - const sourcemeta::core::JSON &root, - const sourcemeta::blaze::Vocabularies &vocabularies, - const sourcemeta::blaze::SchemaFrame &frame, - const sourcemeta::blaze::SchemaFrame::Location &location, - const sourcemeta::blaze::SchemaWalker &, - const sourcemeta::blaze::SchemaResolver &) const + [[nodiscard]] auto condition( + const sourcemeta::core::JSON &schema, const sourcemeta::core::JSON &root, + const sourcemeta::blaze::Vocabularies &vocabularies, + const sourcemeta::blaze::SchemaFrame &frame, + const sourcemeta::blaze::SchemaFrame::Location &location, + const sourcemeta::blaze::SchemaWalker &, + const sourcemeta::blaze::SchemaResolver &, const bool is_metaschema) const -> SchemaTransformRule::Result override { + this->metaschema_synthesis_pending_ = false; + ONLY_CONTINUE_IF( vocabularies.contains(Vocabularies::Known::JSON_Schema_Draft_7) && schema.is_object()); - ONLY_CONTINUE_IF(subschema_at_dialect(schema, location, DRAFT_7_URL) || - has_actionable_id_fragment(schema) || - has_actionable_dependencies(schema) || - has_actionable_ref_siblings(schema)); + const bool needs_dialect_transition{ + subschema_at_dialect(schema, location, DRAFT_7_URL) || + has_actionable_id_fragment(schema) || + has_actionable_dependencies(schema) || + has_actionable_ref_siblings(schema)}; + + const bool needs_metaschema_vocabulary{is_metaschema && + location.pointer.empty() && + !schema.defines("$vocabulary")}; + + ONLY_CONTINUE_IF(needs_dialect_transition || needs_metaschema_vocabulary); for (const auto &entry : frame.locations()) { if (entry.second.type != @@ -45,6 +53,7 @@ class UpgradeDraft7To201909 final : public SchemaTransformRule { } } + this->metaschema_synthesis_pending_ = needs_metaschema_vocabulary; return true; } @@ -59,6 +68,10 @@ class UpgradeDraft7To201909 final : public SchemaTransformRule { } else { mark_dialect_override(schema, DRAFT_2019_09_URL); } + + if (this->metaschema_synthesis_pending_) { + synthesize_2019_09_vocabulary(schema); + } } [[nodiscard]] auto rereference(const std::string_view, @@ -87,6 +100,19 @@ class UpgradeDraft7To201909 final : public SchemaTransformRule { static constexpr std::string_view DRAFT_2019_09_URL{ "https://json-schema.org/draft/2019-09/schema"}; + static constexpr std::string_view VOCAB_2019_09_CORE_URL{ + "https://json-schema.org/draft/2019-09/vocab/core"}; + static constexpr std::string_view VOCAB_2019_09_APPLICATOR_URL{ + "https://json-schema.org/draft/2019-09/vocab/applicator"}; + static constexpr std::string_view VOCAB_2019_09_VALIDATION_URL{ + "https://json-schema.org/draft/2019-09/vocab/validation"}; + static constexpr std::string_view VOCAB_2019_09_META_DATA_URL{ + "https://json-schema.org/draft/2019-09/vocab/meta-data"}; + static constexpr std::string_view VOCAB_2019_09_FORMAT_URL{ + "https://json-schema.org/draft/2019-09/vocab/format"}; + static constexpr std::string_view VOCAB_2019_09_CONTENT_URL{ + "https://json-schema.org/draft/2019-09/vocab/content"}; + static inline const std::array SHADOW_EXEMPT_KEYWORDS{ {"$schema", "$id", "title", "description", "default", "examples", "$comment", "readOnly", "writeOnly", "deprecated", "contentMediaType", @@ -110,6 +136,8 @@ class UpgradeDraft7To201909 final : public SchemaTransformRule { std::pair> renames_; + mutable bool metaschema_synthesis_pending_{false}; + static auto is_shadow_exempt(const std::string_view keyword) -> bool { return std::ranges::any_of( SHADOW_EXEMPT_KEYWORDS, @@ -315,6 +343,52 @@ class UpgradeDraft7To201909 final : public SchemaTransformRule { return false; } + static auto synthesize_2019_09_vocabulary(sourcemeta::core::JSON &schema) + -> void { + std::string_view anchor; + if (schema.defines("$id")) { + anchor = "$id"; + } else if (schema.defines("$schema")) { + anchor = "$schema"; + } + + const std::string *next_key{nullptr}; + if (!anchor.empty()) { + bool found_anchor{false}; + for (const auto &entry : schema.as_object()) { + if (found_anchor) { + next_key = &entry.first; + break; + } + if (entry.first == anchor) { + found_anchor = true; + } + } + } + + if (next_key != nullptr) { + schema.try_assign_before( + "$vocabulary", sourcemeta::core::JSON::make_object(), *next_key); + } else { + schema.assign_assume_new("$vocabulary", + sourcemeta::core::JSON::make_object()); + } + + auto &vocabularies{schema.at("$vocabulary")}; + vocabularies.assign_assume_new(std::string{VOCAB_2019_09_CORE_URL}, + sourcemeta::core::JSON{true}); + vocabularies.assign_assume_new(std::string{VOCAB_2019_09_APPLICATOR_URL}, + sourcemeta::core::JSON{true}); + vocabularies.assign_assume_new(std::string{VOCAB_2019_09_VALIDATION_URL}, + sourcemeta::core::JSON{true}); + vocabularies.assign_assume_new(std::string{VOCAB_2019_09_META_DATA_URL}, + sourcemeta::core::JSON{true}); + vocabularies.assign_assume_new(std::string{VOCAB_2019_09_FORMAT_URL}, + sourcemeta::core::JSON{false}); + vocabularies.assign_assume_new(std::string{VOCAB_2019_09_CONTENT_URL}, + sourcemeta::core::JSON{true}); + } + static auto has_pending_pattern(const sourcemeta::core::JSON &subschema) -> bool { if (!subschema.is_object()) { diff --git a/vendor/blaze/src/compiler/default_compiler.cc b/vendor/blaze/src/compiler/default_compiler.cc index 28b20bdbb..5fe917fec 100644 --- a/vendor/blaze/src/compiler/default_compiler.cc +++ b/vendor/blaze/src/compiler/default_compiler.cc @@ -28,6 +28,7 @@ auto sourcemeta::blaze::default_schema_compiler( Known::JSON_Schema_2020_12_Validation, Known::JSON_Schema_2020_12_Meta_Data, Known::JSON_Schema_2020_12_Format_Annotation, + Known::JSON_Schema_2020_12_Format_Assertion, Known::JSON_Schema_2020_12_Content, Known::JSON_Schema_2019_09_Core, Known::JSON_Schema_2019_09_Applicator, @@ -113,6 +114,8 @@ auto sourcemeta::blaze::default_schema_compiler( compiler_2019_09_content_contentschema); COMPILE(Known::JSON_Schema_2020_12_Format_Annotation, "format", compiler_draft3_validation_format); + COMPILE(Known::JSON_Schema_2020_12_Format_Assertion, "format", + compiler_draft3_validation_format); // Same as Draft 7 diff --git a/vendor/blaze/src/compiler/default_compiler_draft3.h b/vendor/blaze/src/compiler/default_compiler_draft3.h index 9c2a5508e..198d2d7ae 100644 --- a/vendor/blaze/src/compiler/default_compiler_draft3.h +++ b/vendor/blaze/src/compiler/default_compiler_draft3.h @@ -2447,15 +2447,92 @@ auto compiler_draft3_validation_format(const Context &context, static constexpr auto unsupported_dialect_message{ "The format assertion tweak not supported in this dialect"}; - if (schema_context.vocabularies.contains(Known::JSON_Schema_2019_09_Format) || - schema_context.vocabularies.contains( - Known::JSON_Schema_2020_12_Format_Annotation)) { - if (context.tweaks.format_assertion) { - throw sourcemeta::blaze::CompilerError( - schema_context.base, to_pointer(schema_context.relative_pointer), - unsupported_dialect_message); + const auto is_2019_09_format{ + schema_context.vocabularies.contains(Known::JSON_Schema_2019_09_Format)}; + const auto is_2020_12_format_annotation{schema_context.vocabularies.contains( + Known::JSON_Schema_2020_12_Format_Annotation)}; + const auto is_2020_12_format_assertion{schema_context.vocabularies.contains( + Known::JSON_Schema_2020_12_Format_Assertion)}; + + const auto force_assertion{ + schema_context.schema.is_object() && + schema_context.schema.defines("x-format-assertion") && + schema_context.schema.at("x-format-assertion").is_boolean() && + schema_context.schema.at("x-format-assertion").to_boolean()}; + + const auto assert_active{context.tweaks.format_assertion || force_assertion}; + + if ((is_2019_09_format && assert_active) || is_2020_12_format_assertion || + (is_2020_12_format_annotation && assert_active)) { + const auto &format{schema_context.schema.at(dynamic_context.keyword)}; + if (!format.is_string()) { + return {}; + } + + const auto &name{format.to_string()}; + ValueStringType type; + if (name == "date-time") { + type = ValueStringType::DateTime; + } else if (name == "date") { + type = ValueStringType::Date; + } else if (name == "time") { + type = ValueStringType::Time; + } else if (name == "duration") { + type = ValueStringType::Duration; + } else if (name == "email") { + type = ValueStringType::Email; + } else if (name == "idn-email") { + type = ValueStringType::IDNEmail; + } else if (name == "hostname") { + type = ValueStringType::Hostname; + } else if (name == "idn-hostname") { + type = ValueStringType::IDNHostname; + } else if (name == "ipv4") { + type = ValueStringType::IPv4; + } else if (name == "ipv6") { + type = ValueStringType::IPv6; + } else if (name == "uri") { + type = ValueStringType::URI; + } else if (name == "uri-reference") { + type = ValueStringType::URIReference; + } else if (name == "iri") { + type = ValueStringType::IRI; + } else if (name == "iri-reference") { + type = ValueStringType::IRIReference; + } else if (name == "uri-template") { + type = ValueStringType::URITemplate; + } else if (name == "json-pointer") { + type = ValueStringType::JSONPointer; + } else if (name == "relative-json-pointer") { + type = ValueStringType::RelativeJSONPointer; + } else if (name == "regex") { + type = ValueStringType::Regex; + } else if (name == "uuid") { + type = ValueStringType::UUID; + } else { + return {}; + } + + Instructions instructions{ + make(sourcemeta::blaze::InstructionIndex::AssertionStringType, context, + schema_context, dynamic_context, type)}; + + if (context.mode == Mode::Exhaustive) { + Instructions annotation_children{ + make(sourcemeta::blaze::InstructionIndex::AnnotationEmit, context, + schema_context, dynamic_context, + sourcemeta::core::JSON{ + schema_context.schema.at(dynamic_context.keyword)})}; + instructions.push_back( + make(sourcemeta::blaze::InstructionIndex::ControlGroupWhenType, + context, schema_context, relative_dynamic_context(), + ValueType::String, std::move(annotation_children))); } + return instructions; + } + + if (is_2019_09_format || is_2020_12_format_annotation) { if (context.mode == Mode::FastValidation) { return {}; } @@ -2471,7 +2548,7 @@ auto compiler_draft3_validation_format(const Context &context, ValueType::String, std::move(children))}; } - if (!context.tweaks.format_assertion) { + if (!assert_active) { return {}; } @@ -2492,8 +2569,49 @@ auto compiler_draft3_validation_format(const Context &context, const auto is_draft6{ schema_context.vocabularies.contains(Known::JSON_Schema_Draft_6) || schema_context.vocabularies.contains(Known::JSON_Schema_Draft_6_Hyper)}; + const auto is_draft7{ + schema_context.vocabularies.contains(Known::JSON_Schema_Draft_7) || + schema_context.vocabularies.contains(Known::JSON_Schema_Draft_7_Hyper)}; - if (is_draft4 || is_draft6) { + if (is_draft7) { + if (name == "date-time") { + type = ValueStringType::DateTime; + } else if (name == "date") { + type = ValueStringType::Date; + } else if (name == "time") { + type = ValueStringType::Time; + } else if (name == "email") { + type = ValueStringType::Email; + } else if (name == "idn-email") { + type = ValueStringType::IDNEmail; + } else if (name == "hostname") { + type = ValueStringType::Hostname; + } else if (name == "idn-hostname") { + type = ValueStringType::IDNHostname; + } else if (name == "ipv4") { + type = ValueStringType::IPv4; + } else if (name == "ipv6") { + type = ValueStringType::IPv6; + } else if (name == "uri") { + type = ValueStringType::URI; + } else if (name == "uri-reference") { + type = ValueStringType::URIReference; + } else if (name == "uri-template") { + type = ValueStringType::URITemplate; + } else if (name == "json-pointer") { + type = ValueStringType::JSONPointer; + } else if (name == "relative-json-pointer") { + type = ValueStringType::RelativeJSONPointer; + } else if (name == "regex") { + type = ValueStringType::Regex; + } else if (name == "iri") { + type = ValueStringType::IRI; + } else if (name == "iri-reference") { + type = ValueStringType::IRIReference; + } else { + return {}; + } + } else if (is_draft4 || is_draft6) { if (name == "date-time") { type = ValueStringType::DateTime; } else if (name == "email") { @@ -2529,30 +2647,28 @@ auto compiler_draft3_validation_format(const Context &context, } else if (name == "uri") { type = ValueStringType::URI; } else if (name == "date") { - throw sourcemeta::blaze::CompilerError( - schema_context.base, to_pointer(schema_context.relative_pointer), - "The \"date\" format is not supported in assertion mode yet"); + type = ValueStringType::Date; } else if (name == "time") { - throw sourcemeta::blaze::CompilerError( - schema_context.base, to_pointer(schema_context.relative_pointer), - "The \"time\" format is not supported in assertion mode yet"); + type = ValueStringType::PartialTime; } else if (name == "utc-millisec") { + // TODO: Support this old format, even though not even the official test + // suite covers it throw sourcemeta::blaze::CompilerError( schema_context.base, to_pointer(schema_context.relative_pointer), "The \"utc-millisec\" format is not supported in assertion mode yet"); } else if (name == "regex") { - throw sourcemeta::blaze::CompilerError( - schema_context.base, to_pointer(schema_context.relative_pointer), - "The \"regex\" format is not supported in assertion mode yet"); + type = ValueStringType::Regex; } else if (name == "color") { - throw sourcemeta::blaze::CompilerError( - schema_context.base, to_pointer(schema_context.relative_pointer), - "The \"color\" format is not supported in assertion mode yet"); + type = ValueStringType::Color; } else if (name == "style") { + // TODO: Support this old format, even though not even the official test + // suite covers it throw sourcemeta::blaze::CompilerError( schema_context.base, to_pointer(schema_context.relative_pointer), "The \"style\" format is not supported in assertion mode yet"); } else if (name == "phone") { + // TODO: Support this old format, even though not even the official test + // suite covers it throw sourcemeta::blaze::CompilerError( schema_context.base, to_pointer(schema_context.relative_pointer), "The \"phone\" format is not supported in assertion mode yet"); diff --git a/vendor/blaze/src/evaluator/CMakeLists.txt b/vendor/blaze/src/evaluator/CMakeLists.txt index 7adf7b920..2b04a12f8 100644 --- a/vendor/blaze/src/evaluator/CMakeLists.txt +++ b/vendor/blaze/src/evaluator/CMakeLists.txt @@ -29,3 +29,7 @@ target_link_libraries(sourcemeta_blaze_evaluator PUBLIC sourcemeta::core::dns) target_link_libraries(sourcemeta_blaze_evaluator PUBLIC sourcemeta::core::time) +target_link_libraries(sourcemeta_blaze_evaluator PUBLIC + sourcemeta::core::crypto) +target_link_libraries(sourcemeta_blaze_evaluator PUBLIC + sourcemeta::core::css) diff --git a/vendor/blaze/src/evaluator/evaluator_describe.cc b/vendor/blaze/src/evaluator/evaluator_describe.cc index 01503f5a1..e970478c3 100644 --- a/vendor/blaze/src/evaluator/evaluator_describe.cc +++ b/vendor/blaze/src/evaluator/evaluator_describe.cc @@ -60,7 +60,7 @@ auto value_type_name(const sourcemeta::core::JSON &value) -> std::string_view { return type_name(value.type()); } -auto escape_string(const std::string &input) -> std::string { +auto escape_string(const std::string_view input) -> std::string { std::size_t size{2}; for (const auto character : input) { size += (character == '"') ? 2 : 1; @@ -1357,6 +1357,37 @@ auto describe(const bool valid, const Instruction &step, } } + if (valid) { + return message.str(); + } + + assert(target.is_object()); + std::set extras; + for (const auto &entry : target.as_object()) { + if (!value.contains(entry.first, entry.hash)) { + extras.insert(entry.first); + } + } + + if (extras.empty()) { + return message.str(); + } + + if (extras.size() == 1) { + message << ", but it also defines the property " + << escape_string(*(extras.cbegin())); + } else { + message << ", but it also defines properties "; + for (auto iterator = extras.cbegin(); iterator != extras.cend(); + ++iterator) { + if (std::next(iterator) == extras.cend()) { + message << "and " << escape_string(*iterator); + } else { + message << escape_string(*iterator) << ", "; + } + } + } + return message.str(); } @@ -1382,6 +1413,36 @@ auto describe(const bool valid, const Instruction &step, } } + if (valid || !target.is_object()) { + return message.str(); + } + + std::set extras; + for (const auto &entry : target.as_object()) { + if (!value.contains(entry.first, entry.hash)) { + extras.insert(entry.first); + } + } + + if (extras.empty()) { + return message.str(); + } + + if (extras.size() == 1) { + message << ", but it also defines the property " + << escape_string(*(extras.cbegin())); + } else { + message << ", but it also defines properties "; + for (auto iterator = extras.cbegin(); iterator != extras.cend(); + ++iterator) { + if (std::next(iterator) == extras.cend()) { + message << "and " << escape_string(*iterator); + } else { + message << escape_string(*iterator) << ", "; + } + } + } + return message.str(); } @@ -1392,6 +1453,45 @@ auto describe(const bool valid, const Instruction &step, message << "The value was expected to be an object that only defines " "the " << value.size() << " given properties"; + + if (valid || !target.is_object()) { + return message.str(); + } + + std::set extras; + for (const auto &entry : target.as_object()) { + bool allowed{false}; + for (const auto &candidate : value) { + if (candidate.first == entry.hash && candidate.second == entry.first) { + allowed = true; + break; + } + } + + if (!allowed) { + extras.insert(entry.first); + } + } + + if (extras.empty()) { + return message.str(); + } + + if (extras.size() == 1) { + message << ", but it also defines the property " + << escape_string(*(extras.cbegin())); + } else { + message << ", but it also defines properties "; + for (auto iterator = extras.cbegin(); iterator != extras.cend(); + ++iterator) { + if (std::next(iterator) == extras.cend()) { + message << "and " << escape_string(*iterator); + } else { + message << escape_string(*iterator) << ", "; + } + } + } + return message.str(); } @@ -2023,9 +2123,18 @@ auto describe(const bool valid, const Instruction &step, case ValueStringType::URITemplate: message << " URI template"; break; + case ValueStringType::IRI: + message << " IRI"; + break; + case ValueStringType::IRIReference: + message << " IRI reference"; + break; case ValueStringType::Email: message << " email address"; break; + case ValueStringType::IDNEmail: + message << " internationalized email address"; + break; case ValueStringType::IPv4: message << " IPv4 address"; break; @@ -2035,12 +2144,39 @@ auto describe(const bool valid, const Instruction &step, case ValueStringType::Hostname: message << " hostname"; break; + case ValueStringType::IDNHostname: + message << " internationalized hostname"; + break; case ValueStringType::DateTime: message << " RFC 3339 date-time"; break; + case ValueStringType::Date: + message << " RFC 3339 full-date"; + break; + case ValueStringType::Time: + message << " RFC 3339 full-time"; + break; + case ValueStringType::PartialTime: + message << " RFC 3339 partial-time without fractional seconds"; + break; + case ValueStringType::Duration: + message << " RFC 3339 duration"; + break; case ValueStringType::JSONPointer: message << " JSON Pointer"; break; + case ValueStringType::RelativeJSONPointer: + message << " relative JSON Pointer"; + break; + case ValueStringType::UUID: + message << " UUID"; + break; + case ValueStringType::Regex: + message << " ECMA-262 regular expression"; + break; + case ValueStringType::Color: + message << " CSS 2 color"; + break; default: return unknown(); } diff --git a/vendor/blaze/src/evaluator/include/sourcemeta/blaze/evaluator_dispatch.h b/vendor/blaze/src/evaluator/include/sourcemeta/blaze/evaluator_dispatch.h index 951eb59e7..bf9fa62dc 100644 --- a/vendor/blaze/src/evaluator/include/sourcemeta/blaze/evaluator_dispatch.h +++ b/vendor/blaze/src/evaluator/include/sourcemeta/blaze/evaluator_dispatch.h @@ -3,9 +3,12 @@ #include +#include +#include #include #include #include +#include #include #include @@ -879,9 +882,18 @@ INSTRUCTION_HANDLER(AssertionStringType) { case ValueStringType::URITemplate: result = URITemplate::is_uritemplate(target); break; + case ValueStringType::IRI: + result = URI::is_iri(target); + break; + case ValueStringType::IRIReference: + result = URI::is_iri_reference(target); + break; case ValueStringType::Email: result = is_email(target); break; + case ValueStringType::IDNEmail: + result = is_idn_email(target); + break; case ValueStringType::IPv4: result = is_ipv4(target); break; @@ -891,12 +903,39 @@ INSTRUCTION_HANDLER(AssertionStringType) { case ValueStringType::Hostname: result = is_hostname(target); break; + case ValueStringType::IDNHostname: + result = is_idn_hostname(target); + break; case ValueStringType::DateTime: result = is_rfc3339_datetime(target); break; + case ValueStringType::Date: + result = is_rfc3339_fulldate(target); + break; + case ValueStringType::Time: + result = is_rfc3339_fulltime(target); + break; + case ValueStringType::PartialTime: + result = is_rfc3339_partialtime_no_secfrac(target); + break; + case ValueStringType::Duration: + result = is_rfc3339_duration(target); + break; case ValueStringType::JSONPointer: result = is_pointer(target); break; + case ValueStringType::RelativeJSONPointer: + result = is_relative_pointer(target); + break; + case ValueStringType::UUID: + result = is_uuid_like(target); + break; + case ValueStringType::Regex: + result = is_regex_ecma(target); + break; + case ValueStringType::Color: + result = is_css2_color(target); + break; default: std::unreachable(); } diff --git a/vendor/blaze/src/evaluator/include/sourcemeta/blaze/evaluator_value.h b/vendor/blaze/src/evaluator/include/sourcemeta/blaze/evaluator_value.h index 78b537e7c..38e59f7a5 100644 --- a/vendor/blaze/src/evaluator/include/sourcemeta/blaze/evaluator_value.h +++ b/vendor/blaze/src/evaluator/include/sourcemeta/blaze/evaluator_value.h @@ -124,12 +124,24 @@ enum class ValueStringType : std::uint8_t { URI, URIReference, URITemplate, + IRI, + IRIReference, Email, + IDNEmail, IPv4, IPv6, Hostname, + IDNHostname, DateTime, - JSONPointer + Date, + Time, + PartialTime, + Duration, + JSONPointer, + RelativeJSONPointer, + UUID, + Regex, + Color }; /// @ingroup evaluator diff --git a/vendor/blaze/src/foundation/foundation.cc b/vendor/blaze/src/foundation/foundation.cc index e93b713e6..438ffba3c 100644 --- a/vendor/blaze/src/foundation/foundation.cc +++ b/vendor/blaze/src/foundation/foundation.cc @@ -512,10 +512,16 @@ auto sourcemeta::blaze::parse_vocabularies( return std::nullopt; } - assert(vocabulary_entry->is_object()); + if (!vocabulary_entry->is_object()) { + return std::nullopt; + } + sourcemeta::blaze::Vocabularies result; for (const auto &entry : vocabulary_entry->as_object()) { - assert(entry.second.is_boolean()); + if (!entry.second.is_boolean()) { + return std::nullopt; + } + result.insert(entry.first, entry.second.to_boolean()); } diff --git a/vendor/core/CMakeLists.txt b/vendor/core/CMakeLists.txt index 7c87031ed..742cb6fcd 100644 --- a/vendor/core/CMakeLists.txt +++ b/vendor/core/CMakeLists.txt @@ -30,9 +30,11 @@ option(SOURCEMETA_CORE_JSONL "Build the Sourcemeta Core JSONL library" ON) option(SOURCEMETA_CORE_YAML "Build the Sourcemeta Core YAML library" ON) option(SOURCEMETA_CORE_JSONRPC "Build the Sourcemeta Core JSON-RPC library" ON) option(SOURCEMETA_CORE_MCP "Build the Sourcemeta Core MCP library" ON) +option(SOURCEMETA_CORE_HTTP "Build the Sourcemeta Core HTTP library" ON) option(SOURCEMETA_CORE_SEMVER "Build the Sourcemeta Core SemVer library" ON) option(SOURCEMETA_CORE_GZIP "Build the Sourcemeta Core GZIP library" ON) option(SOURCEMETA_CORE_HTML "Build the Sourcemeta Core HTML library" ON) +option(SOURCEMETA_CORE_CSS "Build the Sourcemeta Core CSS library" ON) option(SOURCEMETA_CORE_MARKDOWN "Build the Sourcemeta Core Markdown library" ON) option(SOURCEMETA_CORE_TESTS "Build the Sourcemeta Core tests" OFF) option(SOURCEMETA_CORE_BENCHMARK "Build the Sourcemeta Core benchmarks" OFF) @@ -183,6 +185,10 @@ if(SOURCEMETA_CORE_MCP) add_subdirectory(src/core/mcp) endif() +if(SOURCEMETA_CORE_HTTP) + add_subdirectory(src/core/http) +endif() + if(SOURCEMETA_CORE_SEMVER) add_subdirectory(src/core/semver) endif() @@ -191,6 +197,10 @@ if(SOURCEMETA_CORE_HTML) add_subdirectory(src/core/html) endif() +if(SOURCEMETA_CORE_CSS) + add_subdirectory(src/core/css) +endif() + if(SOURCEMETA_CORE_MARKDOWN) find_package(CMarkGFM REQUIRED) add_subdirectory(src/core/markdown) @@ -333,6 +343,10 @@ if(SOURCEMETA_CORE_TESTS) add_subdirectory(test/mcp) endif() + if(SOURCEMETA_CORE_HTTP) + add_subdirectory(test/http) + endif() + if(SOURCEMETA_CORE_SEMVER) add_subdirectory(test/semver) endif() @@ -341,6 +355,10 @@ if(SOURCEMETA_CORE_TESTS) add_subdirectory(test/html) endif() + if(SOURCEMETA_CORE_CSS) + add_subdirectory(test/css) + endif() + if(SOURCEMETA_CORE_MARKDOWN) add_subdirectory(test/markdown) endif() diff --git a/vendor/core/cmake/FindPCRE2.cmake b/vendor/core/cmake/FindPCRE2.cmake index a3cf0ae4d..29e44e328 100644 --- a/vendor/core/cmake/FindPCRE2.cmake +++ b/vendor/core/cmake/FindPCRE2.cmake @@ -101,6 +101,7 @@ if(NOT PCRE2_FOUND) if(SOURCEMETA_COMPILER_LLVM OR SOURCEMETA_COMPILER_GCC) target_compile_options(sljit PRIVATE -Wno-double-promotion) target_compile_options(sljit PRIVATE -Wno-conditional-uninitialized) + target_compile_options(sljit PRIVATE -fstrict-flex-arrays=0) endif() if(SOURCEMETA_COMPILER_MSVC) @@ -138,6 +139,7 @@ if(NOT PCRE2_FOUND) target_compile_options(pcre2 PRIVATE -Wno-overlength-strings) target_compile_options(pcre2 PRIVATE -Wno-conversion) target_compile_options(pcre2 PRIVATE -Wno-type-limits) + target_compile_options(pcre2 PRIVATE -fstrict-flex-arrays=0) endif() if(SOURCEMETA_COMPILER_MSVC) diff --git a/vendor/core/cmake/common/compiler/options.cmake b/vendor/core/cmake/common/compiler/options.cmake index 54cca1ad3..150799252 100644 --- a/vendor/core/cmake/common/compiler/options.cmake +++ b/vendor/core/cmake/common/compiler/options.cmake @@ -73,7 +73,25 @@ function(sourcemeta_add_default_options visibility target) # run analyses that never reach codegen, costing build time for no # behavioral effect $<$>:-funroll-loops> - $<$>:-ftree-vectorize>) + $<$>:-ftree-vectorize> + + # See https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html + -Wformat + -Wformat=2 + -Werror=format-security + -fstrict-flex-arrays=3) + + # Hardware-assisted control-flow protection. The compiler emits these as + # HINT-space instructions that are NOPs on CPUs without the feature, so + # binaries remain compatible with older hardware + if(SOURCEMETA_OS_LINUX) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + target_compile_options("${target}" ${visibility} -fcf-protection=full) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" + OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + target_compile_options("${target}" ${visibility} -mbranch-protection=standard) + endif() + endif() endif() if(SOURCEMETA_COMPILER_LLVM) @@ -102,6 +120,11 @@ function(sourcemeta_add_default_options visibility target) $<$>:-fvectorize> # Enable vectorization of straight-line code for performance $<$>:-fslp-vectorize>) + + # Prevent the compiler from deleting redundant null-pointer checks after + # a dereference would normally prove them unreachable + target_compile_options("${target}" ${visibility} + $<$>:-fno-delete-null-pointer-checks>) elseif(SOURCEMETA_COMPILER_GCC) target_compile_options("${target}" ${visibility} # Newer versions of GCC (i.e. 14) seem to print a lot of false-positives here @@ -111,8 +134,21 @@ function(sourcemeta_add_default_options visibility target) # Disables runtime type information $<$,$>:-fno-rtti> # See https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html + -Wtrampolines + -Wbidi-chars=any -fstack-clash-protection) + # Prevent the compiler from deleting redundant null-pointer checks after + # a dereference would normally prove them unreachable + target_compile_options("${target}" ${visibility} + $<$>:-fno-delete-null-pointer-checks>) + + # Prevent the compiler from assuming shared library symbols could be + # interposed at runtime, enabling more inlining and devirtualization + if(BUILD_SHARED_LIBS) + target_compile_options("${target}" ${visibility} -fno-semantic-interposition) + endif() + # _GLIBCXX_ASSERTIONS is libstdc++ (GNU) specific, not honored by libc++ # (which the LLVM toolchain on Apple ships). Restrict to non-Apple GCC # to avoid emitting a Debug-only definition that does nothing on macOS diff --git a/vendor/core/config.cmake.in b/vendor/core/config.cmake.in index cd1bb4491..e02574a6a 100644 --- a/vendor/core/config.cmake.in +++ b/vendor/core/config.cmake.in @@ -26,9 +26,11 @@ if(NOT SOURCEMETA_CORE_COMPONENTS) list(APPEND SOURCEMETA_CORE_COMPONENTS yaml) list(APPEND SOURCEMETA_CORE_COMPONENTS jsonrpc) list(APPEND SOURCEMETA_CORE_COMPONENTS mcp) + list(APPEND SOURCEMETA_CORE_COMPONENTS http) list(APPEND SOURCEMETA_CORE_COMPONENTS semver) list(APPEND SOURCEMETA_CORE_COMPONENTS gzip) list(APPEND SOURCEMETA_CORE_COMPONENTS html) + list(APPEND SOURCEMETA_CORE_COMPONENTS css) list(APPEND SOURCEMETA_CORE_COMPONENTS markdown) list(APPEND SOURCEMETA_CORE_COMPONENTS error) list(APPEND SOURCEMETA_CORE_COMPONENTS options) @@ -89,6 +91,7 @@ foreach(component ${SOURCEMETA_CORE_COMPONENTS}) elseif(component STREQUAL "uri") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_io.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_ip.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_text.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_uri.cmake") elseif(component STREQUAL "uritemplate") find_dependency(PCRE2 CONFIG) @@ -149,6 +152,14 @@ foreach(component ${SOURCEMETA_CORE_COMPONENTS}) include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonrpc.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_mcp.cmake") + elseif(component STREQUAL "http") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_preprocessor.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_numeric.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_io.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_unicode.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_time.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_http.cmake") elseif(component STREQUAL "semver") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_preprocessor.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_semver.cmake") @@ -159,6 +170,11 @@ foreach(component ${SOURCEMETA_CORE_COMPONENTS}) elseif(component STREQUAL "html") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_preprocessor.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_html.cmake") + elseif(component STREQUAL "css") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_preprocessor.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_numeric.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_text.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_css.cmake") elseif(component STREQUAL "markdown") find_dependency(cmark_gfm CONFIG) include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_markdown.cmake") diff --git a/vendor/core/src/core/crypto/CMakeLists.txt b/vendor/core/src/core/crypto/CMakeLists.txt index 2d7fe1fc6..bc5a62e95 100644 --- a/vendor/core/src/core/crypto/CMakeLists.txt +++ b/vendor/core/src/core/crypto/CMakeLists.txt @@ -1,6 +1,6 @@ sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME crypto - PRIVATE_HEADERS sha256.h uuid.h - SOURCES crypto_sha256.cc crypto_uuid.cc) + PRIVATE_HEADERS sha256.h uuid.h crc32.h + SOURCES crypto_sha256.cc crypto_uuid.cc crypto_crc32.cc) if(SOURCEMETA_CORE_CRYPTO_USE_SYSTEM_OPENSSL) target_compile_definitions(sourcemeta_core_crypto diff --git a/vendor/core/src/core/crypto/crypto_crc32.cc b/vendor/core/src/core/crypto/crypto_crc32.cc new file mode 100644 index 000000000..1220366b7 --- /dev/null +++ b/vendor/core/src/core/crypto/crypto_crc32.cc @@ -0,0 +1,48 @@ +#include + +#include // std::array +#include // std::size_t +#include // std::uint8_t, std::uint32_t + +namespace { + +constexpr auto compute_crc32_table_entry(const std::uint32_t value) noexcept + -> std::uint32_t { + auto entry{value}; + for (int bit_index = 0; bit_index < 8; ++bit_index) { + const auto mask{ + static_cast(-static_cast(entry & 1u))}; + entry = (entry >> 1u) ^ (0xEDB88320u & mask); + } + return entry; +} + +constexpr auto build_crc32_table() noexcept -> std::array { + std::array table{}; + for (std::uint32_t index = 0; index < 256u; ++index) { + table[index] = compute_crc32_table_entry(index); + } + return table; +} + +constexpr std::array CRC32_TABLE{build_crc32_table()}; + +} // namespace + +namespace sourcemeta::core { + +auto crc32(const std::string_view input) -> std::uint32_t { + return crc32_update(0u, input); +} + +auto crc32_update(const std::uint32_t previous, const std::string_view input) + -> std::uint32_t { + auto checksum{previous ^ 0xFFFFFFFFu}; + for (const auto character : input) { + const auto byte{static_cast(character)}; + checksum = CRC32_TABLE[(checksum ^ byte) & 0xffu] ^ (checksum >> 8u); + } + return checksum ^ 0xFFFFFFFFu; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/crypto/include/sourcemeta/core/crypto.h b/vendor/core/src/core/crypto/include/sourcemeta/core/crypto.h index 332cc8427..520e0954b 100644 --- a/vendor/core/src/core/crypto/include/sourcemeta/core/crypto.h +++ b/vendor/core/src/core/crypto/include/sourcemeta/core/crypto.h @@ -10,6 +10,7 @@ /// #include /// ``` +#include #include #include diff --git a/vendor/core/src/core/crypto/include/sourcemeta/core/crypto_crc32.h b/vendor/core/src/core/crypto/include/sourcemeta/core/crypto_crc32.h new file mode 100644 index 000000000..914761f70 --- /dev/null +++ b/vendor/core/src/core/crypto/include/sourcemeta/core/crypto_crc32.h @@ -0,0 +1,45 @@ +#ifndef SOURCEMETA_CORE_CRYPTO_CRC32_H_ +#define SOURCEMETA_CORE_CRYPTO_CRC32_H_ + +#ifndef SOURCEMETA_CORE_CRYPTO_EXPORT +#include +#endif + +#include // std::uint32_t +#include // std::string_view + +namespace sourcemeta::core { + +/// @ingroup crypto +/// Compute the CRC-32 checksum (ISO 3309, polynomial 0xEDB88320) of a byte +/// sequence. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// std::cout << sourcemeta::core::crc32("123456789") << "\n"; +/// ``` +auto SOURCEMETA_CORE_CRYPTO_EXPORT crc32(const std::string_view input) + -> std::uint32_t; + +/// @ingroup crypto +/// Extend an existing CRC-32 checksum with additional bytes, returning the +/// updated value. Pass zero as the previous value to start a fresh +/// computation. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// auto checksum{sourcemeta::core::crc32_update(0, "hello")}; +/// checksum = sourcemeta::core::crc32_update(checksum, " world"); +/// std::cout << checksum << "\n"; +/// ``` +auto SOURCEMETA_CORE_CRYPTO_EXPORT crc32_update(const std::uint32_t previous, + const std::string_view input) + -> std::uint32_t; + +} // namespace sourcemeta::core + +#endif diff --git a/vendor/core/src/core/css/CMakeLists.txt b/vendor/core/src/core/css/CMakeLists.txt new file mode 100644 index 000000000..054580639 --- /dev/null +++ b/vendor/core/src/core/css/CMakeLists.txt @@ -0,0 +1,9 @@ +sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME css + SOURCES css2_color.cc) + +if(SOURCEMETA_CORE_INSTALL) + sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME css) +endif() + +target_link_libraries(sourcemeta_core_css PRIVATE sourcemeta::core::numeric) +target_link_libraries(sourcemeta_core_css PRIVATE sourcemeta::core::text) diff --git a/vendor/core/src/core/css/css2_color.cc b/vendor/core/src/core/css/css2_color.cc new file mode 100644 index 000000000..f7672e855 --- /dev/null +++ b/vendor/core/src/core/css/css2_color.cc @@ -0,0 +1,235 @@ +#include +#include +#include + +#include // std::array +#include // assert +#include // std::uint8_t + +namespace { + +// CSS Core Syntax whitespace: U+0009, U+000A, U+000C, U+000D, U+0020 +constexpr auto is_css_whitespace(const char character) noexcept -> bool { + return character == ' ' || character == '\t' || character == '\n' || + character == '\r' || character == '\f'; +} + +constexpr auto equals_ascii_ci(const std::string_view left, + const std::string_view right) noexcept -> bool { + assert(left.size() == right.size()); + for (std::string_view::size_type position{0}; position < left.size(); + position += 1) { + if (sourcemeta::core::to_lowercase(left[position]) != right[position]) { + return false; + } + } + return true; +} + +constexpr std::array CSS2_KEYWORDS{ + {"aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", + "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", + "yellow"}}; + +auto skip_whitespace(const std::string_view value, + std::string_view::size_type &position) noexcept -> void { + while (position < value.size() && is_css_whitespace(value[position])) { + position += 1; + } +} + +auto match_literal_ci(const std::string_view value, + std::string_view::size_type &position, + const std::string_view literal) noexcept -> bool { + if (position + literal.size() > value.size()) { + return false; + } + for (std::string_view::size_type index{0}; index < literal.size(); + index += 1) { + if (sourcemeta::core::to_lowercase(value[position + index]) != + literal[index]) { + return false; + } + } + position += literal.size(); + return true; +} + +auto match_byte(const std::string_view value, + std::string_view::size_type &position, + const char expected) noexcept -> bool { + if (position >= value.size() || value[position] != expected) { + return false; + } + position += 1; + return true; +} + +auto parse_number(const std::string_view value, + std::string_view::size_type &position, + bool &has_decimal) noexcept -> bool { + const auto start{position}; + has_decimal = false; + + if (position < value.size() && + (value[position] == '+' || value[position] == '-')) { + position += 1; + } + + const auto integer_start{position}; + while (position < value.size() && + sourcemeta::core::is_digit(value[position])) { + position += 1; + } + const auto integer_digits{position - integer_start}; + + if (position < value.size() && value[position] == '.') { + has_decimal = true; + position += 1; + const auto fractional_start{position}; + while (position < value.size() && + sourcemeta::core::is_digit(value[position])) { + position += 1; + } + const auto fractional_digits{position - fractional_start}; + if (fractional_digits == 0) { + position = start; + return false; + } + } else if (integer_digits == 0) { + position = start; + return false; + } + + return true; +} + +enum class RgbValueKind : std::uint8_t { Integer, Percentage }; + +auto parse_value(const std::string_view value, + std::string_view::size_type &position, + RgbValueKind &kind) noexcept -> bool { + const auto start{position}; + bool has_decimal{false}; + if (!parse_number(value, position, has_decimal)) { + return false; + } + + if (position < value.size() && value[position] == '%') { + position += 1; + kind = RgbValueKind::Percentage; + return true; + } + + if (has_decimal) { + position = start; + return false; + } + + kind = RgbValueKind::Integer; + return true; +} + +} // namespace + +namespace sourcemeta::core { + +auto is_css2_hex_color(const std::string_view value) noexcept -> bool { + if (value.size() != 4 && value.size() != 7) { + return false; + } + + if (value[0] != '#') { + return false; + } + + for (std::string_view::size_type position{1}; position < value.size(); + position += 1) { + if (!sourcemeta::core::is_hex_digit(value[position])) { + return false; + } + } + + return true; +} + +auto is_css2_color_keyword(const std::string_view value) noexcept -> bool { + if (value.size() < 3 || value.size() > 7) { + return false; + } + + for (const auto &keyword : CSS2_KEYWORDS) { + if (keyword.size() != value.size()) { + continue; + } + if (equals_ascii_ci(value, keyword)) { + return true; + } + } + + return false; +} + +auto is_css2_rgb_function(const std::string_view value) noexcept -> bool { + std::string_view::size_type position{0}; + + // Per CSS 2.1, the function-token is `IDENT(` with no whitespace between + // the identifier and the opening paren, and the `` value itself + // does not include surrounding whitespace + if (!match_literal_ci(value, position, "rgb")) { + return false; + } + + if (!match_byte(value, position, '(')) { + return false; + } + + skip_whitespace(value, position); + + RgbValueKind first_kind{}; + if (!parse_value(value, position, first_kind)) { + return false; + } + + skip_whitespace(value, position); + if (!match_byte(value, position, ',')) { + return false; + } + skip_whitespace(value, position); + + RgbValueKind second_kind{}; + if (!parse_value(value, position, second_kind)) { + return false; + } + if (second_kind != first_kind) { + return false; + } + + skip_whitespace(value, position); + if (!match_byte(value, position, ',')) { + return false; + } + skip_whitespace(value, position); + + RgbValueKind third_kind{}; + if (!parse_value(value, position, third_kind)) { + return false; + } + if (third_kind != first_kind) { + return false; + } + + skip_whitespace(value, position); + if (!match_byte(value, position, ')')) { + return false; + } + + return position == value.size(); +} + +auto is_css2_color(const std::string_view value) noexcept -> bool { + return is_css2_hex_color(value) || is_css2_color_keyword(value) || + is_css2_rgb_function(value); +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/css/include/sourcemeta/core/css.h b/vendor/core/src/core/css/include/sourcemeta/core/css.h new file mode 100644 index 000000000..a8c8a0135 --- /dev/null +++ b/vendor/core/src/core/css/include/sourcemeta/core/css.h @@ -0,0 +1,128 @@ +#ifndef SOURCEMETA_CORE_CSS_H_ +#define SOURCEMETA_CORE_CSS_H_ + +#ifndef SOURCEMETA_CORE_CSS_EXPORT +#include +#endif + +#include // std::string_view + +/// @defgroup css CSS +/// @brief A growing implementation of CSS-related utilities. +/// +/// This functionality is included as follows: +/// +/// ```cpp +/// #include +/// ``` + +namespace sourcemeta::core { + +/// @ingroup css +/// Check whether the given string is a valid CSS 2.1 hex color per §4.3.6. +/// Accepts only the two hex notations defined by CSS 2.1: +/// +/// ``` +/// "#" 3HEXDIG ; e.g. "#C89" +/// "#" 6HEXDIG ; e.g. "#CC8899" +/// ``` +/// +/// Hex digits are case-insensitive. The 4-digit and 8-digit alpha forms +/// from CSS Color Module Level 4 are not accepted. For example: +/// +/// ```cpp +/// #include +/// +/// #include +/// +/// assert(sourcemeta::core::is_css2_hex_color("#CC8899")); +/// assert(sourcemeta::core::is_css2_hex_color("#C89")); +/// assert(!sourcemeta::core::is_css2_hex_color("#00332520")); +/// assert(!sourcemeta::core::is_css2_hex_color("CC8899")); +/// ``` +SOURCEMETA_CORE_CSS_EXPORT +auto is_css2_hex_color(const std::string_view value) noexcept -> bool; + +/// @ingroup css +/// Check whether the given string is one of the 17 CSS 2.1 color keywords +/// defined in §4.3.6: +/// +/// ``` +/// aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, +/// olive, orange, purple, red, silver, teal, white, yellow +/// ``` +/// +/// Matching is case-insensitive. The `transparent` keyword and the +/// deprecated system colors (`ButtonFace`, `ActiveBorder`, etc.) are out +/// of scope, as are the extended X11 names introduced by CSS Color Module +/// Level 3. For example: +/// +/// ```cpp +/// #include +/// +/// #include +/// +/// assert(sourcemeta::core::is_css2_color_keyword("fuchsia")); +/// assert(sourcemeta::core::is_css2_color_keyword("RED")); +/// assert(!sourcemeta::core::is_css2_color_keyword("puce")); +/// assert(!sourcemeta::core::is_css2_color_keyword("papayawhip")); +/// ``` +SOURCEMETA_CORE_CSS_EXPORT +auto is_css2_color_keyword(const std::string_view value) noexcept -> bool; + +/// @ingroup css +/// Check whether the given string is a valid CSS 2.1 functional RGB color +/// per §4.3.6. Accepts both the integer and percentage forms: +/// +/// ``` +/// rgb( , , ) +/// rgb( , , ) +/// ``` +/// +/// All three values must be the same type. The function name `rgb` is +/// case-insensitive, and CSS whitespace (space, tab, CR, LF, FF) is +/// permitted between tokens. Out-of-range values are accepted (CSS 2.1 +/// clamps at use time). The 4-argument `rgba(...)` form from CSS Color +/// Module Level 3 is not accepted. For example: +/// +/// ```cpp +/// #include +/// +/// #include +/// +/// assert(sourcemeta::core::is_css2_rgb_function("rgb(255, 0, 128)")); +/// assert(sourcemeta::core::is_css2_rgb_function("rgb(100%, 0%, 50%)")); +/// assert(sourcemeta::core::is_css2_rgb_function("rgb(300, -5, 128)")); +/// assert(!sourcemeta::core::is_css2_rgb_function("rgb(100%, 0, 50%)")); +/// assert(!sourcemeta::core::is_css2_rgb_function("rgba(0, 0, 0, 1)")); +/// ``` +SOURCEMETA_CORE_CSS_EXPORT +auto is_css2_rgb_function(const std::string_view value) noexcept -> bool; + +/// @ingroup css +/// Check whether the given string is a valid CSS 2.1 `` value per +/// §4.3.6. The accept set is the union of: +/// +/// - `is_css2_hex_color` +/// - `is_css2_color_keyword` +/// - `is_css2_rgb_function` +/// +/// For example: +/// +/// ```cpp +/// #include +/// +/// #include +/// +/// assert(sourcemeta::core::is_css2_color("fuchsia")); +/// assert(sourcemeta::core::is_css2_color("#CC8899")); +/// assert(sourcemeta::core::is_css2_color("rgb(255, 0, 0)")); +/// assert(!sourcemeta::core::is_css2_color("puce")); +/// assert(!sourcemeta::core::is_css2_color("#00332520")); +/// ``` +SOURCEMETA_CORE_CSS_EXPORT +auto is_css2_color(const std::string_view value) noexcept -> bool; + +} // namespace sourcemeta::core + +#endif diff --git a/vendor/core/src/core/dns/hostname.cc b/vendor/core/src/core/dns/hostname.cc index 7d116450c..e048fba73 100644 --- a/vendor/core/src/core/dns/hostname.cc +++ b/vendor/core/src/core/dns/hostname.cc @@ -1,5 +1,7 @@ #include +#include +#include // std::string #include // std::string_view namespace sourcemeta::core { @@ -58,6 +60,20 @@ auto is_hostname(const std::string_view value) -> bool { return false; } + // RFC 5890 §2.3.2.1: the ACE prefix "xn--" is case-insensitive. A-labels + // must also satisfy RFC 5891 §4.2.3 and RFC 5892 (Punycode round-trip, + // IDNA 2008 derived properties, contextual rules) + if (label_length >= 4 && ((value[label_start] | 0x20) == 'x') && + ((value[label_start + 1] | 0x20) == 'n') && + value[label_start + 2] == '-' && value[label_start + 3] == '-') { + std::string canonical{value.substr(label_start, label_length)}; + canonical[0] = 'x'; + canonical[1] = 'n'; + if (!idna_is_valid_a_label(canonical)) { + return false; + } + } + if (position < value.size()) { // value[position] == '.' position += 1; diff --git a/vendor/core/src/core/http/CMakeLists.txt b/vendor/core/src/core/http/CMakeLists.txt new file mode 100644 index 000000000..60034a76c --- /dev/null +++ b/vendor/core/src/core/http/CMakeLists.txt @@ -0,0 +1,12 @@ +sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME http + PRIVATE_HEADERS problem.h status.h + SOURCES helpers.h problem.cc match_accept.cc match_accept_language.cc + negotiate_encoding.cc from_date.cc format_link.cc field_list.cc + accept_includes_all.cc content_type_matches.cc) + +if(SOURCEMETA_CORE_INSTALL) + sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME http) +endif() + +target_link_libraries(sourcemeta_core_http PUBLIC sourcemeta::core::json) +target_link_libraries(sourcemeta_core_http PRIVATE sourcemeta::core::time) diff --git a/vendor/core/src/core/http/accept_includes_all.cc b/vendor/core/src/core/http/accept_includes_all.cc new file mode 100644 index 000000000..da5a37dee --- /dev/null +++ b/vendor/core/src/core/http/accept_includes_all.cc @@ -0,0 +1,50 @@ +#include + +#include "helpers.h" + +#include // assert +#include // std::uint8_t +#include // std::initializer_list +#include // std::string_view + +namespace sourcemeta::core { + +// NOLINTNEXTLINE(bugprone-exception-escape) +auto http_accept_includes_all( + const std::string_view accept_header, + const std::initializer_list media_types) noexcept + -> bool { + if (http_trim_leading_ows(accept_header).empty()) { + return true; + } + for (const auto media_type : media_types) { + assert(!media_type.empty()); + [[maybe_unused]] const auto slash{media_type.find('/')}; + assert(slash != std::string_view::npos); + assert(slash > 0); + assert(slash < media_type.size() - 1); + assert(media_type.find_first_of(" \t,;*") == std::string_view::npos); + float best_quality{0.0f}; + std::uint8_t best_specificity{0}; + http_for_each_accept_entry( + accept_header, + [&](const std::string_view value, const float quality) noexcept { + const std::uint8_t specificity{ + http_media_specificity(value, media_type)}; + if (specificity == 0) { + return; + } + if (specificity > best_specificity || + (specificity == best_specificity && quality > best_quality)) { + best_quality = quality; + best_specificity = specificity; + } + }); + if (best_specificity == 0 || best_quality == 0.0f) { + return false; + } + } + return true; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/http/content_type_matches.cc b/vendor/core/src/core/http/content_type_matches.cc new file mode 100644 index 000000000..aee92a99f --- /dev/null +++ b/vendor/core/src/core/http/content_type_matches.cc @@ -0,0 +1,17 @@ +#include + +#include "helpers.h" + +#include // std::string_view + +namespace sourcemeta::core { + +auto http_content_type_matches(const std::string_view content_type_header, + const std::string_view media_type) noexcept + -> bool { + const auto bare{ + http_trim_leading_ows(http_split_entry(content_type_header).first)}; + return http_iequals_ascii(bare, media_type); +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/http/field_list.cc b/vendor/core/src/core/http/field_list.cc new file mode 100644 index 000000000..265081f7d --- /dev/null +++ b/vendor/core/src/core/http/field_list.cc @@ -0,0 +1,29 @@ +#include + +#include "helpers.h" + +#include // std::initializer_list +#include // std::string_view + +namespace sourcemeta::core { + +// NOLINTNEXTLINE(bugprone-exception-escape) +auto http_field_list_contains_any( + const std::string_view header_value, + std::initializer_list tokens) noexcept -> bool { + bool found{false}; + http_for_each_field_value(header_value, [&](const std::string_view value) { + if (found) { + return; + } + for (const auto token : tokens) { + if (value == token) { + found = true; + return; + } + } + }); + return found; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/http/format_link.cc b/vendor/core/src/core/http/format_link.cc new file mode 100644 index 000000000..6f7e05a74 --- /dev/null +++ b/vendor/core/src/core/http/format_link.cc @@ -0,0 +1,83 @@ +#include + +#include // std::size_t +#include // std::span +#include // std::string +#include // std::string_view + +namespace { + +constexpr std::string_view LINK_TARGET_OPEN{"<"}; +constexpr std::string_view LINK_REL_OPEN{">; rel=\""}; +constexpr std::string_view LINK_QUOTE_CLOSE{"\""}; +constexpr std::string_view LINK_PARAMETER_OPEN{"; "}; +constexpr std::string_view LINK_PARAMETER_EQUALS{"=\""}; +constexpr std::string_view LINK_ENTRY_SEPARATOR{", "}; + +constexpr std::size_t LINK_FIXED_BYTES{ + LINK_TARGET_OPEN.size() + LINK_REL_OPEN.size() + LINK_QUOTE_CLOSE.size()}; + +constexpr std::size_t LINK_PARAMETER_FIXED_BYTES{LINK_PARAMETER_OPEN.size() + + LINK_PARAMETER_EQUALS.size() + + LINK_QUOTE_CLOSE.size()}; + +auto required_size(const sourcemeta::core::HTTPLink &link) noexcept + -> std::size_t { + std::size_t size{LINK_FIXED_BYTES + link.target.size() + link.rel.size()}; + for (const auto &[name, value] : link.parameters) { + size += LINK_PARAMETER_FIXED_BYTES + name.size() + value.size(); + } + return size; +} + +} // namespace + +namespace sourcemeta::core { + +auto http_format_link(const HTTPLink &link, std::string &out) -> void { + out.reserve(out.size() + required_size(link)); + out.append(LINK_TARGET_OPEN); + out.append(link.target); + out.append(LINK_REL_OPEN); + out.append(link.rel); + out.append(LINK_QUOTE_CLOSE); + for (const auto &[name, value] : link.parameters) { + out.append(LINK_PARAMETER_OPEN); + out.append(name); + out.append(LINK_PARAMETER_EQUALS); + out.append(value); + out.append(LINK_QUOTE_CLOSE); + } +} + +auto http_format_link(const HTTPLink &link) -> std::string { + std::string out; + http_format_link(link, out); + return out; +} + +auto http_format_links(std::span links, std::string &out) + -> void { + if (links.empty()) { + return; + } + std::size_t total{0}; + for (const auto &link : links) { + total += required_size(link); + } + total += LINK_ENTRY_SEPARATOR.size() * (links.size() - 1); + out.reserve(out.size() + total); + http_format_link(links.front(), out); + for (auto iterator{links.begin() + 1}; iterator != links.end(); ++iterator) { + out.append(LINK_ENTRY_SEPARATOR); + http_format_link(*iterator, out); + } +} + +auto http_format_links(std::span links) -> std::string { + std::string out; + http_format_links(links, out); + return out; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/http/from_date.cc b/vendor/core/src/core/http/from_date.cc new file mode 100644 index 000000000..c2ff17f10 --- /dev/null +++ b/vendor/core/src/core/http/from_date.cc @@ -0,0 +1,21 @@ +#include +#include + +#include // std::chrono::system_clock +#include // std::optional +#include // std::string_view + +namespace sourcemeta::core { + +auto http_from_date(const std::string_view value) noexcept + -> std::optional { + if (const auto result{from_imf_fixdate(value)}; result.has_value()) { + return result; + } + if (const auto result{from_rfc850_date(value)}; result.has_value()) { + return result; + } + return from_asctime(value); +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/http/helpers.h b/vendor/core/src/core/http/helpers.h new file mode 100644 index 000000000..abfabd40a --- /dev/null +++ b/vendor/core/src/core/http/helpers.h @@ -0,0 +1,243 @@ +#ifndef SOURCEMETA_CORE_HTTP_HELPERS_H_ +#define SOURCEMETA_CORE_HTTP_HELPERS_H_ + +#include // std::size_t +#include // std::uint8_t, std::uint16_t +#include // std::string_view +#include // std::pair + +// Bounds are validated by surrounding logic. +// NOLINTBEGIN(bugprone-suspicious-stringview-data-usage) +namespace sourcemeta::core { + +inline auto http_is_ows(const char character) noexcept -> bool { + return character == ' ' || character == '\t'; +} + +inline auto http_ascii_lower(const char character) noexcept -> char { + return (character >= 'A' && character <= 'Z') + ? static_cast(character + ('a' - 'A')) + : character; +} + +inline auto http_iequals_ascii(const std::string_view left, + const std::string_view right) noexcept -> bool { + if (left.size() != right.size()) { + return false; + } + for (std::size_t index{0}; index < left.size(); ++index) { + if (http_ascii_lower(left[index]) != http_ascii_lower(right[index])) { + return false; + } + } + return true; +} + +inline auto http_subview(const std::string_view value, const std::size_t offset, + const std::size_t length) noexcept + -> std::string_view { + return std::string_view{value.data() + offset, length}; +} + +inline auto http_media_specificity(const std::string_view range, + const std::string_view candidate) noexcept + -> std::uint8_t { + if (http_iequals_ascii(range, candidate)) { + return 3; + } + if (range == "*/*") { + return 1; + } + const auto range_slash{range.find('/')}; + const auto candidate_slash{candidate.find('/')}; + if (range_slash == std::string_view::npos || + candidate_slash == std::string_view::npos) { + return 0; + } + if (range.size() - range_slash != 2 || range[range_slash + 1] != '*') { + return 0; + } + if (range_slash != candidate_slash) { + return 0; + } + for (std::size_t index{0}; index < range_slash; ++index) { + if (http_ascii_lower(range[index]) != http_ascii_lower(candidate[index])) { + return 0; + } + } + return 2; +} + +inline auto http_trim_trailing_ows(const std::string_view value) noexcept + -> std::string_view { + std::size_t size{value.size()}; + while (size > 0 && http_is_ows(value[size - 1])) { + --size; + } + return http_subview(value, 0, size); +} + +inline auto http_trim_leading_ows(const std::string_view value) noexcept + -> std::string_view { + std::size_t position{0}; + while (position < value.size() && http_is_ows(value[position])) { + ++position; + } + return http_subview(value, position, value.size() - position); +} + +template +inline auto http_for_each_list_entry(const std::string_view header, + Visitor visit) -> void { + std::size_t position{0}; + while (position < header.size()) { + while (position < header.size() && http_is_ows(header[position])) { + ++position; + } + std::size_t end_position{position}; + bool in_quotes{false}; + while (end_position < header.size()) { + const char current{header[end_position]}; + if (in_quotes) { + if (current == '\\' && end_position + 1 < header.size()) { + ++end_position; + } else if (current == '"') { + in_quotes = false; + } + } else if (current == '"') { + in_quotes = true; + } else if (current == ',') { + break; + } + ++end_position; + } + std::size_t entry_end{end_position}; + while (entry_end > position && http_is_ows(header[entry_end - 1])) { + --entry_end; + } + if (position < entry_end) { + visit(http_subview(header, position, entry_end - position)); + } + position = (end_position < header.size()) ? end_position + 1 : end_position; + } +} + +inline auto http_split_entry(const std::string_view entry) noexcept + -> std::pair { + std::size_t semicolon{0}; + while (semicolon < entry.size() && entry[semicolon] != ';') { + ++semicolon; + } + return {http_trim_trailing_ows(http_subview(entry, 0, semicolon)), + http_subview(entry, semicolon, entry.size() - semicolon)}; +} + +template +inline auto http_for_each_parameter(const std::string_view parameters, + Visitor visit) -> void { + std::size_t position{0}; + while (position < parameters.size()) { + if (parameters[position] == ';') { + ++position; + } + while (position < parameters.size() && http_is_ows(parameters[position])) { + ++position; + } + std::size_t end_position{position}; + while (end_position < parameters.size() && + parameters[end_position] != ';') { + ++end_position; + } + const auto raw{http_subview(parameters, position, end_position - position)}; + position = end_position; + if (raw.empty()) { + continue; + } + std::size_t equals{0}; + while (equals < raw.size() && raw[equals] != '=') { + ++equals; + } + if (equals == raw.size()) { + visit(http_trim_trailing_ows(raw), std::string_view{}); + } else { + visit(http_trim_trailing_ows(http_subview(raw, 0, equals)), + http_trim_trailing_ows( + http_subview(raw, equals + 1, raw.size() - equals - 1))); + } + } +} + +// RFC 9110 §5.6.5 q-value. Defaults to 1.0 on malformed input. +inline auto http_parse_qvalue(const std::string_view value) noexcept -> float { + if (value.empty()) { + return 1.0f; + } + if (value[0] != '0' && value[0] != '1') { + return 1.0f; + } + const float integer_part{static_cast(value[0] - '0')}; + if (value.size() == 1) { + return integer_part; + } + if (value[1] != '.' || value.size() > 5) { + return 1.0f; + } + std::uint16_t numerator{0}; + std::uint16_t denominator{1}; + for (std::size_t index{2}; index < value.size(); ++index) { + const char character{value[index]}; + if (character < '0' || character > '9') { + return 1.0f; + } + numerator = static_cast(numerator * 10 + (character - '0')); + denominator = static_cast(denominator * 10); + } + const float fraction{static_cast(numerator) / + static_cast(denominator)}; + const float result{integer_part + fraction}; + if (result > 1.0f) { + return 1.0f; + } + return result; +} + +inline auto http_extract_quality(const std::string_view parameters) noexcept + -> float { + float quality{1.0f}; + http_for_each_parameter( + parameters, [&quality](const std::string_view name, + const std::string_view value) noexcept { + if (name.size() == 1 && (name[0] == 'q' || name[0] == 'Q')) { + quality = http_parse_qvalue(value); + } + }); + return quality; +} + +template +inline auto http_for_each_accept_entry(const std::string_view header, + Visitor visit) -> void { + http_for_each_list_entry(header, [&visit](const std::string_view entry) { + const auto [value, parameters] = http_split_entry(entry); + if (!value.empty()) { + visit(value, http_extract_quality(parameters)); + } + }); +} + +template +inline auto http_for_each_field_value(const std::string_view header, + Visitor visit) -> void { + http_for_each_list_entry(header, [&visit](const std::string_view entry) { + const auto [value, parameters] = http_split_entry(entry); + (void)parameters; + if (!value.empty()) { + visit(value); + } + }); +} + +} // namespace sourcemeta::core +// NOLINTEND(bugprone-suspicious-stringview-data-usage) + +#endif diff --git a/vendor/core/src/core/http/include/sourcemeta/core/http.h b/vendor/core/src/core/http/include/sourcemeta/core/http.h new file mode 100644 index 000000000..deb428740 --- /dev/null +++ b/vendor/core/src/core/http/include/sourcemeta/core/http.h @@ -0,0 +1,252 @@ +#ifndef SOURCEMETA_CORE_HTTP_H_ +#define SOURCEMETA_CORE_HTTP_H_ + +#ifndef SOURCEMETA_CORE_HTTP_EXPORT +#include +#endif + +// NOLINTBEGIN(misc-include-cleaner) +#include +#include +// NOLINTEND(misc-include-cleaner) + +#include // std::chrono::system_clock +#include // std::uint8_t +#include // std::initializer_list +#include // std::optional +#include // std::span +#include // std::string +#include // std::string_view +#include // std::pair + +/// @defgroup http HTTP +/// @brief An implementation of HTTP-protocol parsing, formatting, and +/// validation primitives per RFC 9110. +/// +/// This functionality is included as follows: +/// +/// ```cpp +/// #include +/// ``` + +namespace sourcemeta::core { + +/// @ingroup http +/// A content coding supported by this implementation. +enum class HTTPContentEncoding : std::uint8_t { + Identity, + GZIP, +}; + +/// @ingroup http +/// Pick the best media-type candidate against an `Accept` header per RFC 9110 +/// §12.5.1. Returns an empty value when no candidate is acceptable. The +/// returned view borrows from `candidates`. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// const auto best{sourcemeta::core::http_match_accept( +/// "text/html, application/json;q=0.9", +/// {"text/html", "application/json"})}; +/// assert(best == "text/html"); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_match_accept(const std::string_view accept_header, + std::initializer_list candidates) + -> std::string_view; + +/// @ingroup http +/// Test whether every media type is individually acceptable under an `Accept` +/// header per RFC 9110 §12.5.1. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// assert(sourcemeta::core::http_accept_includes_all( +/// "text/html, application/json", +/// {"text/html", "application/json"})); +/// assert(!sourcemeta::core::http_accept_includes_all( +/// "text/html;q=0, application/json", {"text/html"})); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_accept_includes_all( + const std::string_view accept_header, + std::initializer_list media_types) noexcept -> bool; + +/// @ingroup http +/// Test whether a `Content-Type` header denotes the given media type per RFC +/// 9110 §8.3.1. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// assert(sourcemeta::core::http_content_type_matches( +/// "application/json; charset=UTF-8", "application/json")); +/// assert(!sourcemeta::core::http_content_type_matches( +/// "application/xml", "application/json")); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_content_type_matches(const std::string_view content_type_header, + const std::string_view media_type) noexcept + -> bool; + +/// @ingroup http +/// Pick the best language-tag candidate against an `Accept-Language` header +/// per RFC 9110 §12.5.4 using the RFC 4647 §3.4 Lookup scheme. Returns an +/// empty value when no candidate is acceptable. The returned view borrows from +/// `candidates`. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// const auto best{sourcemeta::core::http_match_accept_language( +/// "fr-CA;q=0.9, en;q=0.8", {"en", "fr"})}; +/// assert(best == "fr"); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_match_accept_language( + const std::string_view accept_language_header, + std::initializer_list candidates) -> std::string_view; + +/// @ingroup http +/// Resolve a content coding against an `Accept-Encoding` header per RFC 9110 +/// §12.5.3. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// const auto chosen{sourcemeta::core::http_negotiate_encoding( +/// "gzip, identity;q=0.5", sourcemeta::core::HTTPContentEncoding::GZIP)}; +/// assert(chosen.has_value()); +/// assert(chosen.value() == sourcemeta::core::HTTPContentEncoding::GZIP); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_negotiate_encoding( + const std::string_view accept_encoding_header, + const HTTPContentEncoding server_preference) noexcept + -> std::optional; + +/// @ingroup http +/// Parse an HTTP-date string per RFC 9110 §5.6.7. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// assert(sourcemeta::core::http_from_date( +/// "Sun, 06 Nov 1994 08:49:37 GMT").has_value()); +/// assert(sourcemeta::core::http_from_date( +/// "Sunday, 06-Nov-94 08:49:37 GMT").has_value()); +/// assert(sourcemeta::core::http_from_date( +/// "Sun Nov 6 08:49:37 1994").has_value()); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_from_date(const std::string_view value) noexcept + -> std::optional; + +/// @ingroup http +/// A typed RFC 8288 §3 link-value. The caller owns the backing storage for +/// every field, must URI-escape `target`, and must ensure parameter values are +/// valid `quoted-string` content. +struct HTTPLink { + std::string_view target; + std::string_view rel; + std::span> parameters{}; +}; + +/// @ingroup http +/// Append an RFC 8288 §3 link-value to `out`. For example: +/// +/// ```cpp +/// #include +/// #include +/// #include +/// +/// std::string buffer{"prefix:"}; +/// sourcemeta::core::http_format_link( +/// {.target = "/schema.json", .rel = "describedby"}, buffer); +/// assert(buffer == "prefix:; rel=\"describedby\""); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_format_link(const HTTPLink &link, std::string &out) -> void; + +/// @ingroup http +/// Format an RFC 8288 §3 link-value. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// const auto value{sourcemeta::core::http_format_link( +/// {.target = "https://example.com/schema.json", .rel = "describedby"})}; +/// assert(value == +/// "; rel=\"describedby\""); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_format_link(const HTTPLink &link) -> std::string; + +/// @ingroup http +/// Append an RFC 8288 §3.5 comma-separated multi-link value to `out`. For +/// example: +/// +/// ```cpp +/// #include +/// #include +/// #include +/// +/// const sourcemeta::core::HTTPLink links[]{ +/// {.target = "/here", .rel = "self"}, +/// {.target = "/next", .rel = "next"}}; +/// std::string buffer; +/// sourcemeta::core::http_format_links(links, buffer); +/// assert(buffer == +/// "; rel=\"self\", ; rel=\"next\""); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_format_links(std::span links, std::string &out) + -> void; + +/// @ingroup http +/// Format an RFC 8288 §3.5 comma-separated multi-link value. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// const sourcemeta::core::HTTPLink links[]{ +/// {.target = "/here", .rel = "self"}, +/// {.target = "/next", .rel = "next"}}; +/// const auto value{sourcemeta::core::http_format_links(links)}; +/// assert(value == +/// "; rel=\"self\", ; rel=\"next\""); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_format_links(std::span links) -> std::string; + +/// @ingroup http +/// Test whether a comma-separated header value per RFC 9110 §5.6.1 lists any +/// of the given tokens. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// assert(sourcemeta::core::http_field_list_contains_any( +/// "\"abc\", W/\"def\", *", {"*"})); +/// assert(!sourcemeta::core::http_field_list_contains_any( +/// "\"abc\", \"def\"", {"\"xyz\""})); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_field_list_contains_any( + const std::string_view header_value, + std::initializer_list tokens) noexcept -> bool; + +} // namespace sourcemeta::core + +#endif diff --git a/vendor/core/src/core/http/include/sourcemeta/core/http_problem.h b/vendor/core/src/core/http/include/sourcemeta/core/http_problem.h new file mode 100644 index 000000000..a89b3ed74 --- /dev/null +++ b/vendor/core/src/core/http/include/sourcemeta/core/http_problem.h @@ -0,0 +1,44 @@ +#ifndef SOURCEMETA_CORE_HTTP_PROBLEM_H_ +#define SOURCEMETA_CORE_HTTP_PROBLEM_H_ + +#ifndef SOURCEMETA_CORE_HTTP_EXPORT +#include +#endif + +#include +#include + +namespace sourcemeta::core { + +/// @ingroup http +/// Fields of an RFC 9457 §3.1 Problem Details object. +struct HTTPProblemDetails { + HTTPStatus status; + JSON::StringView type{"about:blank"}; + JSON::StringView title{}; + JSON::StringView detail{}; + JSON::StringView instance{}; +}; + +/// @ingroup http +/// Build an RFC 9457 §3.1 Problem Details JSON object. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// const auto body{sourcemeta::core::http_make_problem_details({ +/// .status = sourcemeta::core::HTTP_STATUS_NOT_FOUND, +/// .type = "https://example.com/probs/not-found", +/// .detail = "The requested resource does not exist."})}; +/// +/// assert(body.at("status").to_integer() == 404); +/// assert(body.at("title").to_string() == "Not Found"); +/// ``` +SOURCEMETA_CORE_HTTP_EXPORT +auto http_make_problem_details(const HTTPProblemDetails &problem) + -> sourcemeta::core::JSON; + +} // namespace sourcemeta::core + +#endif diff --git a/vendor/core/src/core/http/include/sourcemeta/core/http_status.h b/vendor/core/src/core/http/include/sourcemeta/core/http_status.h new file mode 100644 index 000000000..3a82995c4 --- /dev/null +++ b/vendor/core/src/core/http/include/sourcemeta/core/http_status.h @@ -0,0 +1,391 @@ +#ifndef SOURCEMETA_CORE_HTTP_STATUS_H_ +#define SOURCEMETA_CORE_HTTP_STATUS_H_ + +#include // std::uint16_t +#include // std::string_view + +namespace sourcemeta::core { + +/// @ingroup http +/// A typed HTTP status code per RFC 9110 §15. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// assert(sourcemeta::core::HTTP_STATUS_OK.code == 200); +/// assert(sourcemeta::core::HTTP_STATUS_OK.phrase == "OK"); +/// assert(sourcemeta::core::HTTP_STATUS_OK.wire == "200 OK"); +/// ``` +struct HTTPStatus { + std::uint16_t code; + std::string_view phrase; + std::string_view wire; + + constexpr auto operator==(const HTTPStatus &) const -> bool = default; +}; + +/// @ingroup http +/// RFC 9110 §15.2.1 (Informational). +inline constexpr HTTPStatus HTTP_STATUS_CONTINUE{ + .code = 100, .phrase = "Continue", .wire = "100 Continue"}; + +/// @ingroup http +/// RFC 9110 §15.2.2 (Informational). +inline constexpr HTTPStatus HTTP_STATUS_SWITCHING_PROTOCOLS{ + .code = 101, + .phrase = "Switching Protocols", + .wire = "101 Switching Protocols"}; + +/// @ingroup http +/// RFC 2518 §10.1 (WebDAV). +inline constexpr HTTPStatus HTTP_STATUS_PROCESSING{ + .code = 102, .phrase = "Processing", .wire = "102 Processing"}; + +/// @ingroup http +/// RFC 8297 §2. +inline constexpr HTTPStatus HTTP_STATUS_EARLY_HINTS{ + .code = 103, .phrase = "Early Hints", .wire = "103 Early Hints"}; + +/// @ingroup http +/// RFC 9110 §15.3.1 (Successful). +inline constexpr HTTPStatus HTTP_STATUS_OK{ + .code = 200, .phrase = "OK", .wire = "200 OK"}; + +/// @ingroup http +/// RFC 9110 §15.3.2 (Successful). +inline constexpr HTTPStatus HTTP_STATUS_CREATED{ + .code = 201, .phrase = "Created", .wire = "201 Created"}; + +/// @ingroup http +/// RFC 9110 §15.3.3 (Successful). +inline constexpr HTTPStatus HTTP_STATUS_ACCEPTED{ + .code = 202, .phrase = "Accepted", .wire = "202 Accepted"}; + +/// @ingroup http +/// RFC 9110 §15.3.4 (Successful). +inline constexpr HTTPStatus HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION{ + .code = 203, + .phrase = "Non-Authoritative Information", + .wire = "203 Non-Authoritative Information"}; + +/// @ingroup http +/// RFC 9110 §15.3.5 (Successful). +inline constexpr HTTPStatus HTTP_STATUS_NO_CONTENT{ + .code = 204, .phrase = "No Content", .wire = "204 No Content"}; + +/// @ingroup http +/// RFC 9110 §15.3.6 (Successful). +inline constexpr HTTPStatus HTTP_STATUS_RESET_CONTENT{ + .code = 205, .phrase = "Reset Content", .wire = "205 Reset Content"}; + +/// @ingroup http +/// RFC 9110 §15.3.7 (Successful). +inline constexpr HTTPStatus HTTP_STATUS_PARTIAL_CONTENT{ + .code = 206, .phrase = "Partial Content", .wire = "206 Partial Content"}; + +/// @ingroup http +/// RFC 4918 §11.1 (WebDAV). +inline constexpr HTTPStatus HTTP_STATUS_MULTI_STATUS{ + .code = 207, .phrase = "Multi-Status", .wire = "207 Multi-Status"}; + +/// @ingroup http +/// RFC 5842 §7.1 (WebDAV). +inline constexpr HTTPStatus HTTP_STATUS_ALREADY_REPORTED{ + .code = 208, .phrase = "Already Reported", .wire = "208 Already Reported"}; + +/// @ingroup http +/// RFC 3229 §10.4.1 (HTTP Delta Encoding). +inline constexpr HTTPStatus HTTP_STATUS_IM_USED{ + .code = 226, .phrase = "IM Used", .wire = "226 IM Used"}; + +/// @ingroup http +/// RFC 9110 §15.4.1 (Redirection). +inline constexpr HTTPStatus HTTP_STATUS_MULTIPLE_CHOICES{ + .code = 300, .phrase = "Multiple Choices", .wire = "300 Multiple Choices"}; + +/// @ingroup http +/// RFC 9110 §15.4.2 (Redirection). +inline constexpr HTTPStatus HTTP_STATUS_MOVED_PERMANENTLY{ + .code = 301, + .phrase = "Moved Permanently", + .wire = "301 Moved Permanently"}; + +/// @ingroup http +/// RFC 9110 §15.4.3 (Redirection). +inline constexpr HTTPStatus HTTP_STATUS_FOUND{ + .code = 302, .phrase = "Found", .wire = "302 Found"}; + +/// @ingroup http +/// RFC 9110 §15.4.4 (Redirection). +inline constexpr HTTPStatus HTTP_STATUS_SEE_OTHER{ + .code = 303, .phrase = "See Other", .wire = "303 See Other"}; + +/// @ingroup http +/// RFC 9110 §15.4.5 (Redirection). +inline constexpr HTTPStatus HTTP_STATUS_NOT_MODIFIED{ + .code = 304, .phrase = "Not Modified", .wire = "304 Not Modified"}; + +/// @ingroup http +/// RFC 9110 §15.4.6 (Redirection). +inline constexpr HTTPStatus HTTP_STATUS_USE_PROXY{ + .code = 305, .phrase = "Use Proxy", .wire = "305 Use Proxy"}; + +/// @ingroup http +/// RFC 9110 §15.4.8 (Redirection). +inline constexpr HTTPStatus HTTP_STATUS_TEMPORARY_REDIRECT{ + .code = 307, + .phrase = "Temporary Redirect", + .wire = "307 Temporary Redirect"}; + +/// @ingroup http +/// RFC 9110 §15.4.9 (Redirection). +inline constexpr HTTPStatus HTTP_STATUS_PERMANENT_REDIRECT{ + .code = 308, + .phrase = "Permanent Redirect", + .wire = "308 Permanent Redirect"}; + +/// @ingroup http +/// RFC 9110 §15.5.1 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_BAD_REQUEST{ + .code = 400, .phrase = "Bad Request", .wire = "400 Bad Request"}; + +/// @ingroup http +/// RFC 9110 §15.5.2 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_UNAUTHORIZED{ + .code = 401, .phrase = "Unauthorized", .wire = "401 Unauthorized"}; + +/// @ingroup http +/// RFC 9110 §15.5.3 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_PAYMENT_REQUIRED{ + .code = 402, .phrase = "Payment Required", .wire = "402 Payment Required"}; + +/// @ingroup http +/// RFC 9110 §15.5.4 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_FORBIDDEN{ + .code = 403, .phrase = "Forbidden", .wire = "403 Forbidden"}; + +/// @ingroup http +/// RFC 9110 §15.5.5 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_NOT_FOUND{ + .code = 404, .phrase = "Not Found", .wire = "404 Not Found"}; + +/// @ingroup http +/// RFC 9110 §15.5.6 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_METHOD_NOT_ALLOWED{ + .code = 405, + .phrase = "Method Not Allowed", + .wire = "405 Method Not Allowed"}; + +/// @ingroup http +/// RFC 9110 §15.5.7 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_NOT_ACCEPTABLE{ + .code = 406, .phrase = "Not Acceptable", .wire = "406 Not Acceptable"}; + +/// @ingroup http +/// RFC 9110 §15.5.8 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED{ + .code = 407, + .phrase = "Proxy Authentication Required", + .wire = "407 Proxy Authentication Required"}; + +/// @ingroup http +/// RFC 9110 §15.5.9 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_REQUEST_TIMEOUT{ + .code = 408, .phrase = "Request Timeout", .wire = "408 Request Timeout"}; + +/// @ingroup http +/// RFC 9110 §15.5.10 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_CONFLICT{ + .code = 409, .phrase = "Conflict", .wire = "409 Conflict"}; + +/// @ingroup http +/// RFC 9110 §15.5.11 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_GONE{ + .code = 410, .phrase = "Gone", .wire = "410 Gone"}; + +/// @ingroup http +/// RFC 9110 §15.5.12 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_LENGTH_REQUIRED{ + .code = 411, .phrase = "Length Required", .wire = "411 Length Required"}; + +/// @ingroup http +/// RFC 9110 §15.5.13 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_PRECONDITION_FAILED{ + .code = 412, + .phrase = "Precondition Failed", + .wire = "412 Precondition Failed"}; + +/// @ingroup http +/// RFC 9110 §15.5.14 (Client Error). RFC 9110 renamed this from "Payload +/// Too Large" (RFC 7231) to "Content Too Large". +inline constexpr HTTPStatus HTTP_STATUS_CONTENT_TOO_LARGE{ + .code = 413, + .phrase = "Content Too Large", + .wire = "413 Content Too Large"}; + +/// @ingroup http +/// RFC 9110 §15.5.15 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_URI_TOO_LONG{ + .code = 414, .phrase = "URI Too Long", .wire = "414 URI Too Long"}; + +/// @ingroup http +/// RFC 9110 §15.5.16 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE{ + .code = 415, + .phrase = "Unsupported Media Type", + .wire = "415 Unsupported Media Type"}; + +/// @ingroup http +/// RFC 9110 §15.5.17 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_RANGE_NOT_SATISFIABLE{ + .code = 416, + .phrase = "Range Not Satisfiable", + .wire = "416 Range Not Satisfiable"}; + +/// @ingroup http +/// RFC 9110 §15.5.18 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_EXPECTATION_FAILED{ + .code = 417, + .phrase = "Expectation Failed", + .wire = "417 Expectation Failed"}; + +/// @ingroup http +/// RFC 2324 §2.3.2 (HTCPCP). +inline constexpr HTTPStatus HTTP_STATUS_IM_A_TEAPOT{ + .code = 418, .phrase = "I'm a Teapot", .wire = "418 I'm a Teapot"}; + +/// @ingroup http +/// RFC 9110 §15.5.20 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_MISDIRECTED_REQUEST{ + .code = 421, + .phrase = "Misdirected Request", + .wire = "421 Misdirected Request"}; + +/// @ingroup http +/// RFC 9110 §15.5.21 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_UNPROCESSABLE_CONTENT{ + .code = 422, + .phrase = "Unprocessable Content", + .wire = "422 Unprocessable Content"}; + +/// @ingroup http +/// RFC 4918 §11.3 (WebDAV). +inline constexpr HTTPStatus HTTP_STATUS_LOCKED{ + .code = 423, .phrase = "Locked", .wire = "423 Locked"}; + +/// @ingroup http +/// RFC 4918 §11.4 (WebDAV). +inline constexpr HTTPStatus HTTP_STATUS_FAILED_DEPENDENCY{ + .code = 424, + .phrase = "Failed Dependency", + .wire = "424 Failed Dependency"}; + +/// @ingroup http +/// RFC 8470 §5.2. +inline constexpr HTTPStatus HTTP_STATUS_TOO_EARLY{ + .code = 425, .phrase = "Too Early", .wire = "425 Too Early"}; + +/// @ingroup http +/// RFC 9110 §15.5.22 (Client Error). +inline constexpr HTTPStatus HTTP_STATUS_UPGRADE_REQUIRED{ + .code = 426, .phrase = "Upgrade Required", .wire = "426 Upgrade Required"}; + +/// @ingroup http +/// RFC 6585 §3. +inline constexpr HTTPStatus HTTP_STATUS_PRECONDITION_REQUIRED{ + .code = 428, + .phrase = "Precondition Required", + .wire = "428 Precondition Required"}; + +/// @ingroup http +/// RFC 6585 §4. +inline constexpr HTTPStatus HTTP_STATUS_TOO_MANY_REQUESTS{ + .code = 429, + .phrase = "Too Many Requests", + .wire = "429 Too Many Requests"}; + +/// @ingroup http +/// RFC 6585 §5. +inline constexpr HTTPStatus HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE{ + .code = 431, + .phrase = "Request Header Fields Too Large", + .wire = "431 Request Header Fields Too Large"}; + +/// @ingroup http +/// RFC 7725 §3. +inline constexpr HTTPStatus HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS{ + .code = 451, + .phrase = "Unavailable For Legal Reasons", + .wire = "451 Unavailable For Legal Reasons"}; + +/// @ingroup http +/// RFC 9110 §15.6.1 (Server Error). +inline constexpr HTTPStatus HTTP_STATUS_INTERNAL_SERVER_ERROR{ + .code = 500, + .phrase = "Internal Server Error", + .wire = "500 Internal Server Error"}; + +/// @ingroup http +/// RFC 9110 §15.6.2 (Server Error). +inline constexpr HTTPStatus HTTP_STATUS_NOT_IMPLEMENTED{ + .code = 501, .phrase = "Not Implemented", .wire = "501 Not Implemented"}; + +/// @ingroup http +/// RFC 9110 §15.6.3 (Server Error). +inline constexpr HTTPStatus HTTP_STATUS_BAD_GATEWAY{ + .code = 502, .phrase = "Bad Gateway", .wire = "502 Bad Gateway"}; + +/// @ingroup http +/// RFC 9110 §15.6.4 (Server Error). +inline constexpr HTTPStatus HTTP_STATUS_SERVICE_UNAVAILABLE{ + .code = 503, + .phrase = "Service Unavailable", + .wire = "503 Service Unavailable"}; + +/// @ingroup http +/// RFC 9110 §15.6.5 (Server Error). +inline constexpr HTTPStatus HTTP_STATUS_GATEWAY_TIMEOUT{ + .code = 504, .phrase = "Gateway Timeout", .wire = "504 Gateway Timeout"}; + +/// @ingroup http +/// RFC 9110 §15.6.6 (Server Error). +inline constexpr HTTPStatus HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED{ + .code = 505, + .phrase = "HTTP Version Not Supported", + .wire = "505 HTTP Version Not Supported"}; + +/// @ingroup http +/// RFC 2295 §8.1 (Transparent Content Negotiation). +inline constexpr HTTPStatus HTTP_STATUS_VARIANT_ALSO_NEGOTIATES{ + .code = 506, + .phrase = "Variant Also Negotiates", + .wire = "506 Variant Also Negotiates"}; + +/// @ingroup http +/// RFC 4918 §11.5 (WebDAV). +inline constexpr HTTPStatus HTTP_STATUS_INSUFFICIENT_STORAGE{ + .code = 507, + .phrase = "Insufficient Storage", + .wire = "507 Insufficient Storage"}; + +/// @ingroup http +/// RFC 5842 §7.2 (WebDAV). +inline constexpr HTTPStatus HTTP_STATUS_LOOP_DETECTED{ + .code = 508, .phrase = "Loop Detected", .wire = "508 Loop Detected"}; + +/// @ingroup http +/// RFC 2774 §7. +inline constexpr HTTPStatus HTTP_STATUS_NOT_EXTENDED{ + .code = 510, .phrase = "Not Extended", .wire = "510 Not Extended"}; + +/// @ingroup http +/// RFC 6585 §6. +inline constexpr HTTPStatus HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED{ + .code = 511, + .phrase = "Network Authentication Required", + .wire = "511 Network Authentication Required"}; + +} // namespace sourcemeta::core + +#endif diff --git a/vendor/core/src/core/http/match_accept.cc b/vendor/core/src/core/http/match_accept.cc new file mode 100644 index 000000000..bebedcbe4 --- /dev/null +++ b/vendor/core/src/core/http/match_accept.cc @@ -0,0 +1,66 @@ +#include + +#include "helpers.h" + +#include // assert +#include // std::uint8_t +#include // std::initializer_list +#include // std::string_view + +namespace sourcemeta::core { + +auto http_match_accept(const std::string_view accept_header, + const std::initializer_list candidates) + -> std::string_view { + if (candidates.size() == 0) { + return {}; + } + if (http_trim_leading_ows(accept_header).empty()) { + return *candidates.begin(); + } + + std::string_view best{}; + float best_quality{0.0f}; + std::uint8_t best_specificity{0}; + std::size_t best_order{candidates.size()}; + + std::size_t order{0}; + for (const auto candidate : candidates) { + assert(!candidate.empty()); + [[maybe_unused]] const auto candidate_slash{candidate.find('/')}; + assert(candidate_slash != std::string_view::npos); + assert(candidate_slash > 0); + assert(candidate_slash < candidate.size() - 1); + assert(candidate.find_first_of(" \t,;*") == std::string_view::npos); + float candidate_quality{0.0f}; + std::uint8_t candidate_specificity{0}; + http_for_each_accept_entry(accept_header, [&](const std::string_view value, + const float quality) { + const std::uint8_t specificity{http_media_specificity(value, candidate)}; + if (specificity == 0) { + return; + } + if (specificity > candidate_specificity || + (specificity == candidate_specificity && + quality > candidate_quality)) { + candidate_quality = quality; + candidate_specificity = specificity; + } + }); + if (candidate_quality > 0.0f && + (candidate_quality > best_quality || + (candidate_quality == best_quality && + candidate_specificity > best_specificity) || + (candidate_quality == best_quality && + candidate_specificity == best_specificity && order < best_order))) { + best = candidate; + best_quality = candidate_quality; + best_specificity = candidate_specificity; + best_order = order; + } + ++order; + } + return best; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/http/match_accept_language.cc b/vendor/core/src/core/http/match_accept_language.cc new file mode 100644 index 000000000..548624621 --- /dev/null +++ b/vendor/core/src/core/http/match_accept_language.cc @@ -0,0 +1,88 @@ +#include + +#include "helpers.h" + +#include // assert +#include // std::size_t +#include // std::initializer_list +#include // std::string_view + +namespace { + +auto language_specificity(const std::string_view range, + const std::string_view candidate) noexcept + -> std::size_t { + if (range == "*") { + return 1; + } + if (sourcemeta::core::http_iequals_ascii(range, candidate)) { + return candidate.size() + 1; + } + if (range.size() > candidate.size() && range[candidate.size()] == '-' && + sourcemeta::core::http_iequals_ascii( + sourcemeta::core::http_subview(range, 0, candidate.size()), + candidate)) { + return candidate.size(); + } + return 0; +} + +} // namespace + +namespace sourcemeta::core { + +auto http_match_accept_language( + const std::string_view accept_language_header, + const std::initializer_list candidates) + -> std::string_view { + if (candidates.size() == 0) { + return {}; + } + if (http_trim_leading_ows(accept_language_header).empty()) { + return *candidates.begin(); + } + + std::string_view best{}; + float best_quality{0.0f}; + std::size_t best_specificity{0}; + std::size_t best_order{candidates.size()}; + + std::size_t order{0}; + for (const auto candidate : candidates) { + assert(!candidate.empty()); + assert(candidate.find_first_of(" \t,;*/") == std::string_view::npos); + assert(candidate[0] != '-'); + assert(candidate[candidate.size() - 1] != '-'); + float candidate_quality{0.0f}; + std::size_t candidate_specificity{0}; + http_for_each_accept_entry( + accept_language_header, + [&](const std::string_view value, const float quality) { + const std::size_t specificity{language_specificity(value, candidate)}; + if (specificity == 0) { + return; + } + if (quality > candidate_quality || + (quality == candidate_quality && + specificity > candidate_specificity)) { + candidate_quality = quality; + candidate_specificity = specificity; + } + }); + if (candidate_quality > 0.0f && + (candidate_quality > best_quality || + (candidate_quality == best_quality && + candidate_specificity > best_specificity) || + (candidate_quality == best_quality && + candidate_specificity == best_specificity && order < best_order))) { + best = candidate; + best_quality = candidate_quality; + best_specificity = candidate_specificity; + best_order = order; + } + ++order; + } + return best; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/http/negotiate_encoding.cc b/vendor/core/src/core/http/negotiate_encoding.cc new file mode 100644 index 000000000..12420d5d4 --- /dev/null +++ b/vendor/core/src/core/http/negotiate_encoding.cc @@ -0,0 +1,80 @@ +#include + +#include "helpers.h" + +#include // std::optional, std::nullopt +#include // std::string_view + +namespace sourcemeta::core { + +// NOLINTNEXTLINE(bugprone-exception-escape) +auto http_negotiate_encoding( + const std::string_view accept_encoding_header, + const HTTPContentEncoding server_preference) noexcept + -> std::optional { + if (http_trim_leading_ows(accept_encoding_header).empty()) { + return HTTPContentEncoding::Identity; + } + + float gzip_quality{0.0f}; + float identity_quality{0.0f}; + float wildcard_quality{0.0f}; + bool gzip_listed{false}; + bool identity_listed{false}; + bool wildcard_listed{false}; + + http_for_each_accept_entry( + accept_encoding_header, + [&](const std::string_view token, const float quality) { + if (http_iequals_ascii(token, "gzip") || + http_iequals_ascii(token, "x-gzip")) { + gzip_listed = true; + if (quality > gzip_quality) { + gzip_quality = quality; + } + } else if (http_iequals_ascii(token, "identity")) { + identity_listed = true; + if (quality > identity_quality) { + identity_quality = quality; + } + } else if (token == "*") { + wildcard_listed = true; + if (quality > wildcard_quality) { + wildcard_quality = quality; + } + } + }); + + if (!gzip_listed && wildcard_listed) { + gzip_quality = wildcard_quality; + } + if (!identity_listed) { + if (wildcard_listed) { + identity_quality = wildcard_quality; + } else { + identity_quality = 1.0f; + } + } + + const bool gzip_acceptable{gzip_quality > 0.0f}; + const bool identity_acceptable{identity_quality > 0.0f}; + + if (!gzip_acceptable && !identity_acceptable) { + return std::nullopt; + } + if (!gzip_acceptable) { + return HTTPContentEncoding::Identity; + } + if (!identity_acceptable) { + return HTTPContentEncoding::GZIP; + } + if (gzip_quality > identity_quality) { + return HTTPContentEncoding::GZIP; + } + if (identity_quality > gzip_quality) { + return HTTPContentEncoding::Identity; + } + return server_preference; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/http/problem.cc b/vendor/core/src/core/http/problem.cc new file mode 100644 index 000000000..589403757 --- /dev/null +++ b/vendor/core/src/core/http/problem.cc @@ -0,0 +1,53 @@ +#include + +#include // assert +#include // std::int64_t + +namespace { + +const auto HTTP_HASH_TYPE{sourcemeta::core::JSON::Object::hash("type")}; +const auto HTTP_HASH_TITLE{sourcemeta::core::JSON::Object::hash("title")}; +const auto HTTP_HASH_STATUS{sourcemeta::core::JSON::Object::hash("status")}; +const auto HTTP_HASH_DETAIL{sourcemeta::core::JSON::Object::hash("detail")}; +const auto HTTP_HASH_INSTANCE{sourcemeta::core::JSON::Object::hash("instance")}; + +} // namespace + +namespace sourcemeta::core { + +auto http_make_problem_details(const HTTPProblemDetails &problem) + -> sourcemeta::core::JSON { + assert(problem.status.code >= 100 && problem.status.code <= 599); + assert(!problem.status.phrase.empty()); + assert(problem.type.find_first_of("\r\n") == JSON::StringView::npos); + assert(problem.title.find_first_of("\r\n") == JSON::StringView::npos); + assert(problem.instance.find_first_of("\r\n") == JSON::StringView::npos); + + auto object{sourcemeta::core::JSON::make_object()}; + object.assign_assume_new("type", + sourcemeta::core::JSON{problem.type.empty() + ? "about:blank" + : problem.type}, + HTTP_HASH_TYPE); + object.assign_assume_new("title", + sourcemeta::core::JSON{problem.title.empty() + ? problem.status.phrase + : problem.title}, + HTTP_HASH_TITLE); + object.assign_assume_new( + "status", + sourcemeta::core::JSON{static_cast(problem.status.code)}, + HTTP_HASH_STATUS); + if (!problem.detail.empty()) { + object.assign_assume_new("detail", sourcemeta::core::JSON{problem.detail}, + HTTP_HASH_DETAIL); + } + if (!problem.instance.empty()) { + object.assign_assume_new("instance", + sourcemeta::core::JSON{problem.instance}, + HTTP_HASH_INSTANCE); + } + return object; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/idna/codegen.cc b/vendor/core/src/core/idna/codegen.cc index 9c57203df..88bfba34b 100644 --- a/vendor/core/src/core/idna/codegen.cc +++ b/vendor/core/src/core/idna/codegen.cc @@ -23,9 +23,9 @@ namespace { constexpr std::size_t TOTAL_CODEPOINTS{0x110000}; -constexpr std::size_t PAGE_SHIFT{10}; -constexpr std::size_t PAGE_SIZE{1 << PAGE_SHIFT}; -constexpr std::size_t NUM_PAGES{TOTAL_CODEPOINTS / PAGE_SIZE}; +constexpr std::size_t TABLE_PAGE_SHIFT{10}; +constexpr std::size_t TABLE_PAGE_SIZE{1 << TABLE_PAGE_SHIFT}; +constexpr std::size_t NUM_PAGES{TOTAL_CODEPOINTS / TABLE_PAGE_SIZE}; struct PropertyEntry { std::uint32_t first; @@ -123,21 +123,23 @@ auto build_pages(const std::vector &entries) -> TwoStageTable { TwoStageTable table; table.stage1.reserve(NUM_PAGES); for (std::size_t page_index{0}; page_index < NUM_PAGES; page_index += 1) { - const auto page_start{page_index * PAGE_SIZE}; + const auto page_start{page_index * TABLE_PAGE_SIZE}; const std::string page_key{ - reinterpret_cast(values.data() + page_start), PAGE_SIZE}; + reinterpret_cast(values.data() + page_start), + TABLE_PAGE_SIZE}; const auto existing{page_to_id.find(page_key)}; if (existing != page_to_id.end()) { table.stage1.push_back(existing->second); continue; } const auto new_id{ - static_cast(table.stage2.size() / PAGE_SIZE)}; + static_cast(table.stage2.size() / TABLE_PAGE_SIZE)}; page_to_id.emplace(page_key, new_id); table.stage2.insert( table.stage2.end(), values.begin() + static_cast(page_start), - values.begin() + static_cast(page_start + PAGE_SIZE)); + values.begin() + + static_cast(page_start + TABLE_PAGE_SIZE)); table.stage1.push_back(new_id); } return table; diff --git a/vendor/core/src/core/jsonrpc/include/sourcemeta/core/jsonrpc.h b/vendor/core/src/core/jsonrpc/include/sourcemeta/core/jsonrpc.h index 314fafbcd..ffabca559 100644 --- a/vendor/core/src/core/jsonrpc/include/sourcemeta/core/jsonrpc.h +++ b/vendor/core/src/core/jsonrpc/include/sourcemeta/core/jsonrpc.h @@ -66,6 +66,37 @@ constexpr std::int64_t JSONRPC_CODE_SERVER_ERROR_MAX = -32000; SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_is_server_error(const std::int64_t code) -> bool; +/// @ingroup jsonrpc +/// Check whether the given JSON value is a JSON-RPC 2.0 batch envelope. For +/// example: +/// +/// ```cpp +/// #include +/// #include +/// #include +/// +/// const auto payload{sourcemeta::core::parse_json(R"([])")}; +/// assert(sourcemeta::core::jsonrpc_is_batch(payload)); +/// ``` +SOURCEMETA_CORE_JSONRPC_EXPORT +auto jsonrpc_is_batch(const sourcemeta::core::JSON &payload) -> bool; + +/// @ingroup jsonrpc +/// Check whether the given JSON value is a non-empty JSON-RPC 2.0 batch +/// envelope. For example: +/// +/// ```cpp +/// #include +/// #include +/// #include +/// +/// const auto payload{sourcemeta::core::parse_json( +/// R"([ { "jsonrpc": "2.0", "method": "ping" } ])")}; +/// assert(sourcemeta::core::jsonrpc_is_valid_batch(payload)); +/// ``` +SOURCEMETA_CORE_JSONRPC_EXPORT +auto jsonrpc_is_valid_batch(const sourcemeta::core::JSON &payload) -> bool; + /// @ingroup jsonrpc /// Extract the request identifier from a JSON-RPC 2.0 envelope. Returns a /// pointer to the identifier (string, number, or null per the specification) diff --git a/vendor/core/src/core/jsonrpc/jsonrpc.cc b/vendor/core/src/core/jsonrpc/jsonrpc.cc index ca15a878e..89724d34e 100644 --- a/vendor/core/src/core/jsonrpc/jsonrpc.cc +++ b/vendor/core/src/core/jsonrpc/jsonrpc.cc @@ -29,6 +29,14 @@ auto jsonrpc_is_server_error(const std::int64_t code) -> bool { code <= JSONRPC_CODE_SERVER_ERROR_MAX; } +auto jsonrpc_is_batch(const sourcemeta::core::JSON &payload) -> bool { + return payload.is_array(); +} + +auto jsonrpc_is_valid_batch(const sourcemeta::core::JSON &payload) -> bool { + return jsonrpc_is_batch(payload) && !payload.empty(); +} + auto jsonrpc_request_id(const sourcemeta::core::JSON &request) -> const sourcemeta::core::JSON * { if (!request.is_object()) { diff --git a/vendor/core/src/core/mcp/include/sourcemeta/core/mcp.h b/vendor/core/src/core/mcp/include/sourcemeta/core/mcp.h index eb4b75dd6..de244891e 100644 --- a/vendor/core/src/core/mcp/include/sourcemeta/core/mcp.h +++ b/vendor/core/src/core/mcp/include/sourcemeta/core/mcp.h @@ -206,6 +206,14 @@ constexpr auto mcp_supports_implementation_website_url( return version == MCPProtocolVersion::V_2025_11_25; } +/// @ingroup mcp +/// Whether the given protocol version supports JSON-RPC 2.0 batching. +constexpr auto +mcp_supports_jsonrpc_batching(const MCPProtocolVersion version) noexcept + -> bool { + return version == MCPProtocolVersion::V_2025_03_26; +} + /// @ingroup mcp /// Build an MCP `text` content block carrying the given text payload. For /// example: @@ -321,13 +329,12 @@ auto mcp_make_tool_error(const sourcemeta::core::JSON &identifier, /// #include /// /// const auto identifier{sourcemeta::core::JSON{3}}; -/// const auto envelope{sourcemeta::core::mcp_make_error_resource_not_found( -/// identifier, "file:///missing")}; +/// const auto envelope{ +/// sourcemeta::core::mcp_make_error_resource_not_found(identifier)}; /// assert(envelope.at("error").at("code").to_integer() == -32002); /// ``` SOURCEMETA_CORE_MCP_EXPORT -auto mcp_make_error_resource_not_found(const sourcemeta::core::JSON &identifier, - const JSON::StringView uri) +auto mcp_make_error_resource_not_found(const sourcemeta::core::JSON &identifier) -> sourcemeta::core::JSON; /// @ingroup mcp diff --git a/vendor/core/src/core/mcp/mcp.cc b/vendor/core/src/core/mcp/mcp.cc index 1585ae3c7..969a9587a 100644 --- a/vendor/core/src/core/mcp/mcp.cc +++ b/vendor/core/src/core/mcp/mcp.cc @@ -178,12 +178,10 @@ auto mcp_make_tool_error(const sourcemeta::core::JSON &identifier, std::move(envelope_result)); } -auto mcp_make_error_resource_not_found(const sourcemeta::core::JSON &identifier, - const JSON::StringView uri) +auto mcp_make_error_resource_not_found(const sourcemeta::core::JSON &identifier) -> sourcemeta::core::JSON { return sourcemeta::core::jsonrpc_make_error( - &identifier, MCP_CODE_RESOURCE_NOT_FOUND, "Resource not found", - sourcemeta::core::JSON{uri}); + &identifier, MCP_CODE_RESOURCE_NOT_FOUND, "Resource not found"); } auto mcp_make_resource(const JSON::StringView uri, const JSON::StringView name, diff --git a/vendor/core/src/core/time/CMakeLists.txt b/vendor/core/src/core/time/CMakeLists.txt index e2ef8d440..62481adb0 100644 --- a/vendor/core/src/core/time/CMakeLists.txt +++ b/vendor/core/src/core/time/CMakeLists.txt @@ -1,6 +1,7 @@ sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME time - SOURCES gmt.cc rfc3339_datetime.cc rfc3339_fulldate.cc rfc3339_fulltime.cc - rfc3339_duration.cc) + SOURCES imf_fixdate.cc rfc850_date.cc asctime.cc + rfc3339_datetime.cc rfc3339_fulldate.cc rfc3339_fulltime.cc + rfc3339_partialtime_no_secfrac.cc rfc3339_duration.cc) if(SOURCEMETA_CORE_INSTALL) sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME time) diff --git a/vendor/core/src/core/time/asctime.cc b/vendor/core/src/core/time/asctime.cc new file mode 100644 index 000000000..777aed71e --- /dev/null +++ b/vendor/core/src/core/time/asctime.cc @@ -0,0 +1,87 @@ +#include + +#include // assert +#include // std::isdigit +#include // std::chrono::system_clock +#include // std::time_t, std::tm, timegm, gmtime_r, gmtime_s +#include // std::put_time, std::get_time +#include // std::locale +#include // std::optional, std::nullopt +#include // std::ostringstream, std::istringstream +#include // std::runtime_error +#include // std::string +#include // std::string_view + +namespace { +constexpr auto FORMAT_ASCTIME_OUTPUT{"%a %b %e %H:%M:%S %Y"}; +constexpr auto FORMAT_ASCTIME_NORMALISED_INPUT{"%a %b %d %H:%M:%S %Y"}; +} // namespace + +namespace sourcemeta::core { + +auto to_asctime(const std::chrono::system_clock::time_point time) + -> std::string { + const std::time_t ctime = std::chrono::system_clock::to_time_t(time); + std::tm buffer; +#if defined(_MSC_VER) + if (gmtime_s(&buffer, &ctime) != 0) { + throw std::runtime_error("Could not convert time point to asctime"); + } +#else + if (gmtime_r(&ctime, &buffer) == nullptr) { + throw std::runtime_error("Could not convert time point to asctime"); + } +#endif + std::tm *parts = &buffer; + assert(parts); + std::ostringstream stream; + stream.imbue(std::locale::classic()); + stream << std::put_time(parts, FORMAT_ASCTIME_OUTPUT); + return stream.str(); +} + +auto from_asctime(const std::string_view value) noexcept + -> std::optional try { + if (value.size() != 24) { + return std::nullopt; + } + if (value[3] != ' ' || value[7] != ' ' || value[10] != ' ' || + value[13] != ':' || value[16] != ':' || value[19] != ' ') { + return std::nullopt; + } + if ((value[8] != ' ' && + !std::isdigit(static_cast(value[8]))) || + !std::isdigit(static_cast(value[9])) || + !std::isdigit(static_cast(value[11])) || + !std::isdigit(static_cast(value[12])) || + !std::isdigit(static_cast(value[14])) || + !std::isdigit(static_cast(value[15])) || + !std::isdigit(static_cast(value[17])) || + !std::isdigit(static_cast(value[18])) || + !std::isdigit(static_cast(value[20])) || + !std::isdigit(static_cast(value[21])) || + !std::isdigit(static_cast(value[22])) || + !std::isdigit(static_cast(value[23]))) { + return std::nullopt; + } + std::string normalised{value}; + if (normalised[8] == ' ') { + normalised[8] = '0'; + } + std::istringstream stream{normalised}; + stream.imbue(std::locale::classic()); + std::tm parts = {}; + stream >> std::get_time(&parts, FORMAT_ASCTIME_NORMALISED_INPUT); + if (stream.fail()) { + return std::nullopt; + } +#if defined(_MSC_VER) + return std::chrono::system_clock::from_time_t(_mkgmtime(&parts)); +#else + return std::chrono::system_clock::from_time_t(timegm(&parts)); +#endif +} catch (...) { + return std::nullopt; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/time/gmt.cc b/vendor/core/src/core/time/gmt.cc deleted file mode 100644 index 71731d17d..000000000 --- a/vendor/core/src/core/time/gmt.cc +++ /dev/null @@ -1,56 +0,0 @@ -#include - -#include // assert -#include // std::time_t, std::tm, std::gmtime, std::mktime, timegm -#include // std::put_time, std::get_time -#include // std::ostringstream, std::istringstream -#include // std::invalid_argument, std::runtime_error -#include // std::string -#include // std::string_view - -#if defined(_MSC_VER) -#include -#endif - -namespace { -constexpr auto FORMAT_GMT{"%a, %d %b %Y %H:%M:%S GMT"}; -} - -namespace sourcemeta::core { - -auto to_gmt(const std::chrono::system_clock::time_point time) -> std::string { - const std::time_t ctime = std::chrono::system_clock::to_time_t(time); - std::tm buffer; -#if defined(_MSC_VER) - if (gmtime_s(&buffer, &ctime) != 0) { - throw std::runtime_error("Could not convert time point to GMT"); - } -#else - if (gmtime_r(&ctime, &buffer) == nullptr) { - throw std::runtime_error("Could not convert time point to GMT"); - } -#endif - std::tm *parts = &buffer; - assert(parts); - std::ostringstream stream; - stream << std::put_time(parts, FORMAT_GMT); - return stream.str(); -} - -auto from_gmt(const std::string_view time) - -> std::chrono::system_clock::time_point { - std::istringstream stream{std::string{time}}; - std::tm parts = {}; - stream >> std::get_time(&parts, FORMAT_GMT); - if (stream.fail()) { - throw std::invalid_argument("Invalid GMT timestamp"); - } - -#if defined(_MSC_VER) - return std::chrono::system_clock::from_time_t(_mkgmtime(&parts)); -#else - return std::chrono::system_clock::from_time_t(timegm(&parts)); -#endif -} - -} // namespace sourcemeta::core diff --git a/vendor/core/src/core/time/imf_fixdate.cc b/vendor/core/src/core/time/imf_fixdate.cc new file mode 100644 index 000000000..b4af8dde6 --- /dev/null +++ b/vendor/core/src/core/time/imf_fixdate.cc @@ -0,0 +1,82 @@ +#include + +#include // assert +#include // std::isdigit +#include // std::chrono::system_clock +#include // std::time_t, std::tm, timegm, gmtime_r, gmtime_s +#include // std::put_time, std::get_time +#include // std::locale +#include // std::optional, std::nullopt +#include // std::ostringstream, std::istringstream +#include // std::runtime_error +#include // std::string +#include // std::string_view + +namespace { +constexpr auto FORMAT_IMF_FIXDATE{"%a, %d %b %Y %H:%M:%S GMT"}; +} + +namespace sourcemeta::core { + +auto to_imf_fixdate(const std::chrono::system_clock::time_point time) + -> std::string { + const std::time_t ctime = std::chrono::system_clock::to_time_t(time); + std::tm buffer; +#if defined(_MSC_VER) + if (gmtime_s(&buffer, &ctime) != 0) { + throw std::runtime_error("Could not convert time point to IMF-fixdate"); + } +#else + if (gmtime_r(&ctime, &buffer) == nullptr) { + throw std::runtime_error("Could not convert time point to IMF-fixdate"); + } +#endif + std::tm *parts = &buffer; + assert(parts); + std::ostringstream stream; + stream.imbue(std::locale::classic()); + stream << std::put_time(parts, FORMAT_IMF_FIXDATE); + return stream.str(); +} + +auto from_imf_fixdate(const std::string_view value) noexcept + -> std::optional try { + if (value.size() != 29) { + return std::nullopt; + } + if (value[3] != ',' || value[4] != ' ' || value[7] != ' ' || + value[11] != ' ' || value[16] != ' ' || value[19] != ':' || + value[22] != ':' || value[25] != ' ' || value.substr(26) != "GMT") { + return std::nullopt; + } + if (!std::isdigit(static_cast(value[5])) || + !std::isdigit(static_cast(value[6])) || + !std::isdigit(static_cast(value[12])) || + !std::isdigit(static_cast(value[13])) || + !std::isdigit(static_cast(value[14])) || + !std::isdigit(static_cast(value[15])) || + !std::isdigit(static_cast(value[17])) || + !std::isdigit(static_cast(value[18])) || + !std::isdigit(static_cast(value[20])) || + !std::isdigit(static_cast(value[21])) || + !std::isdigit(static_cast(value[23])) || + !std::isdigit(static_cast(value[24]))) { + return std::nullopt; + } + std::istringstream stream{std::string{value}}; + stream.imbue(std::locale::classic()); + std::tm parts = {}; + stream >> std::get_time(&parts, FORMAT_IMF_FIXDATE); + if (stream.fail()) { + return std::nullopt; + } +#if defined(_MSC_VER) + return std::chrono::system_clock::from_time_t(_mkgmtime(&parts)); +#else + return std::chrono::system_clock::from_time_t(timegm(&parts)); +#endif +} catch (...) { + return std::nullopt; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/time/include/sourcemeta/core/time.h b/vendor/core/src/core/time/include/sourcemeta/core/time.h index 790e14eae..26acc75a0 100644 --- a/vendor/core/src/core/time/include/sourcemeta/core/time.h +++ b/vendor/core/src/core/time/include/sourcemeta/core/time.h @@ -9,6 +9,7 @@ #include // assert #include // std::chrono::system_clock::time_point #include // std::uint8_t, std::uint16_t +#include // std::optional #include // std::string #include // std::string_view @@ -25,64 +26,97 @@ namespace sourcemeta::core { /// @ingroup time -/// Convert a time point into a GMT string. For example: +/// Format a time point as an RFC 9110 §5.6.7 IMF-fixdate string. For example: /// /// ```cpp /// #include -/// -/// #include -/// #include /// #include /// -/// std::tm parts = {}; -/// parts.tm_year = 115; -/// parts.tm_mon = 9; -/// parts.tm_mday = 21; -/// parts.tm_hour = 11; -/// parts.tm_min = 28; -/// parts.tm_sec = 0; -/// parts.tm_isdst = 0; +/// const auto point{std::chrono::system_clock::from_time_t(0)}; +/// assert(sourcemeta::core::to_imf_fixdate(point) == +/// "Thu, 01 Jan 1970 00:00:00 GMT"); +/// ``` +SOURCEMETA_CORE_TIME_EXPORT +auto to_imf_fixdate(const std::chrono::system_clock::time_point time) + -> std::string; + +/// @ingroup time +/// Parse an RFC 9110 §5.6.7 IMF-fixdate string into a time point. For example: /// -/// const auto point{std::chrono::system_clock::from_time_t(timegm(&parts))}; +/// ```cpp +/// #include +/// #include /// -/// assert(sourcemeta::core::to_gmt(point) == -/// "Wed, 21 Oct 2015 11:28:00 GMT"); +/// const auto point{ +/// sourcemeta::core::from_imf_fixdate("Thu, 01 Jan 1970 00:00:00 GMT")}; +/// assert(point.has_value()); /// ``` -/// -/// On Windows, you might need to use `_mkgmtime` instead of `timegm`. SOURCEMETA_CORE_TIME_EXPORT -auto to_gmt(const std::chrono::system_clock::time_point time) -> std::string; +auto from_imf_fixdate(const std::string_view value) noexcept + -> std::optional; /// @ingroup time -/// Parse a GMT string into a time point. For example: +/// Format a time point as an RFC 850 date string. For example: /// /// ```cpp /// #include +/// #include +/// +/// const auto point{std::chrono::system_clock::from_time_t(0)}; +/// assert(sourcemeta::core::to_rfc850_date(point) == +/// "Thursday, 01-Jan-70 00:00:00 GMT"); +/// ``` +SOURCEMETA_CORE_TIME_EXPORT +auto to_rfc850_date(const std::chrono::system_clock::time_point time) + -> std::string; + +/// @ingroup time +/// Parse an RFC 850 date string into a time point. The two-digit year is +/// interpreted per RFC 9110 §5.6.7. For example: /// -/// #include -/// #include +/// ```cpp +/// #include /// #include /// /// const auto point{ -/// sourcemeta::core::from_gmt("Wed, 21 Oct 2015 11:28:00 GMT")}; +/// sourcemeta::core::from_rfc850_date("Sunday, 06-Nov-94 08:49:37 GMT")}; +/// assert(point.has_value()); +/// ``` +SOURCEMETA_CORE_TIME_EXPORT +auto from_rfc850_date(const std::string_view value) noexcept + -> std::optional; + +/// @ingroup time +/// Format a time point as an RFC 9110 §5.6.7 asctime-date string. The output +/// matches the ANSI C `asctime()` field layout but omits the trailing newline +/// that `asctime()` itself appends. For example: /// -/// std::tm parts = {}; -/// parts.tm_year = 115; -/// parts.tm_mon = 9; -/// parts.tm_mday = 21; -/// parts.tm_hour = 11; -/// parts.tm_min = 28; -/// parts.tm_sec = 0; -/// parts.tm_isdst = 0; -/// const auto expected{std::chrono::system_clock::from_time_t(timegm(&parts))}; +/// ```cpp +/// #include +/// #include /// -/// assert(point = expected); +/// const auto point{std::chrono::system_clock::from_time_t(0)}; +/// assert(sourcemeta::core::to_asctime(point) == "Thu Jan 1 00:00:00 1970"); /// ``` +SOURCEMETA_CORE_TIME_EXPORT +auto to_asctime(const std::chrono::system_clock::time_point time) + -> std::string; + +/// @ingroup time +/// Parse an RFC 9110 §5.6.7 asctime-date string into a time point. The format +/// has no timezone token and is interpreted as GMT. For example: +/// +/// ```cpp +/// #include +/// #include /// -/// On Windows, you might need to use `_mkgmtime` instead of `timegm`. +/// const auto point{ +/// sourcemeta::core::from_asctime("Sun Nov 6 08:49:37 1994")}; +/// assert(point.has_value()); +/// ``` SOURCEMETA_CORE_TIME_EXPORT -auto from_gmt(const std::string_view time) - -> std::chrono::system_clock::time_point; +auto from_asctime(const std::string_view value) noexcept + -> std::optional; /// @ingroup time /// Check whether the given string is a valid date-time value per RFC 3339 @@ -161,6 +195,33 @@ auto is_rfc3339_fulldate(const std::string_view value) -> bool; SOURCEMETA_CORE_TIME_EXPORT auto is_rfc3339_fulltime(const std::string_view value) -> bool; +/// @ingroup time +/// Check whether the given string is a valid partial-time value per RFC 3339 +/// Section 5.6 (Internet Date/Time Format), excluding the optional +/// fractional seconds component. This implements the `partial-time` +/// production rule without `[time-secfrac]`: +/// +/// ``` +/// partial-time = time-hour ":" time-minute ":" time-second +/// ``` +/// +/// This matches the JSON Schema Draft 3 `time` format (`hh:mm:ss`). For +/// example: +/// +/// ```cpp +/// #include +/// +/// #include +/// +/// assert(sourcemeta::core::is_rfc3339_partialtime_no_secfrac("08:30:06")); +/// assert(sourcemeta::core::is_rfc3339_partialtime_no_secfrac("23:59:60")); +/// assert(!sourcemeta::core::is_rfc3339_partialtime_no_secfrac("08:30:06.5")); +/// assert(!sourcemeta::core::is_rfc3339_partialtime_no_secfrac("08:30:06Z")); +/// assert(!sourcemeta::core::is_rfc3339_partialtime_no_secfrac("8:30 AM")); +/// ``` +SOURCEMETA_CORE_TIME_EXPORT +auto is_rfc3339_partialtime_no_secfrac(const std::string_view value) -> bool; + /// @ingroup time /// Check whether the given string is a valid duration value per RFC 3339 /// Appendix A (ISO 8601 Collected ABNF). This implements the `duration` diff --git a/vendor/core/src/core/time/rfc3339_partialtime_no_secfrac.cc b/vendor/core/src/core/time/rfc3339_partialtime_no_secfrac.cc new file mode 100644 index 000000000..2a972b313 --- /dev/null +++ b/vendor/core/src/core/time/rfc3339_partialtime_no_secfrac.cc @@ -0,0 +1,59 @@ +#include +#include + +namespace sourcemeta::core { + +auto is_rfc3339_partialtime_no_secfrac(const std::string_view value) -> bool { + // partial-time without [time-secfrac] is exactly "HH:MM:SS" = 8 characters + if (value.size() != 8) { + return false; + } + + // time-hour = 2DIGIT ; 00-23 + if (!is_digit(value[0]) || !is_digit(value[1])) { + return false; + } + const auto hour{static_cast(value[0] - '0') * 10 + + static_cast(value[1] - '0')}; + if (hour > 23) { + return false; + } + + if (value[2] != ':') { + return false; + } + + // time-minute = 2DIGIT ; 00-59 + if (!is_digit(value[3]) || !is_digit(value[4])) { + return false; + } + const auto minute{static_cast(value[3] - '0') * 10 + + static_cast(value[4] - '0')}; + if (minute > 59) { + return false; + } + + if (value[5] != ':') { + return false; + } + + // time-second = 2DIGIT ; 00-60 (60 = leap second per §5.7) + if (!is_digit(value[6]) || !is_digit(value[7])) { + return false; + } + const auto second{static_cast(value[6] - '0') * 10 + + static_cast(value[7] - '0')}; + if (second > 60) { + return false; + } + + // Leap second per §5.7: only legal at 23:59 UTC. partial-time carries no + // offset, so we treat the value as UTC and require 23:59:60 exactly + if (second == 60 && (hour != 23 || minute != 59)) { + return false; + } + + return true; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/time/rfc850_date.cc b/vendor/core/src/core/time/rfc850_date.cc new file mode 100644 index 000000000..a41e2576e --- /dev/null +++ b/vendor/core/src/core/time/rfc850_date.cc @@ -0,0 +1,125 @@ +#include + +#include // std::ranges::find +#include // std::array +#include // assert +#include // std::isdigit +#include // std::chrono::system_clock +#include // std::time_t, std::tm, timegm, gmtime_r, gmtime_s +#include // std::put_time, std::get_time +#include // std::locale +#include // std::optional, std::nullopt +#include // std::ostringstream, std::istringstream +#include // std::runtime_error +#include // std::string, std::to_string +#include // std::string_view + +namespace { + +constexpr auto FORMAT_RFC850_OUTPUT{"%A, %d-%b-%y %H:%M:%S GMT"}; +constexpr auto FORMAT_RFC850_NORMALISED_INPUT{"%d-%b-%Y %H:%M:%S GMT"}; + +constexpr std::array RFC850_DAY_NAMES{ + {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", + "Sunday"}}; + +auto current_utc_year() noexcept -> std::optional { + const auto now{std::chrono::system_clock::now()}; + const std::time_t ctime{std::chrono::system_clock::to_time_t(now)}; + std::tm buffer; +#if defined(_MSC_VER) + if (gmtime_s(&buffer, &ctime) != 0) { + return std::nullopt; + } +#else + if (gmtime_r(&ctime, &buffer) == nullptr) { + return std::nullopt; + } +#endif + return buffer.tm_year + 1900; +} + +} // namespace + +namespace sourcemeta::core { + +auto to_rfc850_date(const std::chrono::system_clock::time_point time) + -> std::string { + const std::time_t ctime = std::chrono::system_clock::to_time_t(time); + std::tm buffer; +#if defined(_MSC_VER) + if (gmtime_s(&buffer, &ctime) != 0) { + throw std::runtime_error("Could not convert time point to RFC 850 date"); + } +#else + if (gmtime_r(&ctime, &buffer) == nullptr) { + throw std::runtime_error("Could not convert time point to RFC 850 date"); + } +#endif + std::tm *parts = &buffer; + assert(parts); + std::ostringstream stream; + stream.imbue(std::locale::classic()); + stream << std::put_time(parts, FORMAT_RFC850_OUTPUT); + return stream.str(); +} + +auto from_rfc850_date(const std::string_view value) noexcept + -> std::optional try { + const auto comma_position{value.find(',')}; + if (comma_position == std::string_view::npos) { + return std::nullopt; + } + const auto day_name{value.substr(0, comma_position)}; + if (std::ranges::find(RFC850_DAY_NAMES, day_name) == RFC850_DAY_NAMES.end()) { + return std::nullopt; + } + const auto rest{value.substr(comma_position + 1)}; + if (rest.size() != 23 || rest[0] != ' ' || rest[3] != '-' || rest[7] != '-' || + rest[10] != ' ' || rest.substr(19) != " GMT") { + return std::nullopt; + } + if (!std::isdigit(static_cast(rest[1])) || + !std::isdigit(static_cast(rest[2])) || + !std::isdigit(static_cast(rest[8])) || + !std::isdigit(static_cast(rest[9])) || + !std::isdigit(static_cast(rest[11])) || + !std::isdigit(static_cast(rest[12])) || + !std::isdigit(static_cast(rest[14])) || + !std::isdigit(static_cast(rest[15])) || + !std::isdigit(static_cast(rest[17])) || + !std::isdigit(static_cast(rest[18]))) { + return std::nullopt; + } + const int two_digit_year{(rest[8] - '0') * 10 + (rest[9] - '0')}; + const auto current_year{current_utc_year()}; + if (!current_year.has_value()) { + return std::nullopt; + } + const int current_century{(current_year.value() / 100) * 100}; + int full_year{current_century + two_digit_year}; + if (full_year > current_year.value() + 50) { + full_year -= 100; + } + std::string normalised; + normalised.reserve(24); + normalised.append(rest.substr(1, 7)); + normalised.append(std::to_string(full_year)); + normalised.append(rest.substr(10)); + std::istringstream stream{normalised}; + stream.imbue(std::locale::classic()); + std::tm parts = {}; + stream >> std::get_time(&parts, FORMAT_RFC850_NORMALISED_INPUT); + if (stream.fail()) { + return std::nullopt; + } +#if defined(_MSC_VER) + return std::chrono::system_clock::from_time_t(_mkgmtime(&parts)); +#else + return std::chrono::system_clock::from_time_t(timegm(&parts)); +#endif +} catch (...) { + return std::nullopt; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/core/unicode/codegen.cc b/vendor/core/src/core/unicode/codegen.cc index 7e478003b..f86f8ef77 100644 --- a/vendor/core/src/core/unicode/codegen.cc +++ b/vendor/core/src/core/unicode/codegen.cc @@ -10,29 +10,30 @@ #include // std::size_t, std::ptrdiff_t #include // std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t #include // EXIT_FAILURE, EXIT_SUCCESS -#include // std::exception -#include // std::filesystem::path -#include // std::hex, std::uppercase, std::dec -#include // std::ios -#include // std::cerr -#include // std::map -#include // std::optional -#include // std::ostream -#include // std::views::transform -#include // std::span -#include // std::runtime_error -#include // std::string -#include // std::string_view +#include // std::exception +#include // std::filesystem::path +#include // std::hex, std::uppercase, std::dec +#include // std::cerr +#include // std::map +#include // std::optional +#include // std::ostream +#include // std::views::transform +#include // std::regex, std::regex_match, std::smatch, std::cmatch +#include // std::span +#include // std::runtime_error +#include // std::string +#include // std::string_view #include // std::unordered_map #include // std::unordered_set +#include // std::move #include // std::vector namespace { constexpr std::size_t TOTAL_CODEPOINTS{0x110000}; -constexpr std::size_t PAGE_SHIFT{10}; -constexpr std::size_t PAGE_SIZE{1 << PAGE_SHIFT}; -constexpr std::size_t NUM_PAGES{TOTAL_CODEPOINTS / PAGE_SIZE}; +constexpr std::size_t TABLE_PAGE_SHIFT{10}; +constexpr std::size_t TABLE_PAGE_SIZE{1 << TABLE_PAGE_SHIFT}; +constexpr std::size_t NUM_PAGES{TOTAL_CODEPOINTS / TABLE_PAGE_SIZE}; constexpr std::size_t DECOMPOSITION_OFFSET_BITS{14}; constexpr std::size_t DECOMPOSITION_OFFSET_MASK{ (1U << DECOMPOSITION_OFFSET_BITS) - 1U}; @@ -86,6 +87,13 @@ struct CanonicalCompositionTriple { std::uint32_t composed; }; +struct UCDEntry { + std::uint32_t first; + std::uint32_t last; + std::string trailing; + bool is_missing; +}; + auto parse_hex_codepoint(const std::string_view token) -> std::uint32_t { const auto parsed{sourcemeta::core::to_uint32_t(token, 16)}; if (!parsed.has_value() || parsed.value() > 0x10FFFF) { @@ -94,6 +102,59 @@ auto parse_hex_codepoint(const std::string_view token) -> std::uint32_t { return parsed.value(); } +auto canonical_index(const std::span order, + const std::span aliases) + -> std::uint8_t { + for (const auto alias : aliases) { + for (std::size_t index{0}; index < order.size(); index += 1) { + if (alias == order[index]) { + return static_cast(index); + } + } + } + throw std::runtime_error{"Alias not in canonical order"}; +} + +template +auto for_each_ucd_entry(std::istream &stream, Callback callback) -> void { + static const std::regex line_re{ + R"(^([0-9A-Fa-f]+)(?:\.\.([0-9A-Fa-f]+))?\s*;\s*(.*)$)"}; + static const std::regex missing_re{R"(^#\s*@missing:\s*(.+?)\s*$)"}; + + sourcemeta::core::for_each_line(stream, [&](const std::string_view raw_line) { + const auto trimmed{sourcemeta::core::trim(raw_line)}; + if (trimmed.empty()) { + return; + } + std::string content; + bool is_missing{false}; + if (trimmed.front() == '#') { + std::cmatch match; + if (!std::regex_match(trimmed.data(), trimmed.data() + trimmed.size(), + match, missing_re)) { + return; + } + content = match[1].str(); + is_missing = true; + } else { + content = std::string{ + sourcemeta::core::trim(sourcemeta::core::take_until(trimmed, '#'))}; + } + std::smatch match; + if (!std::regex_match(content, match, line_re)) { + throw std::runtime_error{ + std::string{"Unparseable UCD line: "}.append(content)}; + } + UCDEntry entry; + entry.first = parse_hex_codepoint(match[1].str()); + entry.last = + match[2].matched ? parse_hex_codepoint(match[2].str()) : entry.first; + entry.trailing = match[3].str(); + entry.is_missing = is_missing; + callback(entry); + }); +} + auto parse_property_file(const std::filesystem::path &input_path, const ValueMap &value_map, const std::optional property_filter) @@ -101,81 +162,29 @@ auto parse_property_file(const std::filesystem::path &input_path, auto stream{sourcemeta::core::read_file(input_path)}; std::vector missing; std::vector data; - constexpr std::string_view missing_prefix{"@missing:"}; - - const auto parse_payload{ - [&](const std::string_view payload) -> std::optional { - const auto trimmed{ - sourcemeta::core::trim(sourcemeta::core::take_until(payload, '#'))}; - const auto first_split{sourcemeta::core::split_once(trimmed, ';')}; - if (!first_split.has_value()) { - throw std::runtime_error{ - std::string{"Unparseable line: "}.append(payload)}; - } - const auto range_part{sourcemeta::core::trim(first_split->first)}; - const auto after_first{sourcemeta::core::trim(first_split->second)}; - - std::string_view value_token; - if (property_filter.has_value()) { - const auto second_split{ - sourcemeta::core::split_once(after_first, ';')}; - std::string_view property_token; - std::string_view tail; - if (second_split.has_value()) { - property_token = sourcemeta::core::trim(second_split->first); - tail = sourcemeta::core::trim(second_split->second); - } else { - property_token = after_first; - tail = {}; - } - if (property_token != property_filter.value()) { - return std::nullopt; - } - value_token = tail; - } else { - value_token = after_first; - } - - const auto range_split{ - sourcemeta::core::split_once(range_part, std::string_view{".."})}; - const auto first{parse_hex_codepoint( - range_split.has_value() ? range_split->first : range_part)}; - const auto last{range_split.has_value() - ? parse_hex_codepoint(range_split->second) - : first}; - - const auto value_it{value_map.find(value_token)}; - if (value_it == value_map.end()) { - throw std::runtime_error{ - std::string{"Unknown property value: "}.append(value_token)}; - } - return PropertyEntry{first, last, value_it->second}; - }}; - - sourcemeta::core::for_each_line(stream, [&](const std::string_view raw_line) { - const auto line{sourcemeta::core::trim(raw_line)}; - if (line.empty()) { - return; - } - if (line.front() == '#') { - const auto comment_body{sourcemeta::core::trim(line.substr(1))}; - if (comment_body.size() < missing_prefix.size() || - comment_body.substr(0, missing_prefix.size()) != missing_prefix) { + for_each_ucd_entry(stream, [&](const UCDEntry &entry) { + std::string_view value_token; + if (property_filter.has_value()) { + const auto split{sourcemeta::core::split_once(entry.trailing, ';')}; + const auto property_token{split.has_value() + ? sourcemeta::core::trim(split->first) + : std::string_view{entry.trailing}}; + if (property_token != property_filter.value()) { return; } - const auto entry{ - parse_payload(comment_body.substr(missing_prefix.size()))}; - if (entry.has_value()) { - missing.push_back(entry.value()); - } - return; + value_token = split.has_value() ? sourcemeta::core::trim(split->second) + : std::string_view{}; + } else { + value_token = entry.trailing; } - const auto entry{parse_payload(line)}; - if (entry.has_value()) { - data.push_back(entry.value()); + const auto value_it{value_map.find(value_token)}; + if (value_it == value_map.end()) { + throw std::runtime_error{ + std::string{"Unknown property value: "}.append(value_token)}; } + (entry.is_missing ? missing : data) + .push_back({entry.first, entry.last, value_it->second}); }); - std::vector result; result.reserve(missing.size() + data.size()); result.insert(result.end(), missing.begin(), missing.end()); @@ -183,116 +192,75 @@ auto parse_property_file(const std::filesystem::path &input_path, return result; } -auto parse_alias_rows(const std::filesystem::path &aliases_path, - const std::string_view property_short) - -> std::vector> { - auto stream{sourcemeta::core::read_file(aliases_path)}; - std::vector> rows; - sourcemeta::core::for_each_line(stream, [&](const std::string_view raw_line) { - const auto line{ - sourcemeta::core::trim(sourcemeta::core::take_until(raw_line, '#'))}; - if (line.empty()) { +auto parse_full_composition_exclusions(const std::filesystem::path &input_path) + -> std::unordered_set { + auto stream{sourcemeta::core::read_file(input_path)}; + std::unordered_set result; + for_each_ucd_entry(stream, [&](const UCDEntry &entry) { + const auto split{sourcemeta::core::split_once(entry.trailing, ';')}; + const auto property{split.has_value() ? sourcemeta::core::trim(split->first) + : std::string_view{entry.trailing}}; + if (property != "Full_Composition_Exclusion") { return; } - std::vector row; - bool matched{false}; - std::size_t field_index{0}; - sourcemeta::core::split(line, ';', [&](const std::string_view field) { - const auto trimmed{sourcemeta::core::trim(field)}; - if (field_index == 0) { - matched = (trimmed == property_short); - } else if (matched && !trimmed.empty()) { - row.emplace_back(trimmed); - } - field_index += 1; - }); - if (matched) { - rows.push_back(std::move(row)); + for (std::uint32_t codepoint{entry.first}; codepoint <= entry.last; + codepoint += 1) { + result.insert(codepoint); } }); - return rows; -} - -auto build_combining_mark_value_map(const std::filesystem::path &aliases_path) - -> ValueMap { - static constexpr std::array combining{ - {"M", "Mn", "Mc", "Me"}}; - ValueMap result; - for (const auto &row : parse_alias_rows(aliases_path, "gc")) { - std::uint8_t value{0}; - for (const auto &field : row) { - for (const auto &candidate : combining) { - if (field == candidate) { - value = 1; - break; - } - } - if (value == 1) { - break; - } - } - for (const auto &field : row) { - result[field] = value; - } - } return result; } -auto build_value_map(const std::filesystem::path &aliases_path, - const std::string_view property_short, - const std::span canonical_order) - -> ValueMap { - std::unordered_map canonical_to_int; - canonical_to_int.reserve(canonical_order.size()); - for (std::size_t index{0}; index < canonical_order.size(); index += 1) { - canonical_to_int.emplace(canonical_order[index], - static_cast(index)); - } - ValueMap result; - std::vector> unmatched; - for (const auto &row : parse_alias_rows(aliases_path, property_short)) { - std::optional value; - for (const auto &field : row) { - const auto found{canonical_to_int.find(field)}; - if (found != canonical_to_int.end()) { - value = found->second; - break; - } - } - if (!value.has_value()) { - unmatched.push_back(row); - continue; - } - for (const auto &field : row) { - result[field] = value.value(); +auto parse_explicit_composition_exclusions( + const std::filesystem::path &input_path) + -> std::unordered_set { + auto stream{sourcemeta::core::read_file(input_path)}; + std::unordered_set result; + sourcemeta::core::for_each_line(stream, [&](const std::string_view raw_line) { + const auto line{ + sourcemeta::core::trim(sourcemeta::core::take_until(raw_line, '#'))}; + if (line.empty()) { + return; } - } - if (!unmatched.empty()) { - throw std::runtime_error{ - std::string{"Property has values not in canonical order: "}.append( - property_short)}; - } + result.insert(parse_hex_codepoint(line)); + }); return result; } -auto build_integer_value_map(const std::filesystem::path &aliases_path, - const std::string_view property_short) +template +auto build_alias_map(const std::filesystem::path &aliases_path, + const std::string_view property_short, ValueFn value_fn) -> ValueMap { ValueMap result; - for (const auto &row : parse_alias_rows(aliases_path, property_short)) { - if (row.empty()) { - continue; + auto stream{sourcemeta::core::read_file(aliases_path)}; + sourcemeta::core::for_each_line(stream, [&](const std::string_view raw_line) { + const auto line{ + sourcemeta::core::trim(sourcemeta::core::take_until(raw_line, '#'))}; + if (line.empty()) { + return; } - const auto parsed{sourcemeta::core::to_uint32_t(row.front())}; - if (!parsed.has_value() || parsed.value() > 0xFFU) { - throw std::runtime_error{ - std::string{"Invalid integer property value: "}.append(row.front())}; + std::vector fields; + sourcemeta::core::split(line, ';', [&](const std::string_view field) { + const auto trimmed{sourcemeta::core::trim(field)}; + if (!trimmed.empty()) { + fields.push_back(trimmed); + } + }); + if (fields.empty() || fields.front() != property_short) { + return; } - const auto value{static_cast(parsed.value())}; - for (const auto &field : row) { - result[field] = value; + if (fields.size() < 2) { + throw std::runtime_error{std::string{ + "PropertyValueAliases.txt: missing aliases for property: "} + .append(property_short)}; } - } + const std::span aliases{fields.begin() + 1, + fields.end()}; + const auto value{value_fn(aliases)}; + for (const auto alias : aliases) { + result[std::string{alias}] = value; + } + }); return result; } @@ -305,122 +273,52 @@ auto parse_unicode_data(const std::filesystem::path &input_path) -> UnicodeData { auto stream{sourcemeta::core::read_file(input_path)}; UnicodeData result; - sourcemeta::core::for_each_line(stream, [&](const std::string_view raw_line) { - const auto line{sourcemeta::core::trim(raw_line)}; - if (line.empty() || line.front() == '#') { - return; - } - std::array fields{}; - std::size_t field_count{0}; - sourcemeta::core::split(line, ';', [&](const std::string_view field) { - if (field_count < fields.size()) { - fields[field_count] = field; - } - field_count += 1; - }); - if (field_count < fields.size()) { + for_each_ucd_entry(stream, [&](const UCDEntry &entry) { + if (entry.first != entry.last) { + throw std::runtime_error{ + "UnicodeData.txt: codepoint range not supported"}; + } + std::array rest{}; + std::size_t count{0}; + sourcemeta::core::split(entry.trailing, ';', + [&](const std::string_view field) { + if (count < rest.size()) { + rest[count] = field; + } + count += 1; + }); + if (count < rest.size()) { throw std::runtime_error{ std::string{"UnicodeData.txt: too few fields in line: "}.append( - line)}; + entry.trailing)}; } - const auto codepoint{ - parse_hex_codepoint(sourcemeta::core::trim(fields[0]))}; - const auto ccc_token{sourcemeta::core::trim(fields[3])}; + const auto ccc_token{sourcemeta::core::trim(rest[2])}; const auto ccc_value{sourcemeta::core::to_uint32_t(ccc_token)}; if (!ccc_value.has_value() || ccc_value.value() > 0xFFU) { throw std::runtime_error{ std::string{"UnicodeData.txt: invalid CCC: "}.append(ccc_token)}; } if (ccc_value.value() != 0) { - result.ccc[codepoint] = static_cast(ccc_value.value()); + result.ccc[entry.first] = static_cast(ccc_value.value()); } - const auto decomp_field{sourcemeta::core::trim(fields[5])}; + const auto decomp_field{sourcemeta::core::trim(rest[4])}; if (decomp_field.empty() || decomp_field.front() == '<') { return; } std::vector decomposition; - std::string_view rest{decomp_field}; - while (!rest.empty()) { - const auto token_end{rest.find(' ')}; - const auto token{token_end == std::string_view::npos - ? rest - : rest.substr(0, token_end)}; - decomposition.push_back(parse_hex_codepoint(token)); - if (token_end == std::string_view::npos) { - break; - } - rest.remove_prefix(token_end + 1); - while (!rest.empty() && rest.front() == ' ') { - rest.remove_prefix(1); - } - } + sourcemeta::core::split( + decomp_field, ' ', [&](const std::string_view token) { + const auto trimmed{sourcemeta::core::trim(token)}; + if (!trimmed.empty()) { + decomposition.push_back(parse_hex_codepoint(trimmed)); + } + }); if (decomposition.size() > 2) { throw std::runtime_error{ - std::string{"UnicodeData.txt: canonical decomposition has more " - "than 2 codepoints"}}; - } - result.decompositions[codepoint] = std::move(decomposition); - }); - return result; -} - -auto parse_full_composition_exclusions(const std::filesystem::path &input_path) - -> std::unordered_set { - auto stream{sourcemeta::core::read_file(input_path)}; - std::unordered_set result; - constexpr std::string_view target{"Full_Composition_Exclusion"}; - sourcemeta::core::for_each_line(stream, [&](const std::string_view raw_line) { - const auto line{sourcemeta::core::trim(raw_line)}; - if (line.empty() || line.front() == '#') { - return; - } - const auto trimmed{ - sourcemeta::core::trim(sourcemeta::core::take_until(line, '#'))}; - const auto first_split{sourcemeta::core::split_once(trimmed, ';')}; - if (!first_split.has_value()) { - throw std::runtime_error{ - std::string{"DerivedNormalizationProps.txt: unparseable line: "} - .append(line)}; - } - const auto range_part{sourcemeta::core::trim(first_split->first)}; - const auto after_first{sourcemeta::core::trim(first_split->second)}; - const auto second_split{sourcemeta::core::split_once(after_first, ';')}; - const auto property_token{second_split.has_value() - ? sourcemeta::core::trim(second_split->first) - : after_first}; - if (property_token != target) { - return; - } - const auto range_split{ - sourcemeta::core::split_once(range_part, std::string_view{".."})}; - const auto first{parse_hex_codepoint( - range_split.has_value() ? range_split->first : range_part)}; - const auto last{range_split.has_value() - ? parse_hex_codepoint(range_split->second) - : first}; - for (std::uint32_t codepoint{first}; codepoint <= last; codepoint += 1) { - result.insert(codepoint); - } - }); - return result; -} - -auto parse_explicit_composition_exclusions( - const std::filesystem::path &input_path) - -> std::unordered_set { - auto stream{sourcemeta::core::read_file(input_path)}; - std::unordered_set result; - sourcemeta::core::for_each_line(stream, [&](const std::string_view raw_line) { - const auto line{sourcemeta::core::trim(raw_line)}; - if (line.empty() || line.front() == '#') { - return; + std::string{"UnicodeData.txt: canonical decomposition has more than " + "2 codepoints"}}; } - const auto trimmed{ - sourcemeta::core::trim(sourcemeta::core::take_until(line, '#'))}; - if (trimmed.empty()) { - return; - } - result.insert(parse_hex_codepoint(trimmed)); + result.decompositions[entry.first] = std::move(decomposition); }); return result; } @@ -438,24 +336,14 @@ auto build_canonical_compositions( "Full_Composition_Exclusion"}}; } } - const auto ccc_of{[&](const std::uint32_t codepoint) -> std::uint8_t { const auto found{ccc.find(codepoint)}; return found == ccc.end() ? std::uint8_t{0} : found->second; }}; - std::vector triples; for (const auto &[composed, decomposition] : decompositions) { - if (decomposition.size() != 2) { - continue; - } - if (ccc_of(composed) != 0) { - continue; - } - if (ccc_of(decomposition[0]) != 0) { - continue; - } - if (full_exclusions.contains(composed)) { + if (decomposition.size() != 2 || ccc_of(composed) != 0 || + ccc_of(decomposition[0]) != 0 || full_exclusions.contains(composed)) { continue; } triples.push_back({decomposition[0], decomposition[1], composed}); @@ -463,17 +351,41 @@ auto build_canonical_compositions( std::sort(triples.begin(), triples.end(), [](const CanonicalCompositionTriple &left, const CanonicalCompositionTriple &right) { - if (left.starter != right.starter) { - return left.starter < right.starter; - } - if (left.combining != right.combining) { - return left.combining < right.combining; - } - return left.composed < right.composed; + return std::tie(left.starter, left.combining, left.composed) < + std::tie(right.starter, right.combining, right.composed); }); return triples; } +template +auto build_page_table(const std::span values) + -> std::pair, std::vector> { + std::unordered_map page_to_id; + std::vector stage1; + std::vector stage2; + stage1.reserve(NUM_PAGES); + for (std::size_t page_index{0}; page_index < NUM_PAGES; page_index += 1) { + const auto page_start{page_index * TABLE_PAGE_SIZE}; + const std::string page_key{ + reinterpret_cast(values.data() + page_start), + TABLE_PAGE_SIZE * sizeof(T)}; + const auto existing{page_to_id.find(page_key)}; + if (existing != page_to_id.end()) { + stage1.push_back(existing->second); + continue; + } + const auto new_id{ + static_cast(stage2.size() / TABLE_PAGE_SIZE)}; + page_to_id.emplace(page_key, new_id); + stage2.insert(stage2.end(), + values.begin() + static_cast(page_start), + values.begin() + static_cast( + page_start + TABLE_PAGE_SIZE)); + stage1.push_back(new_id); + } + return {std::move(stage1), std::move(stage2)}; +} + auto build_canonical_decomposition_pages( const std::map> &decompositions) -> DecompositionTable { @@ -491,31 +403,8 @@ auto build_canonical_decomposition_pages( packed[codepoint] = static_cast( (decomposition.size() << DECOMPOSITION_OFFSET_BITS) | offset); } - - std::unordered_map page_to_id; - DecompositionTable table; - table.blob = std::move(blob); - table.stage1.reserve(NUM_PAGES); - for (std::size_t page_index{0}; page_index < NUM_PAGES; page_index += 1) { - const auto page_start{page_index * PAGE_SIZE}; - const std::string page_key{ - reinterpret_cast(packed.data() + page_start), - PAGE_SIZE * sizeof(std::uint16_t)}; - const auto existing{page_to_id.find(page_key)}; - if (existing != page_to_id.end()) { - table.stage1.push_back(existing->second); - continue; - } - const auto new_id{ - static_cast(table.stage2.size() / PAGE_SIZE)}; - page_to_id.emplace(page_key, new_id); - table.stage2.insert( - table.stage2.end(), - packed.begin() + static_cast(page_start), - packed.begin() + static_cast(page_start + PAGE_SIZE)); - table.stage1.push_back(new_id); - } - return table; + auto [stage1, stage2] = build_page_table(std::span{packed}); + return {std::move(blob), std::move(stage1), std::move(stage2)}; } auto build_pages(const std::vector &entries) -> TwoStageTable { @@ -526,51 +415,13 @@ auto build_pages(const std::vector &entries) -> TwoStageTable { values[codepoint] = entry.value; } } - - std::unordered_map page_to_id; - TwoStageTable table; - table.stage1.reserve(NUM_PAGES); - for (std::size_t page_index{0}; page_index < NUM_PAGES; page_index += 1) { - const auto page_start{page_index * PAGE_SIZE}; - const std::string page_key{ - reinterpret_cast(values.data() + page_start), PAGE_SIZE}; - const auto existing{page_to_id.find(page_key)}; - if (existing != page_to_id.end()) { - table.stage1.push_back(existing->second); - continue; - } - const auto new_id{ - static_cast(table.stage2.size() / PAGE_SIZE)}; - page_to_id.emplace(page_key, new_id); - table.stage2.insert( - table.stage2.end(), - values.begin() + static_cast(page_start), - values.begin() + static_cast(page_start + PAGE_SIZE)); - table.stage1.push_back(new_id); - } - return table; + auto [stage1, stage2] = build_page_table(std::span{values}); + return {std::move(stage1), std::move(stage2)}; } -template -auto emit_row_decimal(std::ostream &stream, const std::span items) - -> void { - constexpr std::size_t row_width{16}; - for (std::size_t offset{0}; offset < items.size(); offset += row_width) { - stream << " "; - const auto upper{offset + row_width < items.size() ? offset + row_width - : items.size()}; - const auto row{items.subspan(offset, upper - offset)}; - const auto widened{row | std::views::transform([](const T value) { - return static_cast(value); - })}; - sourcemeta::core::join_to(stream, widened, ", "); - stream << ",\n"; - } -} - -template -auto emit_row_hex(std::ostream &stream, const std::span items, - const std::size_t row_width) -> void { +template +auto emit_row(std::ostream &stream, const std::span items, + const std::size_t row_width, Format format) -> void { for (std::size_t offset{0}; offset < items.size(); offset += row_width) { stream << " "; const auto upper{offset + row_width < items.size() ? offset + row_width @@ -579,22 +430,30 @@ auto emit_row_hex(std::ostream &stream, const std::span items, if (column > offset) { stream << ", "; } - stream << "0x" << std::hex << std::uppercase - << static_cast(items[column]) << std::dec; + format(stream, items[column]); } stream << ",\n"; } } +constexpr auto emit_decimal{[](std::ostream &stream, const auto value) { + stream << static_cast(value); +}}; + +constexpr auto emit_hex{[](std::ostream &stream, const auto value) { + stream << "0x" << std::hex << std::uppercase + << static_cast(value) << std::dec; +}}; + auto emit_property(std::ostream &stream, const std::string_view prefix, const TwoStageTable &table) -> void { stream << "constexpr std::uint16_t " << prefix << "_STAGE1[" << table.stage1.size() << "] = {\n"; - emit_row_decimal(stream, table.stage1); + emit_row(stream, table.stage1, 16, emit_decimal); stream << "};\n\n"; stream << "constexpr std::uint8_t " << prefix << "_STAGE2[" << table.stage2.size() << "] = {\n"; - emit_row_decimal(stream, table.stage2); + emit_row(stream, table.stage2, 16, emit_decimal); stream << "};\n\n"; } @@ -602,34 +461,37 @@ auto emit_canonical_decomposition(std::ostream &stream, const DecompositionTable &table) -> void { stream << "constexpr char32_t CANONICAL_DECOMPOSITION_BLOB[" << table.blob.size() << "] = {\n"; - emit_row_hex(stream, table.blob, 8); + emit_row(stream, table.blob, 8, emit_hex); stream << "};\n\n"; stream << "constexpr std::uint16_t CANONICAL_DECOMPOSITION_STAGE1[" << table.stage1.size() << "] = {\n"; - emit_row_decimal(stream, table.stage1); + emit_row(stream, table.stage1, 16, emit_decimal); stream << "};\n\n"; stream << "constexpr std::uint16_t CANONICAL_DECOMPOSITION_STAGE2[" << table.stage2.size() << "] = {\n"; - emit_row_decimal(stream, table.stage2); + emit_row(stream, table.stage2, 16, emit_decimal); stream << "};\n\n"; } auto emit_canonical_composition( std::ostream &stream, const std::vector &triples) -> void { - stream << "struct CanonicalCompositionEntry {\n"; - stream << " char32_t starter;\n"; - stream << " char32_t combining;\n"; - stream << " char32_t composed;\n"; - stream << "};\n\n"; - stream << "constexpr CanonicalCompositionEntry CANONICAL_COMPOSITIONS[" + stream << "struct CanonicalCompositionEntry {\n" + << " char32_t starter;\n" + << " char32_t combining;\n" + << " char32_t composed;\n" + << "};\n\n" + << "constexpr CanonicalCompositionEntry CANONICAL_COMPOSITIONS[" << triples.size() << "] = {\n"; - for (const auto &triple : triples) { - stream << " {0x" << std::hex << std::uppercase - << static_cast(triple.starter) << ", 0x" - << static_cast(triple.combining) << ", 0x" - << static_cast(triple.composed) << std::dec << "},\n"; - } + emit_row( + stream, triples, 1, + [](std::ostream &output, const CanonicalCompositionTriple &triple) { + output << "{0x" << std::hex << std::uppercase + << static_cast(triple.starter) << ", 0x" + << static_cast(triple.combining) << ", 0x" + << static_cast(triple.composed) << std::dec + << "}"; + }); stream << "};\n\n"; } @@ -653,15 +515,66 @@ auto main(const int argc, const char *const argv[]) -> int { const std::filesystem::path output_path{positional.at(0)}; const std::filesystem::path aliases_path{positional.at(1)}; - const std::filesystem::path combining_class_path{positional.at(2)}; - const std::filesystem::path joining_type_path{positional.at(3)}; - const std::filesystem::path bidi_class_path{positional.at(4)}; - const std::filesystem::path scripts_path{positional.at(5)}; - const std::filesystem::path general_category_path{positional.at(6)}; const std::filesystem::path normalization_props_path{positional.at(7)}; const std::filesystem::path unicode_data_path{positional.at(8)}; const std::filesystem::path composition_exclusions_path{positional.at(9)}; + const auto canonical_value{ + [](const std::span order) { + return [order](const std::span aliases) { + return canonical_index(order, aliases); + }; + }}; + + const auto combining_class_map{build_alias_map( + aliases_path, "ccc", + [](const std::span aliases) { + const auto parsed{sourcemeta::core::to_uint32_t(aliases.front())}; + if (!parsed.has_value() || parsed.value() > 0xFFU) { + throw std::runtime_error{ + std::string{"Invalid integer property value: "}.append( + aliases.front())}; + } + return static_cast(parsed.value()); + })}; + const auto joining_type_map{build_alias_map( + aliases_path, "jt", canonical_value(JOINING_TYPE_ORDER))}; + const auto bidi_class_map{ + build_alias_map(aliases_path, "bc", canonical_value(BIDI_CLASS_ORDER))}; + const auto script_map{build_alias_map( + aliases_path, "sc", canonical_value(UNICODE_SCRIPT_ORDER))}; + const auto combining_mark_map{ + build_alias_map(aliases_path, "gc", + [](const std::span aliases) { + for (const auto alias : aliases) { + if (alias == "M" || alias == "Mn" || + alias == "Mc" || alias == "Me") { + return std::uint8_t{1}; + } + } + return std::uint8_t{0}; + })}; + const auto nfc_quick_check_map{build_alias_map( + aliases_path, "NFC_QC", canonical_value(NFC_QUICK_CHECK_ORDER))}; + + struct PropertySpec { + std::string_view prefix; + std::filesystem::path input_path; + std::optional property_filter; + const ValueMap &value_map; + }; + + const std::array properties{ + {{"COMBINING_CLASS", positional.at(2), std::nullopt, + combining_class_map}, + {"JOINING_TYPE", positional.at(3), std::nullopt, joining_type_map}, + {"BIDI_CLASS", positional.at(4), std::nullopt, bidi_class_map}, + {"UNICODE_SCRIPT", positional.at(5), std::nullopt, script_map}, + {"IS_COMBINING_MARK", positional.at(6), std::nullopt, + combining_mark_map}, + {"NFC_QUICK_CHECK", normalization_props_path, + std::optional{"NFC_QC"}, nfc_quick_check_map}}}; + const auto unicode_data{parse_unicode_data(unicode_data_path)}; const auto full_exclusions{ parse_full_composition_exclusions(normalization_props_path)}; @@ -672,54 +585,18 @@ auto main(const int argc, const char *const argv[]) -> int { stream << "#include \n"; stream << "#include \n\n"; stream << "namespace {\n\n"; - - struct PropertySpec { - std::string_view prefix; - const std::filesystem::path &input_path; - std::optional property_filter; - ValueMap value_map; - }; - - const auto combining_class_map{ - build_integer_value_map(aliases_path, "ccc")}; - const auto joining_type_map{ - build_value_map(aliases_path, "jt", JOINING_TYPE_ORDER)}; - const auto bidi_class_map{ - build_value_map(aliases_path, "bc", BIDI_CLASS_ORDER)}; - const auto script_map{ - build_value_map(aliases_path, "sc", UNICODE_SCRIPT_ORDER)}; - const auto combining_mark_map{ - build_combining_mark_value_map(aliases_path)}; - const auto nfc_quick_check_map{ - build_value_map(aliases_path, "NFC_QC", NFC_QUICK_CHECK_ORDER)}; - - const std::array properties{ - {{"COMBINING_CLASS", combining_class_path, std::nullopt, - combining_class_map}, - {"JOINING_TYPE", joining_type_path, std::nullopt, joining_type_map}, - {"BIDI_CLASS", bidi_class_path, std::nullopt, bidi_class_map}, - {"UNICODE_SCRIPT", scripts_path, std::nullopt, script_map}, - {"IS_COMBINING_MARK", general_category_path, std::nullopt, - combining_mark_map}, - {"NFC_QUICK_CHECK", normalization_props_path, - std::optional{"NFC_QC"}, nfc_quick_check_map}}}; - for (const auto &spec : properties) { - const auto entries{parse_property_file(spec.input_path, spec.value_map, - spec.property_filter)}; - const auto table{build_pages(entries)}; - emit_property(stream, spec.prefix, table); + emit_property( + stream, spec.prefix, + build_pages(parse_property_file(spec.input_path, spec.value_map, + spec.property_filter))); } - - const auto decomposition_table{ - build_canonical_decomposition_pages(unicode_data.decompositions)}; - emit_canonical_decomposition(stream, decomposition_table); - - const auto triples{build_canonical_compositions( - unicode_data.decompositions, unicode_data.ccc, full_exclusions, - explicit_exclusions)}; - emit_canonical_composition(stream, triples); - + emit_canonical_decomposition(stream, build_canonical_decomposition_pages( + unicode_data.decompositions)); + emit_canonical_composition(stream, build_canonical_compositions( + unicode_data.decompositions, + unicode_data.ccc, full_exclusions, + explicit_exclusions)); stream << "} // namespace\n"; }); } catch (const std::exception &error) { diff --git a/vendor/core/src/core/uri/CMakeLists.txt b/vendor/core/src/core/uri/CMakeLists.txt index 5f9f83306..8a93f3bb5 100644 --- a/vendor/core/src/core/uri/CMakeLists.txt +++ b/vendor/core/src/core/uri/CMakeLists.txt @@ -12,3 +12,7 @@ target_link_libraries(sourcemeta_core_uri PRIVATE sourcemeta::core::io) target_link_libraries(sourcemeta_core_uri PRIVATE sourcemeta::core::ip) +target_link_libraries(sourcemeta_core_uri + PRIVATE sourcemeta::core::text) +target_link_libraries(sourcemeta_core_uri + PRIVATE sourcemeta::core::unicode) diff --git a/vendor/core/src/core/uri/canonicalize.cc b/vendor/core/src/core/uri/canonicalize.cc index 528c69ed5..dc23b3369 100644 --- a/vendor/core/src/core/uri/canonicalize.cc +++ b/vendor/core/src/core/uri/canonicalize.cc @@ -1,37 +1,23 @@ +#include #include #include "escaping.h" #include "normalize.h" -#include // std::tolower #include // std::optional #include // std::string -namespace { - -auto to_lowercase(const std::string_view input) -> std::string { - std::string result; - result.reserve(input.size()); - for (const auto character : input) { - result += - static_cast(std::tolower(static_cast(character))); - } - return result; -} - -} // namespace - namespace sourcemeta::core { auto URI::canonicalize() -> URI & { // Lowercase scheme (schemes are case-insensitive per RFC 3986) if (this->scheme_.has_value()) { - this->scheme_ = to_lowercase(this->scheme_.value()); + sourcemeta::core::to_lowercase(this->scheme_.value()); } // Lowercase host (hostnames are case-insensitive per RFC 3986) if (this->host_.has_value()) { - this->host_ = to_lowercase(this->host_.value()); + sourcemeta::core::to_lowercase(this->host_.value()); } // Canonicalize path by removing "." and ".." segments diff --git a/vendor/core/src/core/uri/include/sourcemeta/core/uri.h b/vendor/core/src/core/uri/include/sourcemeta/core/uri.h index c081310fa..ac95720a7 100644 --- a/vendor/core/src/core/uri/include/sourcemeta/core/uri.h +++ b/vendor/core/src/core/uri/include/sourcemeta/core/uri.h @@ -25,7 +25,8 @@ #include // std::vector /// @defgroup uri URI -/// @brief A strict RFC 3986 URI implementation. +/// @brief A strict RFC 3986 URI implementation, with RFC 3987 IRI +/// syntax checking. /// /// This functionality is included as follows: /// @@ -331,6 +332,19 @@ class SOURCEMETA_CORE_URI_EXPORT URI { /// ``` class SOURCEMETA_CORE_URI_EXPORT Query { public: + /// Construct a query view over a raw RFC 3986 query string, + /// without a leading `?`. The view borrows the input and does not + /// own it. For example: + /// + /// ```cpp + /// #include + /// #include + /// + /// const sourcemeta::core::URI::Query query{"foo=bar&baz=qux"}; + /// assert(query.at("foo").value() == "bar"); + /// ``` + explicit Query(const std::string_view raw); + /// Get the raw RFC 3986 query string this view was constructed /// from. For example: /// @@ -403,9 +417,6 @@ class SOURCEMETA_CORE_URI_EXPORT URI { [[nodiscard]] auto end() const -> const_iterator; private: - friend class URI; - explicit Query(const std::string_view raw); - #if defined(_MSC_VER) #pragma warning(disable : 4251) #endif @@ -641,6 +652,33 @@ class SOURCEMETA_CORE_URI_EXPORT URI { [[nodiscard]] static auto is_uri_reference(std::string_view input) noexcept -> bool; + /// Check if the given string is a valid absolute IRI (has a scheme) per + /// RFC 3987 without constructing a full URI object. For example: + /// + /// ```cpp + /// #include + /// #include + /// + /// assert(sourcemeta::core::URI::is_iri("https://example.com/path")); + /// assert(!sourcemeta::core::URI::is_iri("relative/path")); + /// ``` + [[nodiscard]] static auto is_iri(std::string_view input) noexcept -> bool; + + /// Check if the given string is a valid IRI reference per RFC 3987 + /// (absolute or relative) without constructing a full URI object. + /// For example: + /// + /// ```cpp + /// #include + /// #include + /// + /// assert(sourcemeta::core::URI::is_iri_reference("https://example.com")); + /// assert(sourcemeta::core::URI::is_iri_reference("relative/path")); + /// assert(!sourcemeta::core::URI::is_iri_reference("://bad")); + /// ``` + [[nodiscard]] static auto is_iri_reference(std::string_view input) noexcept + -> bool; + /// Strip a URI path prefix and return the remaining suffix. For example: /// /// ```cpp diff --git a/vendor/core/src/core/uri/parse.cc b/vendor/core/src/core/uri/parse.cc index ffa05b4b9..385bbb1b2 100644 --- a/vendor/core/src/core/uri/parse.cc +++ b/vendor/core/src/core/uri/parse.cc @@ -1,4 +1,5 @@ #include +#include #include #include "escaping.h" @@ -15,6 +16,7 @@ #include // std::string_view #include // std::errc #include // std::conditional_t +#include // std::pair namespace { @@ -40,6 +42,73 @@ auto validate_percent_encoded_utf8(const std::string_view input, return 3; } +[[maybe_unused]] auto +decode_utf8_codepoint(const std::string_view input, + const std::string_view::size_type position) + -> std::pair { + const auto lead = static_cast(input[position]); + const auto length = sourcemeta::core::utf8_lead_byte_size(lead); + if (length == 0 || position + length > input.size()) [[unlikely]] { + throw sourcemeta::core::URIParseError{ + static_cast(position + 1)}; + } + + char32_t codepoint{0}; + if (length == 1) { + codepoint = static_cast(lead); + } else if (length == 2) { + codepoint = static_cast(lead & 0x1FU); + } else if (length == 3) { + codepoint = static_cast(lead & 0x0FU); + } else { + codepoint = static_cast(lead & 0x07U); + } + + for (std::uint8_t offset{1}; offset < length; offset += 1) { + const auto continuation = + static_cast(input[position + offset]); + if (!sourcemeta::core::is_utf8_continuation(continuation)) [[unlikely]] { + throw sourcemeta::core::URIParseError{ + static_cast(position + 1)}; + } + codepoint = (codepoint << 6) | static_cast(continuation & 0x3FU); + } + + if (!sourcemeta::core::is_valid_codepoint(codepoint) || + sourcemeta::core::utf8_codepoint_byte_count(codepoint) != length) + [[unlikely]] { + throw sourcemeta::core::URIParseError{ + static_cast(position + 1)}; + } + + return {codepoint, length}; +} + +template +auto accept_iri_extension(const std::string_view input, + std::string_view::size_type &position) -> bool { + if constexpr (!IRI) { + return false; + } else { + if ((static_cast(input[position]) & 0x80U) == 0U) { + return false; + } + const auto [codepoint, length] = decode_utf8_codepoint(input, position); + if (sourcemeta::core::is_ucschar(codepoint)) { + position += length; + return true; + } + if constexpr (AllowIPrivate) { + if (sourcemeta::core::is_iprivate(codepoint)) { + position += length; + return true; + } + } + throw sourcemeta::core::URIParseError{ + static_cast(position + 1)}; + } +} + template auto parse_scheme(const std::string_view input, std::string_view::size_type &position) @@ -197,7 +266,7 @@ auto parse_ipv6(const std::string_view input, } } -template +template auto parse_host(const std::string_view input, std::string_view::size_type &position, [[maybe_unused]] bool &ip_literal) @@ -233,7 +302,7 @@ auto parse_host(const std::string_view input, position += skip; } else if (uri_is_unreserved(current) || uri_is_sub_delim(current)) { position += 1; - } else [[unlikely]] { + } else if (!accept_iri_extension(input, position)) [[unlikely]] { throw sourcemeta::core::URIParseError{ static_cast(position + 1)}; } @@ -248,7 +317,7 @@ auto parse_host(const std::string_view input, } } -template +template auto parse_userinfo(const std::string_view input, std::string_view::size_type &position) -> std::conditional_t> { @@ -272,6 +341,15 @@ auto parse_userinfo(const std::string_view input, } else if (uri_is_unreserved(current) || uri_is_sub_delim(current) || current == URI_COLON) { position += 1; + } else if constexpr (IRI) { + if ((static_cast(current) & 0x80U) == 0U) { + break; + } + const auto [codepoint, length] = decode_utf8_codepoint(input, position); + if (!sourcemeta::core::is_ucschar(codepoint)) { + break; + } + position += length; } else { break; } @@ -285,7 +363,7 @@ auto parse_userinfo(const std::string_view input, } } -template +template auto parse_path(const std::string_view input, std::string_view::size_type &position) -> std::conditional_t> { @@ -316,12 +394,9 @@ auto parse_path(const std::string_view input, if (current == URI_PERCENT) { const auto skip = validate_percent_encoded_utf8(input, position); position += skip; - continue; - } - - if (uri_is_pchar(current) || current == URI_SLASH) { + } else if (uri_is_pchar(current) || current == URI_SLASH) { position += 1; - } else [[unlikely]] { + } else if (!accept_iri_extension(input, position)) [[unlikely]] { throw sourcemeta::core::URIParseError{ static_cast(position + 1)}; } @@ -334,7 +409,7 @@ auto parse_path(const std::string_view input, } } -template +template auto parse_query(const std::string_view input, std::string_view::size_type &position) -> std::conditional_t> { @@ -358,13 +433,10 @@ auto parse_query(const std::string_view input, if (current == URI_PERCENT) { const auto skip = validate_percent_encoded_utf8(input, position); position += skip; - continue; - } - - if (uri_is_pchar(current) || current == URI_SLASH || - current == URI_QUESTION) { + } else if (uri_is_pchar(current) || current == URI_SLASH || + current == URI_QUESTION) { position += 1; - } else [[unlikely]] { + } else if (!accept_iri_extension(input, position)) [[unlikely]] { throw sourcemeta::core::URIParseError{ static_cast(position + 1)}; } @@ -377,7 +449,7 @@ auto parse_query(const std::string_view input, } } -template +template auto parse_fragment(const std::string_view input, std::string_view::size_type &position) -> std::conditional_t> { @@ -398,13 +470,10 @@ auto parse_fragment(const std::string_view input, if (current == URI_PERCENT) { const auto skip = validate_percent_encoded_utf8(input, position); position += skip; - continue; - } - - if (uri_is_pchar(current) || current == URI_SLASH || - current == URI_QUESTION) { + } else if (uri_is_pchar(current) || current == URI_SLASH || + current == URI_QUESTION) { position += 1; - } else [[unlikely]] { + } else if (!accept_iri_extension(input, position)) [[unlikely]] { throw sourcemeta::core::URIParseError{ static_cast(position + 1)}; } @@ -417,7 +486,7 @@ auto parse_fragment(const std::string_view input, } } -template +template auto parse_authority(const std::string_view input, std::string_view::size_type &position, [[maybe_unused]] std::optional &userinfo, @@ -425,16 +494,16 @@ auto parse_authority(const std::string_view input, [[maybe_unused]] std::optional &port, [[maybe_unused]] bool &ip_literal) -> void { if constexpr (CheckOnly) { - parse_userinfo(input, position); - parse_host(input, position, ip_literal); + parse_userinfo(input, position); + parse_host(input, position, ip_literal); } else { - auto userinfo_raw = parse_userinfo(input, position); + auto userinfo_raw = parse_userinfo(input, position); if (userinfo_raw.has_value()) { uri_unescape_unreserved_inplace(userinfo_raw.value()); userinfo = std::move(userinfo_raw.value()); } - auto host_raw = parse_host(input, position, ip_literal); + auto host_raw = parse_host(input, position, ip_literal); uri_unescape_unreserved_inplace(host_raw); host = std::move(host_raw); } @@ -466,7 +535,7 @@ auto parse_authority(const std::string_view input, } } -template +template auto do_parse(const std::string_view input, [[maybe_unused]] std::optional &scheme, [[maybe_unused]] std::optional &userinfo, @@ -496,8 +565,8 @@ auto do_parse(const std::string_view input, if (has_authority) { position += 2; - parse_authority(input, position, userinfo, host, port, - ip_literal); + parse_authority(input, position, userinfo, host, port, + ip_literal); // RFC 3986: hier-part = "//" authority path-abempty // path-abempty = *( "/" segment ), so after authority the next character @@ -513,9 +582,9 @@ auto do_parse(const std::string_view input, const auto path_start = position; bool has_path; if constexpr (CheckOnly) { - has_path = parse_path(input, position); + has_path = parse_path(input, position); } else { - auto parsed_path = parse_path(input, position); + auto parsed_path = parse_path(input, position); has_path = parsed_path.has_value(); if (has_path) { @@ -561,16 +630,16 @@ auto do_parse(const std::string_view input, } if constexpr (CheckOnly) { - parse_query(input, position); - parse_fragment(input, position); + parse_query(input, position); + parse_fragment(input, position); } else { - auto parsed_query = parse_query(input, position); + auto parsed_query = parse_query(input, position); if (parsed_query.has_value()) { uri_unescape_unreserved_inplace(parsed_query.value()); query = std::move(parsed_query.value()); } - auto parsed_fragment = parse_fragment(input, position); + auto parsed_fragment = parse_fragment(input, position); if (parsed_fragment.has_value()) { uri_unescape_unreserved_inplace(parsed_fragment.value()); fragment = std::move(parsed_fragment.value()); @@ -597,9 +666,9 @@ auto URI::parse(const std::string_view input) -> void { assert(!this->path_.has_value()); assert(!this->query_.has_value()); assert(!this->fragment_.has_value()); - do_parse(input, this->scheme_, this->userinfo_, this->host_, - this->port_, this->path_, this->query_, this->fragment_, - this->ip_literal_); + do_parse(input, this->scheme_, this->userinfo_, this->host_, + this->port_, this->path_, this->query_, + this->fragment_, this->ip_literal_); } auto URI::is_uri(const std::string_view input) noexcept -> bool { @@ -607,8 +676,8 @@ auto URI::is_uri(const std::string_view input) noexcept -> bool { std::optional scheme, userinfo, host, path, query, fragment; std::optional port; bool ip_literal{false}; - return do_parse(input, scheme, userinfo, host, port, path, query, - fragment, ip_literal); + return do_parse(input, scheme, userinfo, host, port, path, + query, fragment, ip_literal); } catch (...) { return false; } @@ -619,8 +688,33 @@ auto URI::is_uri_reference(const std::string_view input) noexcept -> bool { std::optional scheme, userinfo, host, path, query, fragment; std::optional port; bool ip_literal{false}; - do_parse(input, scheme, userinfo, host, port, path, query, fragment, - ip_literal); + do_parse(input, scheme, userinfo, host, port, path, query, + fragment, ip_literal); + return true; + } catch (...) { + return false; + } +} + +auto URI::is_iri(const std::string_view input) noexcept -> bool { + try { + std::optional scheme, userinfo, host, path, query, fragment; + std::optional port; + bool ip_literal{false}; + return do_parse(input, scheme, userinfo, host, port, path, + query, fragment, ip_literal); + } catch (...) { + return false; + } +} + +auto URI::is_iri_reference(const std::string_view input) noexcept -> bool { + try { + std::optional scheme, userinfo, host, path, query, fragment; + std::optional port; + bool ip_literal{false}; + do_parse(input, scheme, userinfo, host, port, path, query, + fragment, ip_literal); return true; } catch (...) { return false; diff --git a/vendor/core/src/core/uritemplate/uritemplate_router.cc b/vendor/core/src/core/uritemplate/uritemplate_router.cc index a1e61c94f..a1aea7367 100644 --- a/vendor/core/src/core/uritemplate/uritemplate_router.cc +++ b/vendor/core/src/core/uritemplate/uritemplate_router.cc @@ -241,18 +241,19 @@ auto URITemplateRouter::add(const std::string_view uri_template, throw URITemplateRouterDuplicateOperationIdError{operation_id}; } - // Walk base path segments to establish the trie prefix + if (!uri_template.empty() && uri_template.front() != '/' && + !(uri_template.size() >= 2 && uri_template[0] == '{' && + uri_template[1] == '/')) { + throw URITemplateRouterInvalidSegmentError{"Template must start with '/'", + uri_template}; + } + Node *current = nullptr; if (!this->base_path_.empty()) { - const char *base_position = this->base_path_.data(); - const char *const base_end = base_position + this->base_path_.size(); - while (base_position < base_end) { - while (base_position < base_end && *base_position == '/') { - ++base_position; - } - if (base_position >= base_end) { - break; - } + const char *base_position = this->base_path_.data() + 1; + const char *const base_end = + this->base_path_.data() + this->base_path_.size(); + while (true) { const char *segment_start = base_position; while (base_position < base_end && *base_position != '/') { ++base_position; @@ -262,6 +263,10 @@ auto URITemplateRouter::add(const std::string_view uri_template, static_cast(base_position - segment_start)}; auto &literals = current ? current->literals : this->root_.literals; current = &find_or_create_literal_child(literals, segment); + if (base_position >= base_end) { + break; + } + ++base_position; } } @@ -300,18 +305,23 @@ auto URITemplateRouter::add(const std::string_view uri_template, return; } - Node *base_path_end = current; bool absorbed = false; const char *position = uri_template.data(); const char *const end = position + uri_template.size(); - while (position < end && !absorbed) { - while (position < end && *position == '/') { - ++position; - } + if (position < end && *position == '/') { + ++position; + } - if (position >= end) { - break; + while (true) { + if (position >= end || *position == '/') { + auto &literals = current ? current->literals : this->root_.literals; + current = &find_or_create_literal_child(literals, ""); + if (position >= end) { + break; + } + ++position; + continue; } const char *segment_start = position; @@ -425,14 +435,16 @@ auto URITemplateRouter::add(const std::string_view uri_template, const std::string_view varname{ varname_start, static_cast(varname_end - varname_start)}; - ++position; // skip '}' + ++position; - if (position < end && *position != '/') { - if (*position != '{' || position + 1 >= end || *(position + 1) != '/') { - throw URITemplateRouterInvalidSegmentError{ - "Path segment cannot mix literals and variables", - extract_segment(expression_start, end)}; - } + const bool followed_by_path_operator = + position < end && *position == '{' && position + 1 < end && + *(position + 1) == '/'; + + if (position < end && *position != '/' && !followed_by_path_operator) { + throw URITemplateRouterInvalidSegmentError{ + "Path segment cannot mix literals and variables", + extract_segment(expression_start, end)}; } if (is_expansion_type(type) && position < end) { @@ -448,47 +460,54 @@ auto URITemplateRouter::add(const std::string_view uri_template, } else { current = result; } - } else { - while (position < end && *position != '/' && *position != '{') { - if (*position == '}') { - throw URITemplateRouterInvalidSegmentError{ - "Unmatched closing brace", extract_segment(segment_start, end)}; - } - ++position; + + if (absorbed || position >= end) { + break; + } + if (followed_by_path_operator) { + continue; } + ++position; + continue; + } - if (position < end && *position == '{') { - if (position + 1 < end && *(position + 1) == '/') { - const std::string_view segment{ - segment_start, - static_cast(position - segment_start)}; - auto &literals = current ? current->literals : this->root_.literals; - current = &find_or_create_literal_child(literals, segment); - continue; - } - const char *expr_end = find_expression_end(position, end); - const char *seg_end = expr_end; - while (seg_end < end && *seg_end != '/') { - ++seg_end; - } + while (position < end && *position != '/' && *position != '{') { + if (*position == '}') { throw URITemplateRouterInvalidSegmentError{ - "Path segment cannot mix literals and variables", - std::string_view{segment_start, static_cast( - seg_end - segment_start)}}; + "Unmatched closing brace", extract_segment(segment_start, end)}; } + ++position; + } - const std::string_view segment{ - segment_start, static_cast(position - segment_start)}; - - auto &literals = current ? current->literals : this->root_.literals; - current = &find_or_create_literal_child(literals, segment); + if (position < end && *position == '{') { + if (position + 1 < end && *(position + 1) == '/') { + const std::string_view segment{ + segment_start, static_cast(position - segment_start)}; + auto &literals = current ? current->literals : this->root_.literals; + current = &find_or_create_literal_child(literals, segment); + continue; + } + const char *expr_end = find_expression_end(position, end); + const char *seg_end = expr_end; + while (seg_end < end && *seg_end != '/') { + ++seg_end; + } + throw URITemplateRouterInvalidSegmentError{ + "Path segment cannot mix literals and variables", + std::string_view{segment_start, + static_cast(seg_end - segment_start)}}; } - } - if (current == base_path_end && uri_template.size() == 1 && - uri_template[0] == '/') { + const std::string_view segment{ + segment_start, static_cast(position - segment_start)}; + auto &literals = current ? current->literals : this->root_.literals; - current = &find_or_create_literal_child(literals, ""); + current = &find_or_create_literal_child(literals, segment); + + if (position >= end) { + break; + } + ++position; } if (!absorbed && current != nullptr) { @@ -555,17 +574,13 @@ auto URITemplateRouter::match(const std::string_view path, this->root_.context); } - if (path.size() == 1 && path[0] == '/') { - if (auto *child = find_literal_child(this->root_.literals, "")) { - return finalize_match(this->otherwise_, child->identifier, - child->context); - } + if (path.front() != '/') { return finalize_match(this->otherwise_, 0, 0); } const Node *current = nullptr; - const char *position = path.data(); - const char *const path_end = position + path.size(); + const char *position = path.data() + 1; + const char *const path_end = path.data() + path.size(); const std::vector> *literal_children = &this->root_.literals; @@ -573,11 +588,6 @@ auto URITemplateRouter::match(const std::string_view path, std::size_t variable_index = 0; - // Skip leading slash - if (position < path_end && *position == '/') { - ++position; - } - while (true) { const char *segment_start = position; while (position < path_end && *position != '/') { @@ -586,14 +596,9 @@ auto URITemplateRouter::match(const std::string_view path, const std::string_view segment{ segment_start, static_cast(position - segment_start)}; - // Empty segment (from double slash or trailing slash) doesn't match - if (segment.empty()) { - return finalize_match(this->otherwise_, 0, 0); - } - if (auto *literal_match = find_literal_child(*literal_children, segment)) { current = literal_match; - } else if (*variable_child) { + } else if (!segment.empty() && *variable_child) { assert(variable_index <= std::numeric_limits::max()); if (is_expansion_type((*variable_child)->type)) { @@ -615,12 +620,9 @@ auto URITemplateRouter::match(const std::string_view path, literal_children = ¤t->literals; variable_child = ¤t->variable; - // Check if there's more path if (position >= path_end) { break; } - - // Skip the slash and continue to next segment ++position; } diff --git a/vendor/core/src/core/uritemplate/uritemplate_router_view.cc b/vendor/core/src/core/uritemplate/uritemplate_router_view.cc index 9025f7331..ad17300bc 100644 --- a/vendor/core/src/core/uritemplate/uritemplate_router_view.cc +++ b/vendor/core/src/core/uritemplate/uritemplate_router_view.cc @@ -497,87 +497,46 @@ auto URITemplateRouterView::match( const auto string_table_size = header->arguments_offset - header->string_table_offset; - // Empty path matches empty template if (path.empty()) { return finalize_match(otherwise_context, nodes[0].identifier, nodes[0].context); } - // Root path "/" is stored as an empty literal segment - if (path.size() == 1 && path[0] == '/') { - const auto &root = nodes[0]; - if (root.first_literal_child == NO_CHILD) { - return finalize_match(otherwise_context, 0, 0); - } - - if (root.first_literal_child >= header->node_count || - root.literal_child_count > - header->node_count - root.first_literal_child) { - return finalize_match(otherwise_context, 0, 0); - } - - const auto match = binary_search_literal_children( - nodes, string_table, string_table_size, root.first_literal_child, - root.literal_child_count, "", 0); - if (match == NO_CHILD) { - return finalize_match(otherwise_context, 0, 0); - } - return finalize_match(otherwise_context, nodes[match].identifier, - nodes[match].context); + if (path.front() != '/') { + return finalize_match(otherwise_context, 0, 0); } - // Walk the trie, matching each path segment std::uint32_t current_node = 0; - const char *position = path.data(); - const char *const path_end = position + path.size(); + const char *position = path.data() + 1; + const char *const path_end = path.data() + path.size(); std::size_t variable_index = 0; - // Skip leading slash - if (position < path_end && *position == '/') { - ++position; - } - while (true) { - // Extract segment const char *segment_start = position; while (position < path_end && *position != '/') { ++position; } - const auto segment_length = static_cast(position - segment_start); - // Empty segment (from double slash or trailing slash) doesn't match - if (segment_length == 0) { - return finalize_match(otherwise_context, 0, 0); - } - const auto &node = nodes[current_node]; const auto node_count = header->node_count; - // Try literal children first + std::uint32_t literal_match = NO_CHILD; if (node.first_literal_child != NO_CHILD) { if (node.first_literal_child >= node_count || node.literal_child_count > node_count - node.first_literal_child) { return finalize_match(otherwise_context, 0, 0); } - - const auto literal_match = binary_search_literal_children( + literal_match = binary_search_literal_children( nodes, string_table, string_table_size, node.first_literal_child, node.literal_child_count, segment_start, segment_length); - if (literal_match != NO_CHILD) { - current_node = literal_match; - if (position >= path_end) { - break; - } - ++position; - continue; - } } - // Fall back to variable child - if (node.variable_child != NO_CHILD) { + if (literal_match != NO_CHILD) { + current_node = literal_match; + } else if (segment_length > 0 && node.variable_child != NO_CHILD) { if (node.variable_child >= node_count || variable_index > std::numeric_limits::max()) { @@ -592,8 +551,6 @@ auto URITemplateRouterView::match( return finalize_match(otherwise_context, 0, 0); } - // Both Expansion and OptionalExpansion consume the rest of the path - // verbatim if (is_expansion_type(variable_node.type)) { const auto remaining_length = static_cast(path_end - segment_start); @@ -605,22 +562,20 @@ auto URITemplateRouterView::match( variable_node.context); } - // Regular variable - match single segment callback(static_cast(variable_index), {string_table + variable_node.string_offset, variable_node.string_length}, {segment_start, segment_length}); ++variable_index; current_node = node.variable_child; - if (position >= path_end) { - break; - } - ++position; - continue; + } else { + return finalize_match(otherwise_context, 0, 0); } - // No match - return finalize_match(otherwise_context, 0, 0); + if (position >= path_end) { + break; + } + ++position; } const auto &final_node = nodes[current_node]; diff --git a/vendor/core/src/lang/io/CMakeLists.txt b/vendor/core/src/lang/io/CMakeLists.txt index f1c3005ae..b1a212c9f 100644 --- a/vendor/core/src/lang/io/CMakeLists.txt +++ b/vendor/core/src/lang/io/CMakeLists.txt @@ -1,6 +1,6 @@ sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME io - PRIVATE_HEADERS atomic.h binary.h error.h fileview.h temporary.h - SOURCES io.cc io_atomic.cc io_binary.cc io_fileview.cc io_temporary.cc) + PRIVATE_HEADERS atomic.h binary.h bytestream.h error.h fileview.h temporary.h + SOURCES io.cc io_atomic.cc io_binary.cc io_bytestream.cc io_fileview.cc io_temporary.cc) if(SOURCEMETA_CORE_INSTALL) sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME io) diff --git a/vendor/core/src/lang/io/include/sourcemeta/core/io.h b/vendor/core/src/lang/io/include/sourcemeta/core/io.h index 82632183b..82a2cc6b5 100644 --- a/vendor/core/src/lang/io/include/sourcemeta/core/io.h +++ b/vendor/core/src/lang/io/include/sourcemeta/core/io.h @@ -8,6 +8,7 @@ // NOLINTBEGIN(misc-include-cleaner) #include #include +#include #include #include #include diff --git a/vendor/core/src/lang/io/include/sourcemeta/core/io_bytestream.h b/vendor/core/src/lang/io/include/sourcemeta/core/io_bytestream.h new file mode 100644 index 000000000..fb272f336 --- /dev/null +++ b/vendor/core/src/lang/io/include/sourcemeta/core/io_bytestream.h @@ -0,0 +1,65 @@ +#ifndef SOURCEMETA_CORE_IO_BYTESTREAM_H_ +#define SOURCEMETA_CORE_IO_BYTESTREAM_H_ + +#ifndef SOURCEMETA_CORE_IO_EXPORT +#include +#endif + +#include // std::byte +#include // std::uint8_t +#include // std::initializer_list +#include // std::istringstream, std::ostringstream +#include // std::vector + +namespace sourcemeta::core { + +// Exporting individual members rather than the whole class avoids MSVC +// instantiating std::basic_istringstream / std::basic_ostringstream vbase +// destructors inside this DLL, which would otherwise clash at link time with +// consumer translation units that use these iostream types directly +// (LNK2005). +// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN +#if defined(_MSC_VER) +#pragma warning(disable : 4251 4275) +#endif + +/// @ingroup io +/// An input stream constructed from an inline list of byte values. For +/// example: +/// +/// ```cpp +/// #include +/// +/// sourcemeta::core::InputByteStream stream{0x1f, 0x8b, 0x08, 0x00}; +/// ``` +class InputByteStream : public std::istringstream { +public: + SOURCEMETA_CORE_IO_EXPORT + InputByteStream(std::initializer_list bytes); +}; + +/// @ingroup io +/// An output stream that exposes its accumulated bytes as a byte vector. For +/// example: +/// +/// ```cpp +/// #include +/// #include +/// +/// sourcemeta::core::OutputByteStream stream; +/// stream.put('A'); +/// assert(stream.bytes().size() == 1); +/// ``` +class OutputByteStream : public std::ostringstream { +public: + SOURCEMETA_CORE_IO_EXPORT + auto bytes() const -> std::vector; +}; + +#if defined(_MSC_VER) +#pragma warning(default : 4251 4275) +#endif + +} // namespace sourcemeta::core + +#endif diff --git a/vendor/core/src/lang/io/io_bytestream.cc b/vendor/core/src/lang/io/io_bytestream.cc new file mode 100644 index 000000000..66bcba706 --- /dev/null +++ b/vendor/core/src/lang/io/io_bytestream.cc @@ -0,0 +1,36 @@ +#include + +#include // std::byte +#include // std::uint8_t +#include // std::string + +namespace { + +auto bytes_to_string(std::initializer_list bytes) -> std::string { + std::string result; + result.reserve(bytes.size()); + for (const auto byte : bytes) { + result.push_back(static_cast(byte)); + } + return result; +} + +} // namespace + +namespace sourcemeta::core { + +InputByteStream::InputByteStream(std::initializer_list bytes) + : std::istringstream{bytes_to_string(bytes)} {} + +auto OutputByteStream::bytes() const -> std::vector { + const auto contents{this->str()}; + std::vector result; + result.reserve(contents.size()); + for (const auto character : contents) { + result.push_back( + static_cast(static_cast(character))); + } + return result; +} + +} // namespace sourcemeta::core diff --git a/vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_parse.h b/vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_parse.h index c30def5f9..78b76d174 100644 --- a/vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_parse.h +++ b/vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_parse.h @@ -5,8 +5,8 @@ #include #endif -#include // std::int64_t, std::uint32_t, std::uint64_t -#include // std::optional +#include // std::int64_t, std::uint16_t, std::uint32_t, std::uint64_t +#include // std::optional #include // std::string_view namespace sourcemeta::core { @@ -46,6 +46,12 @@ SOURCEMETA_CORE_NUMERIC_EXPORT auto to_uint32_t(const std::string_view input, const int base) noexcept -> std::optional; +/// @ingroup numeric +/// Attempt to parse a string as an unsigned 16-bit decimal integer +SOURCEMETA_CORE_NUMERIC_EXPORT +auto to_uint16_t(const std::string_view input) noexcept + -> std::optional; + } // namespace sourcemeta::core #endif diff --git a/vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_util.h b/vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_util.h index 383d8d8a6..8630e9616 100644 --- a/vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_util.h +++ b/vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_util.h @@ -67,6 +67,27 @@ inline constexpr auto is_positive_digit(const char character) -> bool { return character >= '1' && character <= '9'; } +/// @ingroup numeric +/// Check whether the given character is an ASCII hexadecimal digit +/// (`'0'`-`'9'`, `'a'`-`'f'`, `'A'`-`'F'`). For example: +/// +/// ```cpp +/// #include +/// +/// #include +/// +/// assert(sourcemeta::core::is_hex_digit('0')); +/// assert(sourcemeta::core::is_hex_digit('a')); +/// assert(sourcemeta::core::is_hex_digit('F')); +/// assert(!sourcemeta::core::is_hex_digit('g')); +/// assert(!sourcemeta::core::is_hex_digit(' ')); +/// ``` +inline constexpr auto is_hex_digit(const char character) noexcept -> bool { + return (character >= '0' && character <= '9') || + (character >= 'a' && character <= 'f') || + (character >= 'A' && character <= 'F'); +} + /// @ingroup numeric /// Check whether a value fits in an unsigned 8-bit byte template constexpr auto is_byte(const T &value) -> bool { diff --git a/vendor/core/src/lang/numeric/parse.cc b/vendor/core/src/lang/numeric/parse.cc index 0edd740b2..3b9ce0de8 100644 --- a/vendor/core/src/lang/numeric/parse.cc +++ b/vendor/core/src/lang/numeric/parse.cc @@ -67,4 +67,16 @@ auto to_uint32_t(const std::string_view input, const int base) noexcept return value; } +auto to_uint16_t(const std::string_view input) noexcept + -> std::optional { + std::uint16_t value{}; + const auto result = + std::from_chars(input.data(), input.data() + input.size(), value); + if (result.ec != std::errc{} || result.ptr != input.data() + input.size()) { + return std::nullopt; + } + + return value; +} + } // namespace sourcemeta::core diff --git a/vendor/core/src/lang/text/include/sourcemeta/core/text.h b/vendor/core/src/lang/text/include/sourcemeta/core/text.h index 26ffc0616..9c5766bcf 100644 --- a/vendor/core/src/lang/text/include/sourcemeta/core/text.h +++ b/vendor/core/src/lang/text/include/sourcemeta/core/text.h @@ -5,7 +5,9 @@ #include #endif +#include // std::same_as #include // std::size_t +#include // std::filesystem::path #include // std::optional #include // std::ostream #include // std::string @@ -41,7 +43,7 @@ auto to_title_case(std::string &value) -> void; /// @ingroup text /// -/// Return the ASCII lowercase form of a character. Non-ASCII bytes pass +/// Return the ASCII lowercase form of a character. Non-ASCII code units pass /// through unchanged. For example: /// /// ```cpp @@ -52,8 +54,120 @@ auto to_title_case(std::string &value) -> void; /// assert(sourcemeta::core::to_lowercase('a') == 'a'); /// assert(sourcemeta::core::to_lowercase('5') == '5'); /// ``` +template + requires std::same_as || + std::same_as || + std::same_as || + std::same_as +inline constexpr auto to_lowercase(const Character character) noexcept + -> Character { + return (character >= 'A' && character <= 'Z') + ? static_cast(character + ('a' - 'A')) + : character; +} + +/// @ingroup text +/// +/// Convert a string to ASCII lowercase in place. For example: +/// +/// ```cpp +/// #include +/// #include +/// #include +/// +/// std::string value{"Hello WORLD"}; +/// sourcemeta::core::to_lowercase(value); +/// assert(value == "hello world"); +/// ``` +template + requires requires(Character character) { + { to_lowercase(character) } -> std::same_as; + } +inline auto to_lowercase(std::basic_string &value) + -> void { + for (auto &character : value) { + character = to_lowercase(character); + } +} + +/// @ingroup text +/// +/// Convert a filesystem path to ASCII lowercase in place. For example: +/// +/// ```cpp +/// #include +/// #include +/// #include +/// +/// std::filesystem::path value{"/Foo/Bar.JSON"}; +/// sourcemeta::core::to_lowercase(value); +/// assert(value == std::filesystem::path{"/foo/bar.json"}); +/// ``` +SOURCEMETA_CORE_TEXT_EXPORT +auto to_lowercase(std::filesystem::path &value) -> void; + +/// @ingroup text +/// +/// Return whether a character is not ASCII uppercase. For example: +/// +/// ```cpp +/// #include +/// #include +/// +/// assert(sourcemeta::core::is_lowercase('a')); +/// assert(!sourcemeta::core::is_lowercase('A')); +/// assert(sourcemeta::core::is_lowercase('5')); +/// ``` +template + requires std::same_as || + std::same_as || + std::same_as || + std::same_as +inline constexpr auto is_lowercase(const Character character) noexcept -> bool { + return character < 'A' || character > 'Z'; +} + +/// @ingroup text +/// +/// Return whether every code unit of a string is not ASCII uppercase. For +/// example: +/// +/// ```cpp +/// #include +/// #include +/// #include +/// +/// assert(sourcemeta::core::is_lowercase(std::string{"hello"})); +/// assert(!sourcemeta::core::is_lowercase(std::string{"Hello"})); +/// ``` +template + requires requires(const String &value) { + { is_lowercase(*value.begin()) } -> std::same_as; + } +inline auto is_lowercase(const String &value) noexcept -> bool { + for (const auto character : value) { + if (!is_lowercase(character)) { + return false; + } + } + return true; +} + +/// @ingroup text +/// +/// Return whether every code unit of a filesystem path is not ASCII +/// uppercase. For example: +/// +/// ```cpp +/// #include +/// #include +/// #include +/// +/// assert(sourcemeta::core::is_lowercase(std::filesystem::path{"/foo/bar"})); +/// assert(!sourcemeta::core::is_lowercase(std::filesystem::path{"/Foo/Bar"})); +/// ``` SOURCEMETA_CORE_TEXT_EXPORT -auto to_lowercase(const char character) noexcept -> char; +auto is_lowercase(const std::filesystem::path &value) noexcept -> bool; /// @ingroup text /// diff --git a/vendor/core/src/lang/text/text.cc b/vendor/core/src/lang/text/text.cc index 368e91528..6916eec96 100644 --- a/vendor/core/src/lang/text/text.cc +++ b/vendor/core/src/lang/text/text.cc @@ -2,9 +2,11 @@ #include // std::isalpha, std::toupper #include // std::size_t +#include // std::filesystem::path #include // std::optional, std::nullopt +#include // std::string #include // std::string_view -#include // std::pair +#include // std::pair, std::move namespace { @@ -17,10 +19,14 @@ auto is_ascii_whitespace(const char character) noexcept -> bool { namespace sourcemeta::core { -auto to_lowercase(const char character) noexcept -> char { - return (character >= 'A' && character <= 'Z') - ? static_cast(character + 32) - : character; +auto to_lowercase(std::filesystem::path &value) -> void { + auto native{value.native()}; + to_lowercase(native); + value = std::filesystem::path{std::move(native)}; +} + +auto is_lowercase(const std::filesystem::path &value) noexcept -> bool { + return is_lowercase(value.native()); } auto to_title_case(std::string &value) -> void { From e8debc0942b4a320d38db23e2c5fe392ba3a1cb3 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 8 Jun 2026 16:12:45 -0400 Subject: [PATCH 2/2] Fix Signed-off-by: Juan Cruz Viotti --- test/runtime/encode_any_test.cc | 1163 +++++-------------------------- 1 file changed, 181 insertions(+), 982 deletions(-) diff --git a/test/runtime/encode_any_test.cc b/test/runtime/encode_any_test.cc index 066ed0ab0..3316bd2e6 100644 --- a/test/runtime/encode_any_test.cc +++ b/test/runtime/encode_any_test.cc @@ -433,869 +433,133 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_31_xs) { Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x02}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_61_xs) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{std::string(61, 'x')}; - EXPECT_EQ(document.size(), 61); - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0xf2}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_url) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{"https://soundcloud.com/dandymusicnl"}; - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x22}, std::byte{0x68}, std::byte{0x74}, std::byte{0x74}, - std::byte{0x70}, std::byte{0x73}, std::byte{0x3a}, std::byte{0x2f}, - std::byte{0x2f}, std::byte{0x73}, std::byte{0x6f}, std::byte{0x75}, - std::byte{0x6e}, std::byte{0x64}, std::byte{0x63}, std::byte{0x6c}, - std::byte{0x6f}, std::byte{0x75}, std::byte{0x64}, std::byte{0x2e}, - std::byte{0x63}, std::byte{0x6f}, std::byte{0x6d}, std::byte{0x2f}, - std::byte{0x64}, std::byte{0x61}, std::byte{0x6e}, std::byte{0x64}, - std::byte{0x79}, std::byte{0x6d}, std::byte{0x75}, std::byte{0x73}, - std::byte{0x69}, std::byte{0x63}, std::byte{0x6e}, std::byte{0x6c}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_128_xs) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{std::string(128, 'x')}; - EXPECT_EQ(document.size(), 128); - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x3f}, std::byte{0x00}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_130_xs) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{std::string(130, 'x')}; - EXPECT_EQ(document.size(), 130); - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x3f}, std::byte{0x02}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_256_xs) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{std::string(256, 'x')}; - EXPECT_EQ(document.size(), 256); - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x47}, std::byte{0x00}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_258_xs) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{std::string(258, 'x')}; - EXPECT_EQ(document.size(), 258); - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x47}, std::byte{0x02}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_512_xs) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{std::string(512, 'x')}; - EXPECT_EQ(document.size(), 512); - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x4f}, std::byte{0x00}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_513_xs) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{std::string(513, 'x')}; - EXPECT_EQ(document.size(), 513); - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x4f}, std::byte{0x01}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); -} - -TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_1024_xs) { - using namespace sourcemeta::jsonbinpack; - sourcemeta::core::JSON document{std::string(1024, 'x')}; - EXPECT_EQ(document.size(), 1024); - sourcemeta::core::OutputByteStream stream{}; - - Encoder encoder{stream}; - encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x57}, std::byte{0x00}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}})); + std::vector expected{std::byte{0x02}}; + expected.insert(expected.end(), 31, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_61_xs) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{std::string(61, 'x')}; + EXPECT_EQ(document.size(), 61); + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + std::vector expected{std::byte{0xf2}}; + expected.insert(expected.end(), 61, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_url) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{"https://soundcloud.com/dandymusicnl"}; + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + const std::vector expected{ + std::byte{0x22}, std::byte{0x68}, std::byte{0x74}, std::byte{0x74}, + std::byte{0x70}, std::byte{0x73}, std::byte{0x3a}, std::byte{0x2f}, + std::byte{0x2f}, std::byte{0x73}, std::byte{0x6f}, std::byte{0x75}, + std::byte{0x6e}, std::byte{0x64}, std::byte{0x63}, std::byte{0x6c}, + std::byte{0x6f}, std::byte{0x75}, std::byte{0x64}, std::byte{0x2e}, + std::byte{0x63}, std::byte{0x6f}, std::byte{0x6d}, std::byte{0x2f}, + std::byte{0x64}, std::byte{0x61}, std::byte{0x6e}, std::byte{0x64}, + std::byte{0x79}, std::byte{0x6d}, std::byte{0x75}, std::byte{0x73}, + std::byte{0x69}, std::byte{0x63}, std::byte{0x6e}, std::byte{0x6c}}; + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_128_xs) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{std::string(128, 'x')}; + EXPECT_EQ(document.size(), 128); + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + std::vector expected{std::byte{0x3f}, std::byte{0x00}}; + expected.insert(expected.end(), 128, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_130_xs) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{std::string(130, 'x')}; + EXPECT_EQ(document.size(), 130); + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + std::vector expected{std::byte{0x3f}, std::byte{0x02}}; + expected.insert(expected.end(), 130, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_256_xs) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{std::string(256, 'x')}; + EXPECT_EQ(document.size(), 256); + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + std::vector expected{std::byte{0x47}, std::byte{0x00}}; + expected.insert(expected.end(), 256, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_258_xs) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{std::string(258, 'x')}; + EXPECT_EQ(document.size(), 258); + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + std::vector expected{std::byte{0x47}, std::byte{0x02}}; + expected.insert(expected.end(), 258, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_512_xs) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{std::string(512, 'x')}; + EXPECT_EQ(document.size(), 512); + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + std::vector expected{std::byte{0x4f}, std::byte{0x00}}; + expected.insert(expected.end(), 512, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_513_xs) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{std::string(513, 'x')}; + EXPECT_EQ(document.size(), 513); + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + std::vector expected{std::byte{0x4f}, std::byte{0x01}}; + expected.insert(expected.end(), 513, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); +} + +TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__string_1024_xs) { + using namespace sourcemeta::jsonbinpack; + sourcemeta::core::JSON document{std::string(1024, 'x')}; + EXPECT_EQ(document.size(), 1024); + sourcemeta::core::OutputByteStream stream{}; + + Encoder encoder{stream}; + encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); + std::vector expected{std::byte{0x57}, std::byte{0x00}}; + expected.insert(expected.end(), 1024, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); } TEST(JSONBinPack_Encoder, @@ -1307,25 +571,9 @@ TEST(JSONBinPack_Encoder, Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x01}, std::byte{0x01}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}})); + std::vector expected{std::byte{0x01}, std::byte{0x01}}; + expected.insert(expected.end(), 62, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); } TEST(JSONBinPack_Encoder, @@ -1337,26 +585,9 @@ TEST(JSONBinPack_Encoder, Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x01}, std::byte{0x02}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}})); + std::vector expected{std::byte{0x01}, std::byte{0x02}}; + expected.insert(expected.end(), 63, std::byte{0x78}); + EXPECT_EQ(stream.bytes(), expected); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__foo_true_2000) { @@ -1411,18 +642,9 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_31) { Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x04}, std::byte{0x00}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}})); + std::vector expected{std::byte{0x04}, std::byte{0x00}}; + expected.insert(expected.end(), 31, std::byte{0x0f}); + EXPECT_EQ(stream.bytes(), expected); } TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_32) { @@ -1437,18 +659,9 @@ TEST(JSONBinPack_Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__array_32) { Encoder encoder{stream}; encoder.ANY_PACKED_TYPE_TAG_BYTE_PREFIX(document, {}); - EXPECT_EQ( - stream.bytes(), - (std::vector{ - std::byte{0x04}, std::byte{0x01}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, std::byte{0x0f}, - std::byte{0x0f}, std::byte{0x0f}})); + std::vector expected{std::byte{0x04}, std::byte{0x01}}; + expected.insert(expected.end(), 32, std::byte{0x0f}); + EXPECT_EQ(stream.bytes(), expected); } TEST(JSONBinPack_Encoder, @@ -1664,62 +877,48 @@ TEST(JSONBinPack_Encoder, // Deal with object property non-determinism if (document.as_object().cbegin()->first == "foo") { - EXPECT_EQ(stream.bytes(), - (std::vector{ - std::byte{0x1b}, std::byte{0x04}, std::byte{0x66}, - std::byte{0x6f}, std::byte{0x6f}, std::byte{0x01}, - std::byte{0x01}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x04}, std::byte{0x62}, std::byte{0x61}, - std::byte{0x72}, std::byte{0x00}, std::byte{0x01}, - std::byte{0x44}})); + const std::vector expected{ + std::byte{0x1b}, std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x01}, std::byte{0x01}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x04}, std::byte{0x62}, std::byte{0x61}, + std::byte{0x72}, std::byte{0x00}, std::byte{0x01}, std::byte{0x44}}; + EXPECT_EQ(stream.bytes(), expected); } else { - EXPECT_EQ(stream.bytes(), - (std::vector{ - std::byte{0x1b}, std::byte{0x04}, std::byte{0x62}, - std::byte{0x61}, std::byte{0x72}, std::byte{0x01}, - std::byte{0x01}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, - std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, - std::byte{0x6f}, std::byte{0x00}, std::byte{0x01}, - std::byte{0x44}})); + const std::vector expected{ + std::byte{0x1b}, std::byte{0x04}, std::byte{0x62}, std::byte{0x61}, + std::byte{0x72}, std::byte{0x01}, std::byte{0x01}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, std::byte{0x78}, + std::byte{0x78}, std::byte{0x04}, std::byte{0x66}, std::byte{0x6f}, + std::byte{0x6f}, std::byte{0x00}, std::byte{0x01}, std::byte{0x44}}; + EXPECT_EQ(stream.bytes(), expected); } }