[String] Allow using Java style %[arg$] prefix in sprintf.

This commit is contained in:
Pāvels Nadtočajevs 2026-02-13 23:43:15 +02:00
parent be587f3a2d
commit f69edf810e
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
2 changed files with 76 additions and 30 deletions

View file

@ -1296,6 +1296,15 @@ TEST_CASE("[String] sprintf") {
REQUIRE(error == false);
CHECK(output == String("fish 99.990 frog"));
///// Argument indices.
format = "fish %2$d frog %1$s xx";
args.clear();
args.push_back("test");
args.push_back(5);
output = format.sprintf(args, &error);
REQUIRE(error == false);
CHECK(output == String("fish 5 frog test xx"));
///// Errors
// More formats than arguments.