mirror of
https://github.com/nlohmann/json.git
synced 2026-05-16 03:05:23 +00:00
Make std::filesystem::path conversion to/from UTF-8 encoded string explicit (#4631)
* Make std::filesystem::path conversion to/from UTF-8 encoded JSON string explicit. Signed-off-by: Richard Musil <risa2000x@gmail.com> * Experimental: Changing C++ standard detection logic to accommodate potential corner cases. Signed-off-by: Richard Musil <risa2000x@gmail.com> * Drop C++ standard tests for compilers which do not implement required features. Signed-off-by: Richard Musil <risa2000x@gmail.com> * Drop C++ standard tests for MSVC versions which do not implement required features. Signed-off-by: Richard Musil <risa2000x@gmail.com> --------- Signed-off-by: Richard Musil <risa2000x@gmail.com> Co-authored-by: Richard Musil <risa2000x@gmail.com>
This commit is contained in:
@@ -1658,6 +1658,31 @@ TEST_CASE("JSON to enum mapping")
|
||||
}
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
TEST_CASE("std::filesystem::path")
|
||||
{
|
||||
SECTION("ascii")
|
||||
{
|
||||
json const j_string = "Path";
|
||||
auto p = j_string.template get<nlohmann::detail::std_fs::path>();
|
||||
json const j_path = p;
|
||||
|
||||
CHECK(j_path.template get<std::string>() ==
|
||||
j_string.template get<std::string>());
|
||||
}
|
||||
|
||||
SECTION("utf-8")
|
||||
{
|
||||
json const j_string = "P\xc4\x9b\xc5\xa1ina";
|
||||
auto p = j_string.template get<nlohmann::detail::std_fs::path>();
|
||||
json const j_path = p;
|
||||
|
||||
CHECK(j_path.template get<std::string>() ==
|
||||
j_string.template get<std::string>());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
||||
TEST_CASE("std::optional")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user