-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e6d361
commit c27d0d2
Showing
11 changed files
with
22,288 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
add_library(abi_compat_common INTERFACE) | ||
target_compile_definitions(abi_compat_common INTERFACE | ||
DOCTEST_CONFIG_SUPER_FAST_ASSERTS | ||
JSON_TEST_KEEP_MACROS) | ||
target_compile_features(abi_compat_common INTERFACE cxx_std_11) | ||
target_compile_options(abi_compat_common INTERFACE | ||
$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>> | ||
# MSVC: Force to always compile with W4 | ||
$<$<CXX_COMPILER_ID:MSVC>:/W4> | ||
|
||
# https://github.com/nlohmann/json/pull/3229 | ||
$<$<CXX_COMPILER_ID:Intel>:-diag-disable=2196> | ||
|
||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated;-Wno-float-equal> | ||
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations> | ||
$<$<CXX_COMPILER_ID:Intel>:-diag-disable=1786>) | ||
target_include_directories(abi_compat_common INTERFACE | ||
../thirdparty/doctest | ||
include) | ||
target_link_libraries(abi_compat_common INTERFACE ${NLOHMANN_JSON_TARGET_NAME}) | ||
|
||
add_library(abi_compat_main STATIC main.cpp) | ||
target_link_libraries(abi_compat_main PUBLIC abi_compat_common) | ||
|
||
add_executable(abi_compat_pre_inline_ns | ||
use_v3_10_5.cpp | ||
use_this.cpp | ||
) | ||
target_link_libraries(abi_compat_pre_inline_ns PRIVATE abi_compat_main) | ||
add_test( | ||
NAME test-abi_compat_pre_inline_ns | ||
COMMAND abi_compat_pre_inline_ns ${DOCTEST_TEST_FILTER}) | ||
|
||
add_library(abi_compat_diag_on STATIC diag_on.cpp) | ||
target_link_libraries(abi_compat_diag_on PUBLIC abi_compat_common) | ||
|
||
add_library(abi_compat_diag_off STATIC diag_off.cpp) | ||
target_link_libraries(abi_compat_diag_off PUBLIC abi_compat_common) | ||
|
||
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "doctest_compatibility.h" | ||
|
||
#include "diag.hpp" | ||
|
||
TEST_CASE("ABI compatible diagnostics") | ||
{ | ||
SECTION("basic_json size") | ||
{ | ||
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") | ||
{ | ||
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#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")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#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")); | ||
} |
Oops, something went wrong.