From 29f8517cf4f83a9df7ccf2430fa632a966e33260 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sun, 16 Jun 2024 20:43:17 +0900 Subject: [PATCH] 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. --- tests/to_toml.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/to_toml.cpp b/tests/to_toml.cpp index a5511bb..0c2f273 100644 --- a/tests/to_toml.cpp +++ b/tests/to_toml.cpp @@ -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::infinity()); } - else + else // sometimes toml-test uses large int with type:float { - return toml::value(toml::detail::from_string(value).unwrap()); + toml::floating_format_info fmt; + fmt.prec = value.size(); + return toml::value(toml::detail::from_string(value).unwrap(), fmt); } } }