summaryrefslogtreecommitdiffstats
path: root/tests/core/string/test_string.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/core/string/test_string.h')
-rw-r--r--tests/core/string/test_string.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h
index 659fb003d3..c10ad6e13d 100644
--- a/tests/core/string/test_string.h
+++ b/tests/core/string/test_string.h
@@ -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();