summaryrefslogtreecommitdiff
path: root/tests/core
diff options
context:
space:
mode:
authorMarcus Elg <marcusaccounts@yahoo.se>2022-08-24 15:41:31 +0200
committerMarcus Elg <marcusaccounts@yahoo.se>2022-08-25 07:41:21 +0200
commitb21460981d35ede84fd5192c6bbae3b654476e86 (patch)
treef75c4325d3cb8811b84bc11d898ade4373f5c06f /tests/core
parent6e390fa9abf2101f8772c4ef6694471153105636 (diff)
Improve string formatting for %f and %v for inf and nan
Diffstat (limited to 'tests/core')
-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 62d2051eee..5000a5da67 100644
--- a/tests/core/string/test_string.h
+++ b/tests/core/string/test_string.h
@@ -745,6 +745,14 @@ TEST_CASE("[String] sprintf") {
REQUIRE(error == false);
CHECK(output == String("fish 99.990000 frog"));
+ // Real (infinity) left-padded
+ format = "fish %11f frog";
+ args.clear();
+ args.push_back(INFINITY);
+ output = format.sprintf(args, &error);
+ REQUIRE(error == false);
+ CHECK(output == String("fish inf frog"));
+
// Real right-padded.
format = "fish %-11f frog";
args.clear();
@@ -845,6 +853,14 @@ TEST_CASE("[String] sprintf") {
REQUIRE(error == false);
CHECK(output == String("fish ( 19.990000, 1.000000, -2.050000) frog"));
+ // Vector left-padded with inf/nan
+ format = "fish %11v frog";
+ args.clear();
+ args.push_back(Variant(Vector2(INFINITY, NAN)));
+ output = format.sprintf(args, &error);
+ REQUIRE(error == false);
+ CHECK(output == String("fish ( inf, nan) frog"));
+
// Vector right-padded.
format = "fish %-11v frog";
args.clear();