From c2bd9cf7a1461c18be0bdf8728d349502a372104 Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Thu, 23 May 2024 10:29:54 -0400 Subject: [PATCH] ubuntu tests --- .github/workflows/ubuntu.yml | 44 +++++- include/jsoncons/json_object.hpp | 30 ++++ test/CMakeLists.txt | 256 +++++++++++++++---------------- 3 files changed, 198 insertions(+), 132 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 097b8ae9c..5b4f36fd9 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -6,6 +6,38 @@ permissions: contents: read jobs: + github_default_compiler: + strategy: + fail-fast: false + matrix: + compiler: + - g++-9 + - g++-10 + - g++-11 + - g++-12 + - clang++-13 + - clang++-14 + build_type: [Debug, Release] + + runs-on: ubuntu-latest + + env: + CXX: ${{ matrix.compiler }} + + steps: + - uses: actions/checkout@v3 + - name: cmake + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On + env: + CC: gcc-10 + CXX: g++-10 + + - working-directory: build/ + run: cmake --build . --config ubuntu-latest + + - working-directory: build/ + run: ctest -C ubuntu-latest --output-on-failure + gcc_build: runs-on: ubuntu-latest @@ -150,9 +182,11 @@ jobs: - name: cmake run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On - name: build - run: cmake --build build + working-directory: build/ + run: cmake --build . - name: test - run: cd build ; ctest --output-on-failure + working-directory: build/ + run: ctest --output-on-failure ci_test_compilers_gcc2: runs-on: ubuntu-latest @@ -167,9 +201,11 @@ jobs: - name: cmake run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On - name: build - run: cmake --build build + working-directory: build/ + run: cmake --build . - name: test - run: cd build ; ctest --output-on-failure + working-directory: build/ + run: ctest --output-on-failure ci_test_compilers_clang: runs-on: ubuntu-latest diff --git a/include/jsoncons/json_object.hpp b/include/jsoncons/json_object.hpp index b965636c6..c6da55642 100644 --- a/include/jsoncons/json_object.hpp +++ b/include/jsoncons/json_object.hpp @@ -214,6 +214,36 @@ namespace jsoncons { } }; + // Structured Bindings Support + // See https://blog.tartanllama.xyz/structured-bindings/ + template::type = 0> + auto get(const key_value& i) -> decltype(i.key()) + { + return i.key(); + } + // Structured Bindings Support + // See https://blog.tartanllama.xyz/structured-bindings/ + template::type = 0> + auto get(const key_value& i) -> decltype(i.value()) + { + return i.value(); + } + +} // jsoncons + +namespace std +{ + template + class tuple_size> + : public std::integral_constant {}; + + template struct tuple_element<0, jsoncons::key_value> { using type = Key; }; + template struct tuple_element<1, jsoncons::key_value> { using type = Value; }; + +} // namespace std + +namespace jsoncons { + template struct get_key_value { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index de875694e..fec5b6617 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -59,134 +59,134 @@ endif() target_include_directories (catch INTERFACE ${CATCH_INCLUDE_DIR}) add_executable(unit_tests - bson/src/bson_cursor_tests.cpp - bson/src/bson_encoder_tests.cpp - bson/src/bson_reader_tests.cpp - bson/src/bson_decimal128_tests.cpp - bson/src/bson_oid_tests.cpp - bson/src/bson_test_suite.cpp - bson/src/encode_decode_bson_tests.cpp - cbor/src/cbor_bitset_traits_tests.cpp - cbor/src/cbor_cursor_tests.cpp - cbor/src/cbor_event_reader_tests.cpp - cbor/src/cbor_encoder_tests.cpp - cbor/src/cbor_event_visitor_tests.cpp - cbor/src/cbor_reader_tests.cpp - cbor/src/cbor_tests.cpp - cbor/src/cbor_typed_array_tests.cpp - cbor/src/decode_cbor_tests.cpp - cbor/src/encode_cbor_tests.cpp - csv/src/csv_cursor_tests.cpp - csv/src/csv_subfield_tests.cpp - csv/src/csv_tests.cpp - csv/src/encode_decode_csv_tests.cpp - jmespath/src/jmespath_expression_tests.cpp - jmespath/src/jmespath_tests.cpp - mergepatch/src/mergepatch_test_suite.cpp - jsonpatch/src/jsonpatch_test_suite.cpp - jsonpatch/src/jsonpatch_tests.cpp - jsonpath/src/jsonpath_flatten_tests.cpp - jsonpath/src/path_node_tests.cpp - jsonpath/src/json_location_tests.cpp - jsonpath/src/json_location_parser_tests.cpp - jsonpath/src/jsonpath_custom_function_tests.cpp - jsonpath/src/jsonpath_json_query_tests.cpp - jsonpath/src/jsonpath_expression_tests.cpp - jsonpath/src/jsonpath_json_replace_tests.cpp - jsonpath/src/jsonpath_select_paths_tests.cpp - jsonpath/src/jsonpath_test_suite.cpp - jsonpath/src/jsonpath_stateful_allocator_tests.cpp - jsonpointer/src/jsonpointer_flatten_tests.cpp - jsonpointer/src/jsonpointer_tests.cpp - jsonschema/src/abort_early_tests.cpp - jsonschema/src/json_schema_walk_tests.cpp - jsonschema/src/format_validator_tests.cpp - jsonschema/src/validation_report_tests.cpp - jsonschema/src/dynamic_ref_tests.cpp - jsonschema/src/jsonschema_defaults_tests.cpp - jsonschema/src/jsonschema_draft4_tests.cpp - jsonschema/src/jsonschema_draft6_tests.cpp - jsonschema/src/jsonschema_draft7_tests.cpp - jsonschema/src/jsonschema_draft201909_tests.cpp - jsonschema/src/jsonschema_draft202012_tests.cpp - jsonschema/src/schema_version_tests.cpp - msgpack/src/decode_msgpack_tests.cpp - msgpack/src/encode_msgpack_tests.cpp - msgpack/src/msgpack_bitset_traits_tests.cpp - msgpack/src/msgpack_cursor_tests.cpp - msgpack/src/msgpack_event_reader_tests.cpp - msgpack/src/msgpack_encoder_tests.cpp - msgpack/src/msgpack_tests.cpp - msgpack/src/msgpack_timestamp_tests.cpp - corelib/src/bigint_tests.cpp - corelib/src/source_adaptor_tests.cpp - corelib/src/byte_string_tests.cpp - corelib/src/value_converter_tests.cpp - corelib/src/decode_traits_tests.cpp - corelib/src/detail/optional_tests.cpp - corelib/src/detail/span_tests.cpp - corelib/src/detail/string_view_tests.cpp - corelib/src/detail/heap_string_tests.cpp - corelib/src/detail/to_integer_tests.cpp - corelib/src/double_round_trip_tests.cpp - corelib/src/double_to_string_tests.cpp - corelib/src/dtoa_tests.cpp - corelib/src/encode_decode_json_tests.cpp - corelib/src/encode_traits_tests.cpp - corelib/src/error_recovery_tests.cpp - corelib/src/json_array_tests.cpp - corelib/src/json_as_tests.cpp - corelib/src/json_bitset_traits_tests.cpp - corelib/src/json_checker_tests.cpp - corelib/src/json_comparator_tests.cpp - corelib/src/json_const_pointer_tests.cpp - corelib/src/json_constructor_tests.cpp - corelib/src/json_cursor_tests.cpp - corelib/src/json_encoder_tests.cpp - corelib/src/json_exception_tests.cpp - corelib/src/json_filter_tests.cpp - corelib/src/json_in_place_update_tests.cpp - corelib/src/json_integer_tests.cpp - corelib/src/json_less_tests.cpp - corelib/src/json_line_split_tests.cpp - corelib/src/json_literal_operator_tests.cpp - corelib/src/json_object_tests.cpp - corelib/src/ojson_object_tests.cpp - corelib/src/json_options_tests.cpp - corelib/src/json_parse_error_tests.cpp - corelib/src/json_parser_position_tests.cpp - corelib/src/json_parser_tests.cpp - corelib/src/json_proxy_tests.cpp - corelib/src/json_push_back_tests.cpp - corelib/src/json_reader_exception_tests.cpp - corelib/src/json_reader_tests.cpp - corelib/src/json_storage_tests.cpp - corelib/src/json_swap_tests.cpp - corelib/src/json_traits_macro_functional_tests.cpp - corelib/src/json_traits_macro_tests.cpp - corelib/src/json_traits_macro_limit_tests.cpp - corelib/src/json_traits_name_macro_tests.cpp - corelib/src/json_type_traits_chrono_tests.cpp - corelib/src/json_type_traits_container_tests.cpp - corelib/src/json_type_traits_tests.cpp - corelib/src/uri_tests.cpp - corelib/src/json_validation_tests.cpp - corelib/src/jsoncons_tests.cpp - corelib/src/JSONTestSuite_tests.cpp - corelib/src/ojson_tests.cpp - corelib/src/parse_string_tests.cpp - corelib/src/short_string_tests.cpp - corelib/src/source_tests.cpp - corelib/src/staj_iterator_tests.cpp - corelib/src/extension_traits_tests.cpp - corelib/src/polymorphic_allocator_tests.cpp - corelib/src/scoped_allocator_adaptor_tests.cpp - corelib/src/string_to_double_tests.cpp - corelib/src/unicode_conv_tests.cpp - corelib/src/wjson_tests.cpp - ubjson/src/decode_ubjson_tests.cpp - ubjson/src/encode_ubjson_tests.cpp - ubjson/src/ubjson_cursor_tests.cpp + #bson/src/bson_cursor_tests.cpp + #bson/src/bson_encoder_tests.cpp + #bson/src/bson_reader_tests.cpp + #bson/src/bson_decimal128_tests.cpp + #bson/src/bson_oid_tests.cpp + #bson/src/bson_test_suite.cpp + #bson/src/encode_decode_bson_tests.cpp + #cbor/src/cbor_bitset_traits_tests.cpp + #cbor/src/cbor_cursor_tests.cpp + #cbor/src/cbor_event_reader_tests.cpp + #cbor/src/cbor_encoder_tests.cpp + #cbor/src/cbor_event_visitor_tests.cpp + #cbor/src/cbor_reader_tests.cpp + #cbor/src/cbor_tests.cpp + #cbor/src/cbor_typed_array_tests.cpp + #cbor/src/decode_cbor_tests.cpp + #cbor/src/encode_cbor_tests.cpp + #csv/src/csv_cursor_tests.cpp + #csv/src/csv_subfield_tests.cpp + #csv/src/csv_tests.cpp + #csv/src/encode_decode_csv_tests.cpp + #jmespath/src/jmespath_expression_tests.cpp + #jmespath/src/jmespath_tests.cpp + #mergepatch/src/mergepatch_test_suite.cpp + #jsonpatch/src/jsonpatch_test_suite.cpp + #jsonpatch/src/jsonpatch_tests.cpp + #jsonpath/src/jsonpath_flatten_tests.cpp + #jsonpath/src/path_node_tests.cpp + #jsonpath/src/json_location_tests.cpp + #jsonpath/src/json_location_parser_tests.cpp + #jsonpath/src/jsonpath_custom_function_tests.cpp + #jsonpath/src/jsonpath_json_query_tests.cpp + #jsonpath/src/jsonpath_expression_tests.cpp + #jsonpath/src/jsonpath_json_replace_tests.cpp + #jsonpath/src/jsonpath_select_paths_tests.cpp + #jsonpath/src/jsonpath_test_suite.cpp + #jsonpath/src/jsonpath_stateful_allocator_tests.cpp + #jsonpointer/src/jsonpointer_flatten_tests.cpp + #jsonpointer/src/jsonpointer_tests.cpp + #jsonschema/src/abort_early_tests.cpp + #jsonschema/src/json_schema_walk_tests.cpp + #jsonschema/src/format_validator_tests.cpp + #jsonschema/src/validation_report_tests.cpp + #jsonschema/src/dynamic_ref_tests.cpp + #jsonschema/src/jsonschema_defaults_tests.cpp + #jsonschema/src/jsonschema_draft4_tests.cpp + #jsonschema/src/jsonschema_draft6_tests.cpp + #jsonschema/src/jsonschema_draft7_tests.cpp + #jsonschema/src/jsonschema_draft201909_tests.cpp + #jsonschema/src/jsonschema_draft202012_tests.cpp + #jsonschema/src/schema_version_tests.cpp + #msgpack/src/decode_msgpack_tests.cpp + #msgpack/src/encode_msgpack_tests.cpp + #msgpack/src/msgpack_bitset_traits_tests.cpp + #msgpack/src/msgpack_cursor_tests.cpp + #msgpack/src/msgpack_event_reader_tests.cpp + #msgpack/src/msgpack_encoder_tests.cpp + #msgpack/src/msgpack_tests.cpp + #msgpack/src/msgpack_timestamp_tests.cpp + #corelib/src/bigint_tests.cpp + #corelib/src/source_adaptor_tests.cpp + #corelib/src/byte_string_tests.cpp + #corelib/src/value_converter_tests.cpp + #corelib/src/decode_traits_tests.cpp + #corelib/src/detail/optional_tests.cpp + #corelib/src/detail/span_tests.cpp + #corelib/src/detail/string_view_tests.cpp + #corelib/src/detail/heap_string_tests.cpp + #corelib/src/detail/to_integer_tests.cpp + #corelib/src/double_round_trip_tests.cpp + #corelib/src/double_to_string_tests.cpp + #corelib/src/dtoa_tests.cpp + #corelib/src/encode_decode_json_tests.cpp + #corelib/src/encode_traits_tests.cpp + #corelib/src/error_recovery_tests.cpp + #corelib/src/json_array_tests.cpp + #corelib/src/json_as_tests.cpp + #corelib/src/json_bitset_traits_tests.cpp + #corelib/src/json_checker_tests.cpp + #corelib/src/json_comparator_tests.cpp + #corelib/src/json_const_pointer_tests.cpp + #corelib/src/json_constructor_tests.cpp + #corelib/src/json_cursor_tests.cpp + #corelib/src/json_encoder_tests.cpp + #corelib/src/json_exception_tests.cpp + #corelib/src/json_filter_tests.cpp + #corelib/src/json_in_place_update_tests.cpp + #corelib/src/json_integer_tests.cpp + #corelib/src/json_less_tests.cpp + #corelib/src/json_line_split_tests.cpp + #corelib/src/json_literal_operator_tests.cpp + #corelib/src/json_object_tests.cpp + #corelib/src/ojson_object_tests.cpp + #corelib/src/json_options_tests.cpp + #corelib/src/json_parse_error_tests.cpp + #corelib/src/json_parser_position_tests.cpp + #corelib/src/json_parser_tests.cpp + #corelib/src/json_proxy_tests.cpp + #corelib/src/json_push_back_tests.cpp + #corelib/src/json_reader_exception_tests.cpp + #corelib/src/json_reader_tests.cpp + #corelib/src/json_storage_tests.cpp + #corelib/src/json_swap_tests.cpp + #corelib/src/json_traits_macro_functional_tests.cpp + #corelib/src/json_traits_macro_tests.cpp + #corelib/src/json_traits_macro_limit_tests.cpp + #corelib/src/json_traits_name_macro_tests.cpp + #corelib/src/json_type_traits_chrono_tests.cpp + #corelib/src/json_type_traits_container_tests.cpp + #corelib/src/json_type_traits_tests.cpp + #corelib/src/uri_tests.cpp + #corelib/src/json_validation_tests.cpp + #corelib/src/jsoncons_tests.cpp + #corelib/src/JSONTestSuite_tests.cpp + #corelib/src/ojson_tests.cpp + #corelib/src/parse_string_tests.cpp + #corelib/src/short_string_tests.cpp + #corelib/src/source_tests.cpp + #corelib/src/staj_iterator_tests.cpp + #corelib/src/extension_traits_tests.cpp + #corelib/src/polymorphic_allocator_tests.cpp + #corelib/src/scoped_allocator_adaptor_tests.cpp + #corelib/src/string_to_double_tests.cpp + #corelib/src/unicode_conv_tests.cpp + #corelib/src/wjson_tests.cpp + #ubjson/src/decode_ubjson_tests.cpp + #ubjson/src/encode_ubjson_tests.cpp + #ubjson/src/ubjson_cursor_tests.cpp ubjson/src/ubjson_encoder_tests.cpp corelib/src/testmain.cpp )