diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-03 09:23:12 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-03 09:23:12 +0200 |
commit | cf6978f2869006ca4203d7dc438c5a99de7347f6 (patch) | |
tree | bb66c94cf9105b94c8a694422e6727ddf05266cf /tests | |
parent | adee79d7b544cf304158478970f67211c9695f59 (diff) | |
parent | b21460981d35ede84fd5192c6bbae3b654476e86 (diff) |
Merge pull request #64833 from MarcusElg/naninfprinting
Improve string formatting (%f and %v) for inf and nan
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/string/test_string.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index d97da05c04..969f5fc096 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -740,6 +740,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(); @@ -840,6 +848,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(); |