[String] Fix string conversion for -0.0 float values.

This commit is contained in:
bruvzg
2023-09-05 09:31:29 +03:00
parent e7208420bc
commit 2b3bbde6da
2 changed files with 21 additions and 5 deletions

View File

@@ -805,6 +805,22 @@ TEST_CASE("[String] sprintf") {
REQUIRE(error == false);
CHECK(output == String("fish +99.990000 frog"));
// Real with sign (negative zero).
format = "fish %+f frog";
args.clear();
args.push_back(-0.0);
output = format.sprintf(args, &error);
REQUIRE(error == false);
CHECK(output == String("fish -0.000000 frog"));
// Real with sign (positive zero).
format = "fish %+f frog";
args.clear();
args.push_back(0.0);
output = format.sprintf(args, &error);
REQUIRE(error == false);
CHECK(output == String("fish +0.000000 frog"));
// Real with 1 decimal.
format = "fish %.1f frog";
args.clear();