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