diff options
Diffstat (limited to 'src/user')
-rw-r--r-- | src/user/app/tests/shared/printf.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/user/app/tests/shared/printf.c b/src/user/app/tests/shared/printf.c index 4e5ffb8..37b9679 100644 --- a/src/user/app/tests/shared/printf.c +++ b/src/user/app/tests/shared/printf.c @@ -23,16 +23,26 @@ static void test_printf(void) { snprintf(buf, sizeof buf, "%s%%%s", "ab", "cd"); test(!strcmp(buf, "ab%cd")); - snprintf(buf, sizeof buf, "%05u %05u", 1234, 56789); - test(!strcmp(buf, "01234 56789")); - - snprintf(buf, sizeof buf, "%5d %5d", 123, 4567); - test(!strcmp(buf, " 123 4567")); - snprintf(buf, sizeof buf, "%5d %5d", -123, -4567); - test(!strcmp(buf, " -123 -4567")); - - snprintf(buf, sizeof buf, "%u %d %x", 0, 0, 0); - test(!strcmp(buf, "0 0 0")); + snprintf(buf, sizeof buf, "%05u,%05u", 1234, 56789); + test(!strcmp(buf, "01234,56789")); + + snprintf(buf, sizeof buf, "%5d,%5d", 123, 4567); + test(!strcmp(buf, " 123, 4567")); + snprintf(buf, sizeof buf, "%5d,%5d", -123, -4567); + test(!strcmp(buf, " -123,-4567")); + + snprintf(buf, sizeof buf, "%u,%d,%x", 0, 0, 0); + test(!strcmp(buf, "0,0,0")); + + /* precision */ + snprintf(buf, sizeof buf, "%5.2u,%5.2d,%5.2x", 0, 0, 0); + test(!strcmp(buf, " 00, 00, 00")); + snprintf(buf, sizeof buf, "%5.2u,%5.2d,%5.2x", 10, -10, 0x10); + test(!strcmp(buf, " 10, -10, 10")); + snprintf(buf, sizeof buf, "%5.3d", -1); + test(!strcmp(buf, " -001")); + snprintf(buf, sizeof buf, "%.5d", 123); + test(!strcmp(buf, "00123")); } void r_s_printf(void) { |