1c5f01b2fSopenharmony_ci//     __ _____ _____ _____
2c5f01b2fSopenharmony_ci//  __|  |   __|     |   | |  JSON for Modern C++ (supporting code)
3c5f01b2fSopenharmony_ci// |  |  |__   |  |  | | | |  version 3.11.2
4c5f01b2fSopenharmony_ci// |_____|_____|_____|_|___|  https://github.com/nlohmann/json
5c5f01b2fSopenharmony_ci//
6c5f01b2fSopenharmony_ci// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
7c5f01b2fSopenharmony_ci// SPDX-License-Identifier: MIT
8c5f01b2fSopenharmony_ci
9c5f01b2fSopenharmony_ci#include "doctest_compatibility.h"
10c5f01b2fSopenharmony_ci
11c5f01b2fSopenharmony_ci#include "diag.hpp"
12c5f01b2fSopenharmony_ci
13c5f01b2fSopenharmony_ciTEST_CASE("ABI compatible diagnostics")
14c5f01b2fSopenharmony_ci{
15c5f01b2fSopenharmony_ci    SECTION("basic_json size")
16c5f01b2fSopenharmony_ci    {
17c5f01b2fSopenharmony_ci        // basic_json with diagnostics is larger because of added data members
18c5f01b2fSopenharmony_ci        CHECK(json_sizeof_diag_on() == json_sizeof_diag_on_explicit());
19c5f01b2fSopenharmony_ci        CHECK(json_sizeof_diag_off() == json_sizeof_diag_off_explicit());
20c5f01b2fSopenharmony_ci        CHECK(json_sizeof_diag_on() > json_sizeof_diag_off());
21c5f01b2fSopenharmony_ci    }
22c5f01b2fSopenharmony_ci
23c5f01b2fSopenharmony_ci    SECTION("basic_json at")
24c5f01b2fSopenharmony_ci    {
25c5f01b2fSopenharmony_ci        // accessing a nonexistent key throws different exception with diagnostics
26c5f01b2fSopenharmony_ci        CHECK_THROWS_WITH(json_at_diag_on(), "[json.exception.out_of_range.403] (/foo) key 'bar' not found");
27c5f01b2fSopenharmony_ci        CHECK_THROWS_WITH(json_at_diag_off(), "[json.exception.out_of_range.403] key 'bar' not found");
28c5f01b2fSopenharmony_ci    }
29c5f01b2fSopenharmony_ci}
30