From 30b4e13b8b272451a144bcb2ec1138815608e0e0 Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Tue, 5 Apr 2022 09:47:39 +0200 Subject: [PATCH] Restore disabled check for #3070 (except on MSVC) Closes #3377 and #3382. --- include/nlohmann/detail/conversions/from_json.hpp | 3 +-- single_include/nlohmann/json.hpp | 3 +-- test/src/unit-regression2.cpp | 6 ++++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index fbb176879e..207d3e3024 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -464,8 +464,7 @@ void from_json(const BasicJsonType& j, std_fs::path& p) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) { - // Not tested because of #3377 (related #3070) - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); // LCOV_EXCL_LINE + JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); } p = *j.template get_ptr(); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 33a91164c7..3b694e5694 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4279,8 +4279,7 @@ void from_json(const BasicJsonType& j, std_fs::path& p) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) { - // Not tested because of #3377 (related #3070) - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); // LCOV_EXCL_LINE + JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); } p = *j.template get_ptr(); } diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index b8cc5107b5..dd2edb4ff3 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -748,8 +748,10 @@ TEST_CASE("regression tests 2") const auto j_path = j.get(); CHECK(j_path == text_path); - // Disabled pending resolution of #3377 - // CHECK_THROWS_WITH_AS(nlohmann::detail::std_fs::path(json(1)), "[json.exception.type_error.302] type must be string, but is number", json::type_error); +#ifndef _MSC_VER + // works everywhere but on MSVC + CHECK_THROWS_WITH_AS(nlohmann::detail::std_fs::path(json(1)), "[json.exception.type_error.302] type must be string, but is number", json::type_error); +#endif } #endif