Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
fsandhei committed Mar 19, 2024
1 parent 878745a commit d27adfd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/nlohmann/detail/conversions/from_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void from_json(const BasicJsonType& j, std::optional<T>& opt)
}
else
{
opt = j.template get<T>();
opt.emplace(j.template get<T>());
}
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
#ifdef __has_include
#if __has_include(<version>)
#include <version>
Expand Down Expand Up @@ -4624,7 +4625,7 @@ void from_json(const BasicJsonType& j, std::optional<T>& opt)
}
else
{
opt = j.template get<T>();
opt.emplace(j.template get<T>());
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/src/unit-conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ TEST_CASE("std::optional")
std::optional<std::string> opt_null;

CHECK(json(opt_null) == j_null);
CHECK(std::optional<std::string>(j_null) == std::nullopt);
CHECK(j_null.get<std::optional<std::string>>() == std::nullopt);
}

SECTION("string")
Expand Down

0 comments on commit d27adfd

Please sign in to comment.