From 480c085ebc2583dfe1a580ae9d3d896460b95bf4 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Thu, 2 Jul 2015 11:31:45 +1000 Subject: Increase unit test coverage of printf h and z length modifiers Signed-off-by: Stewart Smith --- libc/test/run-snprintf.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libc/test') diff --git a/libc/test/run-snprintf.c b/libc/test/run-snprintf.c index e5929ea..e1de983 100644 --- a/libc/test/run-snprintf.c +++ b/libc/test/run-snprintf.c @@ -110,6 +110,26 @@ static void test_printf_o(void) free(buf); } +static void test_printf_h(short i) +{ + char *buf= (char*)malloc(32); + char buf2[32]; + skiboot_snprintf(buf, 32, 32, "%hd", i); + snprintf(buf2, 32, "%hd", i); + assert(0 == strncmp(buf, buf2, 32)); + free(buf); +} + +static void test_printf_z(size_t i) +{ + char *buf= (char*)malloc(32); + char buf2[32]; + skiboot_snprintf(buf, 32, 32, "%zu", i); + snprintf(buf2, 32, "%zu", i); + assert(0 == strncmp(buf, buf2, 32)); + free(buf); +} + int main(void) { char *buf; @@ -167,6 +187,17 @@ int main(void) test_printf_c(); test_printf_p(); test_printf_o(); + test_printf_h(0); + test_printf_h(128); + test_printf_h(256); + test_printf_h(-1); + test_printf_h(32767); + test_printf_h(32768); + test_printf_h(65535); + test_printf_z(0); + test_printf_z(-1); + test_printf_z(12345); + test_printf_z(128000000); return 0; } -- cgit v1.1