📝 overwork project infrastructure

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-06-28 22:16:57 +02:00
parent c37f82e563
commit 2063ac0a26
24 changed files with 206 additions and 118 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13...3.14)
cmake_minimum_required(VERSION 3.13...4.0)
option(JSON_Valgrind "Execute test suite with Valgrind." OFF)
option(JSON_FastTests "Skip expensive/slow tests." OFF)
@@ -148,9 +148,9 @@ message(STATUS "${msg}")
# *DO* use json_test_set_test_options() above this line
json_test_should_build_32bit_test(json_32bit_test json_32bit_test_only "${JSON_32bitTest}")
file(GLOB files src/unit-*.cpp)
file(GLOB files CONFIGURE_DEPENDS src/unit-*.cpp)
if(json_32bit_test_only)
set(files src/unit-32bit.cpp)
set(files src/unit-32bit.cpp)
elseif(NOT json_32bit_test)
list(FILTER files EXCLUDE REGEX src/unit-32bit.cpp)
endif()
+3 -7
View File
@@ -7,13 +7,9 @@ set(NLOHMANN_JSON_BUILD_MODULES ON CACHE BOOL "Enable nlohmann.json module suppo
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../.. ${CMAKE_CURRENT_BINARY_DIR}/tests)
add_executable(json_test main.cpp)
target_link_libraries(json_test
PRIVATE
target_link_libraries(json_test
PRIVATE
nlohmann_json_modules
)
target_compile_definitions(json_test
PRIVATE NLOHMANN_JSON_BUILD_MODULES
)
target_compile_features(json_test PUBLIC cxx_std_20)
target_compile_features(json_test PRIVATE cxx_std_20)
+44 -1
View File
@@ -8,7 +8,50 @@
import nlohmann.json;
#include <sstream>
#include <string>
using namespace nlohmann::literals;
// Exercise each name exported by the nlohmann.json module so that a missing or
// broken export is caught at compile time. This target is only built (not run)
// by the ci_module_cpp20 CI job, so the checks are primarily compile-time; the
// return value additionally validates them if the binary is executed.
int main()
{
nlohmann::json j;
// basic_json / json: parsing and value access
nlohmann::json j = nlohmann::json::parse(R"({"a": 1, "list": [1, 2, 3]})");
const int a = j["a"].get<int>();
// json_pointer and operator""_json_pointer
nlohmann::json_pointer<std::string> ptr = "/list/2"_json_pointer;
const int last = j[ptr].get<int>();
// operator""_json literal
const nlohmann::json lit = R"([1, 2, 3])"_json;
// ordered_json
nlohmann::ordered_json oj;
oj["b"] = 2;
const int b = oj["b"].get<int>();
// ordered_map alias
nlohmann::ordered_map<std::string, int> m;
m["x"] = 1;
// adl_serializer (reference the exported template)
using serializer = nlohmann::adl_serializer<int, void>;
static_cast<void>(sizeof(serializer));
// to_string
const std::string dumped = nlohmann::to_string(j);
// operator<< (hidden friend, reached via ADL through the module)
std::ostringstream os;
os << j << oj << lit;
// use every result so the references cannot be optimized away
return (a == 1 && last == 3 && b == 2 && lit.size() == 3
&& m.size() == 1 && !dumped.empty() && !os.str().empty())
? 0 : 1;
}