aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2018-08-21 13:13:13 +0200
committerMarco Paland <marco@paland.com>2018-08-21 13:13:13 +0200
commitbe3047911075b2e917d73451068e0b84373eefb9 (patch)
tree1ea834a5fdc1daeea15a4ea0d8aec22da2113b49 /test
parente6b5331a36a5815cc36a9b2872f29234efee72cb (diff)
downloadprintf-be3047911075b2e917d73451068e0b84373eefb9.tar.gz
printf-be3047911075b2e917d73451068e0b84373eefb9.tar.bz2
printf-be3047911075b2e917d73451068e0b84373eefb9.zip
fix(printf): fix trailing field width in itoa conversion
Fixes #21
Diffstat (limited to 'test')
-rw-r--r--test/test_suite.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_suite.cpp b/test/test_suite.cpp
index 212fbd3..3ecac5f 100644
--- a/test/test_suite.cpp
+++ b/test/test_suite.cpp
@@ -582,6 +582,18 @@ TEST_CASE("width -20", "[]" ) {
test::sprintf(buffer, "%-20c", 'x');
REQUIRE(!strcmp(buffer, "x "));
+
+ test::sprintf(buffer, "|%5d| |%-2d| |%5d|", 9, 9, 9);
+ REQUIRE(!strcmp(buffer, "| 9| |9 | | 9|"));
+
+ test::sprintf(buffer, "|%5d| |%-2d| |%5d|", 10, 10, 10);
+ REQUIRE(!strcmp(buffer, "| 10| |10| | 10|"));
+
+ test::sprintf(buffer, "|%5d| |%-12d| |%5d|", 9, 9, 9);
+ REQUIRE(!strcmp(buffer, "| 9| |9 | | 9|"));
+
+ test::sprintf(buffer, "|%5d| |%-12d| |%5d|", 10, 10, 10);
+ REQUIRE(!strcmp(buffer, "| 10| |10 | | 10|"));
}