diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9ce1594c1..76ba31d88 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -151,7 +151,7 @@ foreach(file ${files}) $<$>:-Wno-deprecated;-Wno-float-equal> $<$:-Wno-deprecated-declarations> ) - target_include_directories(${testcase} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/utils ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map) + target_include_directories(${testcase} PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map) target_link_libraries(${testcase} PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) if (JSON_Coverage) diff --git a/test/utils/test_utils.hpp b/test/src/test_utils.hpp similarity index 100% rename from test/utils/test_utils.hpp rename to test/src/test_utils.hpp diff --git a/test/src/unit-bson.cpp b/test/src/unit-bson.cpp index 80a8012df..c5a71a3da 100644 --- a/test/src/unit-bson.cpp +++ b/test/src/unit-bson.cpp @@ -35,7 +35,7 @@ using nlohmann::json; #include #include #include -#include +#include "test_utils.hpp" TEST_CASE("BSON") { diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index b0c2b04df..0d55de85e 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -39,7 +39,7 @@ using nlohmann::json; #include #include #include -#include +#include "test_utils.hpp" namespace { @@ -2709,19 +2709,19 @@ TEST_CASE("Tagged values") SECTION("tagged binary") { // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); + json j_binary; + j_binary["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); // convert to CBOR - const auto v = json::to_cbor(j); - CHECK(v == std::vector {0xA1, 0x66, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79, 0xD8, 0x2A, 0x44, 0xCA, 0xFE, 0xBA, 0xBE}); + const auto vec = json::to_cbor(j_binary); + CHECK(vec == std::vector {0xA1, 0x66, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79, 0xD8, 0x2A, 0x44, 0xCA, 0xFE, 0xBA, 0xBE}); // parse error when parsing tagged value - CHECK_THROWS_AS(json::from_cbor(v), json::parse_error); - CHECK_THROWS_WITH(json::from_cbor(v), "[json.exception.parse_error.112] parse error at byte 9: syntax error while parsing CBOR value: invalid byte: 0xD8"); + CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error); + CHECK_THROWS_WITH(json::from_cbor(vec), "[json.exception.parse_error.112] parse error at byte 9: syntax error while parsing CBOR value: invalid byte: 0xD8"); // binary without subtype when tags are ignored - json jb = json::from_cbor(v, true, true, json::cbor_tag_handler_t::ignore); + json jb = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore); CHECK(jb.is_object()); CHECK(jb["binary"].is_binary()); CHECK(!jb["binary"].get_binary().has_subtype()); diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index c3761fb5b..e53a6d595 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -37,7 +37,7 @@ using nlohmann::json; #include #include #include -#include +#include "test_utils.hpp" namespace { diff --git a/test/src/unit-ubjson.cpp b/test/src/unit-ubjson.cpp index 663d8ec1f..7e1a841f1 100644 --- a/test/src/unit-ubjson.cpp +++ b/test/src/unit-ubjson.cpp @@ -36,7 +36,7 @@ using nlohmann::json; #include #include #include -#include +#include "test_utils.hpp" namespace {