mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-14 06:00:15 +02:00
Dump the entire json library in
This commit is contained in:
19
source/Irrlicht/lib/json/tests/abi/diag/CMakeLists.txt
Normal file
19
source/Irrlicht/lib/json/tests/abi/diag/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
# test linking library built with different JSON_DIAGNOSTICS setting
|
||||
# into the same executable
|
||||
|
||||
# compile code using JSON_DIAGNOSTICS=1
|
||||
add_library(abi_compat_diag_on STATIC diag_on.cpp)
|
||||
target_link_libraries(abi_compat_diag_on PUBLIC abi_compat_common)
|
||||
|
||||
# compile code using JSON_DIAGNOSTICS=0
|
||||
add_library(abi_compat_diag_off STATIC diag_off.cpp)
|
||||
target_link_libraries(abi_compat_diag_off PUBLIC abi_compat_common)
|
||||
|
||||
# build test executable and add test
|
||||
add_executable(abi_compat_diag diag.cpp)
|
||||
target_link_libraries(abi_compat_diag PRIVATE
|
||||
abi_compat_main abi_compat_diag_on abi_compat_diag_off)
|
||||
|
||||
add_test(
|
||||
NAME test-abi_compat_diag
|
||||
COMMAND abi_compat_diag ${DOCTEST_TEST_FILTER})
|
29
source/Irrlicht/lib/json/tests/abi/diag/diag.cpp
Normal file
29
source/Irrlicht/lib/json/tests/abi/diag/diag.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++ (supporting code)
|
||||
// | | |__ | | | | | | version 3.11.2
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#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");
|
||||
}
|
||||
}
|
20
source/Irrlicht/lib/json/tests/abi/diag/diag.hpp
Normal file
20
source/Irrlicht/lib/json/tests/abi/diag/diag.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++ (supporting code)
|
||||
// | | |__ | | | | | | version 3.11.2
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
std::size_t json_sizeof_diag_on();
|
||||
std::size_t json_sizeof_diag_on_explicit();
|
||||
|
||||
std::size_t json_sizeof_diag_off();
|
||||
std::size_t json_sizeof_diag_off_explicit();
|
||||
|
||||
void json_at_diag_on();
|
||||
void json_at_diag_off();
|
30
source/Irrlicht/lib/json/tests/abi/diag/diag_off.cpp
Normal file
30
source/Irrlicht/lib/json/tests/abi/diag/diag_off.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++ (supporting code)
|
||||
// | | |__ | | | | | | version 3.11.2
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#undef JSON_DIAGNOSTICS
|
||||
#define JSON_DIAGNOSTICS 0
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "diag.hpp"
|
||||
|
||||
std::size_t json_sizeof_diag_off()
|
||||
{
|
||||
return sizeof(nlohmann::json);
|
||||
}
|
||||
|
||||
std::size_t json_sizeof_diag_off_explicit()
|
||||
{
|
||||
return sizeof(::NLOHMANN_JSON_NAMESPACE::json);
|
||||
}
|
||||
|
||||
void json_at_diag_off()
|
||||
{
|
||||
using nlohmann::json;
|
||||
json j = json{{"foo", json::object()}};
|
||||
j.at(json::json_pointer("/foo/bar"));
|
||||
}
|
30
source/Irrlicht/lib/json/tests/abi/diag/diag_on.cpp
Normal file
30
source/Irrlicht/lib/json/tests/abi/diag/diag_on.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++ (supporting code)
|
||||
// | | |__ | | | | | | version 3.11.2
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#undef JSON_DIAGNOSTICS
|
||||
#define JSON_DIAGNOSTICS 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "diag.hpp"
|
||||
|
||||
std::size_t json_sizeof_diag_on()
|
||||
{
|
||||
return sizeof(nlohmann::json);
|
||||
}
|
||||
|
||||
std::size_t json_sizeof_diag_on_explicit()
|
||||
{
|
||||
return sizeof(::NLOHMANN_JSON_NAMESPACE::json);
|
||||
}
|
||||
|
||||
void json_at_diag_on()
|
||||
{
|
||||
using nlohmann::json;
|
||||
json j = json{{"foo", json::object()}};
|
||||
j.at(json::json_pointer("/foo/bar"));
|
||||
}
|
Reference in New Issue
Block a user