aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2018-09-14 14:42:41 +0200
committerMarco Paland <marco@paland.com>2018-09-14 14:42:41 +0200
commit7075d314a0875caa45c8571f7aa52f732f3612a9 (patch)
treed565c1968a83557fcd6b614e5f6deaa0eda346d2 /test
parent6dae1687b5fd4dd7ee104079da0df906fe393263 (diff)
downloadprintf-7075d314a0875caa45c8571f7aa52f732f3612a9.tar.gz
printf-7075d314a0875caa45c8571f7aa52f732f3612a9.tar.bz2
printf-7075d314a0875caa45c8571f7aa52f732f3612a9.zip
fix(printf): zero precision and zero value hash problem
Fixes #26
Diffstat (limited to 'test')
-rw-r--r--test/test_suite.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_suite.cpp b/test/test_suite.cpp
index e693851..99e07b7 100644
--- a/test/test_suite.cpp
+++ b/test/test_suite.cpp
@@ -247,6 +247,9 @@ TEST_CASE("+ flag", "[]" ) {
test::sprintf(buffer, "%+c", 'x');
REQUIRE(!strcmp(buffer, "x"));
+
+ test::sprintf(buffer, "%+.0d", 0);
+ REQUIRE(!strcmp(buffer, "+"));
}
@@ -344,6 +347,14 @@ TEST_CASE("- flag", "[]" ) {
}
+TEST_CASE("# flag", "[]" ) {
+ char buffer[100];
+
+ test::sprintf(buffer, "%#.0x", 0);
+ REQUIRE(!strcmp(buffer, ""));
+}
+
+
TEST_CASE("specifier", "[]" ) {
char buffer[100];
@@ -1232,6 +1243,9 @@ TEST_CASE("misc", "[]" ) {
test::sprintf(buffer, "%.3s", "foobar");
REQUIRE(!strcmp(buffer, "foo"));
+ test::sprintf(buffer, "% .0d", 0);
+ REQUIRE(!strcmp(buffer, " "));
+
test::sprintf(buffer, "%10.5d", 4);
REQUIRE(!strcmp(buffer, " 00004"));