mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 19:10:11 +08:00
test: set precision if non-toml float is given
in toml-test encoder test, it passes a large integer with float type. in that case, we used a std::stringstream, so no prec information is stored.
This commit is contained in:
@@ -41,7 +41,7 @@ toml::value convert_to_toml(const nlohmann::json& j)
|
||||
{
|
||||
return f_r.unwrap();
|
||||
}
|
||||
else
|
||||
else // not conform TOML floating-point syntax.
|
||||
{
|
||||
// toml-test converts "inf" into "Inf"
|
||||
if(value == "Inf" || value == "+Inf")
|
||||
@@ -52,9 +52,11 @@ toml::value convert_to_toml(const nlohmann::json& j)
|
||||
{
|
||||
return toml::value(-std::numeric_limits<double>::infinity());
|
||||
}
|
||||
else
|
||||
else // sometimes toml-test uses large int with type:float
|
||||
{
|
||||
return toml::value(toml::detail::from_string<double>(value).unwrap());
|
||||
toml::floating_format_info fmt;
|
||||
fmt.prec = value.size();
|
||||
return toml::value(toml::detail::from_string<double>(value).unwrap(), fmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user