diff --git a/.github/workflows/cpp-internal.yml b/.github/workflows/cpp-internal.yml index 71c94dd8..c03450da 100644 --- a/.github/workflows/cpp-internal.yml +++ b/.github/workflows/cpp-internal.yml @@ -1,18 +1,11 @@ name: C++ Internal - on: schedule: - - cron: 0 1 * * * # Nightly at 01:00 UTC + - cron: 0 1 * * * # Nightly at 01:00 UTC push: branches: - master pull_request: - workflow_dispatch: - inputs: - extra_resolve_options: - description: Extra Resolve Options - required: false - jobs: linux_cmake: timeout-minutes: 45 @@ -47,18 +40,16 @@ jobs: - ${{ matrix.config.runner }} name: ${{ matrix.config.name }} steps: - # This is sometimes needed when running docker builds since these - # sometimes produce files with root ownership - name: Ensure correct owner of repository run: sudo chown -R actions-runner:actions-runner . - name: Checkout source code uses: actions/checkout@v3 - - name: Waf Clean - run: python3 waf clean --no_resolve - name: Waf Configure run: python3 waf configure --git_protocol=git@ --cmake_toolchain=${{ matrix.config.toolchain }} --cmake_verbose - name: Waf Build - run: python3 waf build --run_tests + run: python3 waf build + - name: Waf Run Tests + run: python3 waf --run_tests valgrind: timeout-minutes: 45 @@ -70,41 +61,40 @@ jobs: steps: - name: Ensure correct owner of repository run: sudo chown -R actions-runner:actions-runner . - - name: Checkout source code uses: actions/checkout@v3 - - - name: Waf Clean - run: python3 waf clean --no_resolve - - name: Waf Configure run: python3 waf configure --git_protocol=git@ --cmake_toolchain=./resolve_symlinks/toolchains/gcc-toolchain.cmake --cmake_verbose - - name: Waf Build - run: python3 waf build --run_tests --ctest_valgrind - + run: python3 waf build + - name: Waf Run Tests + run: python3 waf --run_tests --ctest_valgrind zig_toolchain_build: name: Zig Toolchain Build (Docker) runs-on: [self-hosted, vm, ubuntu-current] container: - image: kassany/bookworm-ziglang + image: ghcr.io/steinwurf/build-images/zig-cpp options: --user 0:0 - volumes: - - /root/.ssh:/root/.ssh steps: - name: Checkout source code uses: actions/checkout@v4 - - name: Install dependencies + with: + persist-credentials: false + - name: Configure Github Authentication run: | - apt-get update - apt-get install -y python3 python3-pip git cmake build-essential - - name: Waf Clean - run: python3 waf clean --no_resolve + git config --global credential.helper 'store' + git credential approve < diff --git a/test/src/test_parser.cpp b/test/src/test_parser.cpp index dd2e2890..e4f85acd 100644 --- a/test/src/test_parser.cpp +++ b/test/src/test_parser.cpp @@ -6,6 +6,7 @@ #include #include +#include #include namespace @@ -212,3 +213,44 @@ TEST(test_parser, test_parse_unicode) ASSERT_FALSE((bool)error); ASSERT_EQ(json_string, result.dump_min()); } + +TEST(test_parser, test_parse_object_duplicate_key_non_strict) +{ + std::error_code error; + std::string json_string = "{\"bourne\":1,\"bourne\":2}"; + auto result = bourne::detail::parser::parse(json_string, error); + + ASSERT_FALSE((bool)error); + ASSERT_TRUE(result.is_object()); + ASSERT_TRUE(result.has_key("bourne")); + EXPECT_EQ(2, result["bourne"].to_int()); +} + +TEST(test_parser, test_parse_object_duplicate_key_strict) +{ + std::error_code error; + std::string json_string = "{\"bourne\":1,\"bourne\":2}"; + bourne::json::parse_options options; + options.strict = true; + + auto result = bourne::detail::parser::parse(json_string, options, error); + + EXPECT_EQ(bourne::error::parse_object_duplicate_key, error) + << error.message(); + ASSERT_EQ(bourne::json::null(), result); +} + +TEST(test_parser, test_parse_nested_object_duplicate_key_strict) +{ + std::error_code error; + std::string json_string = + "{\"outer\":{\"bourne\":1,\"bourne\":2},\"ok\":true}"; + bourne::json::parse_options options; + options.strict = true; + + auto result = bourne::json::parse(json_string, options, error); + + EXPECT_EQ(bourne::error::parse_object_duplicate_key, error) + << error.message(); + ASSERT_EQ(bourne::json::null(), result); +}