mirror of
https://github.com/nlohmann/json.git
synced 2025-01-05 13:14:56 +08:00
d909f80960
* Add versioned inline namespace Add a versioned inline namespace to prevent ABI issues when linking code using multiple library versions. * Add namespace macros * Encode ABI information in inline namespace Add _diag suffix to inline namespace if JSON_DIAGNOSTICS is enabled, and _ldvcmp suffix if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON is enabled. * Move ABI-affecting macros into abi_macros.hpp * Move std_fs namespace definition into std_fs.hpp * Remove std_fs namespace from unit test * Format more files in tests directory * Add unit tests * Update documentation * Fix GDB pretty printer * fixup! Add namespace macros * Derive ABI prefix from NLOHMANN_JSON_VERSION_*
22 lines
771 B
C++
22 lines
771 B
C++
#include "doctest_compatibility.h"
|
|
|
|
#include "diag.hpp"
|
|
|
|
TEST_CASE("ABI compatible diagnostics")
|
|
{
|
|
SECTION("basic_json size")
|
|
{
|
|
// basic_json with diagnostics is larger because of added data members
|
|
CHECK(json_sizeof_diag_on() == json_sizeof_diag_on_explicit());
|
|
CHECK(json_sizeof_diag_off() == json_sizeof_diag_off_explicit());
|
|
CHECK(json_sizeof_diag_on() > json_sizeof_diag_off());
|
|
}
|
|
|
|
SECTION("basic_json at")
|
|
{
|
|
// accessing a nonexistent key throws different exception with diagnostics
|
|
CHECK_THROWS_WITH(json_at_diag_on(), "[json.exception.out_of_range.403] (/foo) key 'bar' not found");
|
|
CHECK_THROWS_WITH(json_at_diag_off(), "[json.exception.out_of_range.403] key 'bar' not found");
|
|
}
|
|
}
|