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:
22
source/Irrlicht/lib/json/tests/abi/config/CMakeLists.txt
Normal file
22
source/Irrlicht/lib/json/tests/abi/config/CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
# test the different options to change the namespace
|
||||
|
||||
# test default namespace
|
||||
add_executable(abi_config_default default.cpp)
|
||||
target_link_libraries(abi_config_default PRIVATE abi_compat_main)
|
||||
add_test(
|
||||
NAME test-abi_config_default
|
||||
COMMAND abi_config_default ${DOCTEST_TEST_FILTER})
|
||||
|
||||
# test no version namespace
|
||||
add_executable(abi_config_noversion noversion.cpp)
|
||||
target_link_libraries(abi_config_noversion PRIVATE abi_compat_main)
|
||||
add_test(
|
||||
NAME test-abi_config_noversion
|
||||
COMMAND abi_config_noversion ${DOCTEST_TEST_FILTER})
|
||||
|
||||
# test custom namespace
|
||||
add_executable(abi_config_custom custom.cpp)
|
||||
target_link_libraries(abi_config_custom PRIVATE abi_compat_main)
|
||||
add_test(
|
||||
NAME test-abi_config_custom
|
||||
COMMAND abi_config_custom ${DOCTEST_TEST_FILTER})
|
35
source/Irrlicht/lib/json/tests/abi/config/config.hpp
Normal file
35
source/Irrlicht/lib/json/tests/abi/config/config.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | 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 "doctest.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
|
||||
#define STRINGIZE_EX(x) #x
|
||||
#define STRINGIZE(x) STRINGIZE_EX(x)
|
||||
|
||||
template<typename T>
|
||||
std::string namespace_name(std::string ns, T* /*unused*/ = nullptr) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
#if DOCTEST_MSVC && !DOCTEST_CLANG
|
||||
ns = __FUNCSIG__;
|
||||
#elif !DOCTEST_CLANG
|
||||
ns = __PRETTY_FUNCTION__;
|
||||
#endif
|
||||
std::smatch m;
|
||||
|
||||
// extract the true namespace name from the function signature
|
||||
CAPTURE(ns);
|
||||
CHECK(std::regex_search(ns, m, std::regex("nlohmann(::[a-zA-Z0-9_]+)*::basic_json")));
|
||||
|
||||
return m.str();
|
||||
}
|
33
source/Irrlicht/lib/json/tests/abi/config/custom.cpp
Normal file
33
source/Irrlicht/lib/json/tests/abi/config/custom.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | 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 "config.hpp"
|
||||
|
||||
// define custom namespace
|
||||
#define NLOHMANN_JSON_NAMESPACE nlohmann // this line may be omitted
|
||||
#define NLOHMANN_JSON_NAMESPACE_BEGIN namespace nlohmann {
|
||||
#define NLOHMANN_JSON_NAMESPACE_END }
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
|
||||
TEST_CASE("custom namespace")
|
||||
{
|
||||
// GCC 4.8 fails with regex_error
|
||||
#if !DOCTEST_GCC || DOCTEST_GCC >= DOCTEST_COMPILER(4, 9, 0)
|
||||
SECTION("namespace matches expectation")
|
||||
{
|
||||
std::string expected = "nlohmann::basic_json";
|
||||
|
||||
// fallback for Clang
|
||||
const std::string ns{STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json"};
|
||||
|
||||
CHECK(namespace_name<nlohmann::json>(ns) == expected);
|
||||
}
|
||||
#endif
|
||||
}
|
41
source/Irrlicht/lib/json/tests/abi/config/default.cpp
Normal file
41
source/Irrlicht/lib/json/tests/abi/config/default.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | 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 "config.hpp"
|
||||
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
|
||||
TEST_CASE("default namespace")
|
||||
{
|
||||
// GCC 4.8 fails with regex_error
|
||||
#if !DOCTEST_GCC || DOCTEST_GCC >= DOCTEST_COMPILER(4, 9, 0)
|
||||
SECTION("namespace matches expectation")
|
||||
{
|
||||
std::string expected = "nlohmann::json_abi";
|
||||
|
||||
#if JSON_DIAGNOSTICS
|
||||
expected += "_diag";
|
||||
#endif
|
||||
|
||||
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||
expected += "_ldvcmp";
|
||||
#endif
|
||||
|
||||
expected += "_v" STRINGIZE(NLOHMANN_JSON_VERSION_MAJOR);
|
||||
expected += "_" STRINGIZE(NLOHMANN_JSON_VERSION_MINOR);
|
||||
expected += "_" STRINGIZE(NLOHMANN_JSON_VERSION_PATCH) "::basic_json";
|
||||
|
||||
// fallback for Clang
|
||||
const std::string ns{STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json"};
|
||||
|
||||
CHECK(namespace_name<nlohmann::json>(ns) == expected);
|
||||
}
|
||||
#endif
|
||||
}
|
40
source/Irrlicht/lib/json/tests/abi/config/noversion.cpp
Normal file
40
source/Irrlicht/lib/json/tests/abi/config/noversion.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | 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 "config.hpp"
|
||||
|
||||
#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 1
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
|
||||
TEST_CASE("default namespace without version component")
|
||||
{
|
||||
// GCC 4.8 fails with regex_error
|
||||
#if !DOCTEST_GCC || DOCTEST_GCC >= DOCTEST_COMPILER(4, 9, 0)
|
||||
SECTION("namespace matches expectation")
|
||||
{
|
||||
std::string expected = "nlohmann::json_abi";
|
||||
|
||||
#if JSON_DIAGNOSTICS
|
||||
expected += "_diag";
|
||||
#endif
|
||||
|
||||
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||
expected += "_ldvcmp";
|
||||
#endif
|
||||
|
||||
expected += "::basic_json";
|
||||
|
||||
// fallback for Clang
|
||||
const std::string ns{STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json"};
|
||||
|
||||
CHECK(namespace_name<nlohmann::json>(ns) == expected);
|
||||
}
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user