From 53df748bfa143426fc65c9a1653726ef25d07b8e Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Thu, 2 Jul 2015 11:07:36 +1000 Subject: Increase unit test coverage of printf %p and %o Signed-off-by: Stewart Smith --- libc/test/run-snprintf.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libc/test/run-snprintf.c b/libc/test/run-snprintf.c index 7087a90..e5929ea 100644 --- a/libc/test/run-snprintf.c +++ b/libc/test/run-snprintf.c @@ -90,6 +90,26 @@ static void test_printf_c(void) free(buf); } +static void test_printf_p(void) +{ + char *buf= (char*)malloc(32); + char buf2[32]; + skiboot_snprintf(buf, 32, 32, "%p", buf); + snprintf(buf2, 32, "%p", buf); + assert(0 == strncmp(buf, buf2, 32)); + free(buf); +} + +static void test_printf_o(void) +{ + char *buf= (char*)malloc(32); + char buf2[32]; + skiboot_snprintf(buf, 32, 32, "%o", 0x12345678); + snprintf(buf2, 32, "%o", 0x12345678); + assert(0 == strncmp(buf, buf2, 32)); + free(buf); +} + int main(void) { char *buf; @@ -145,6 +165,8 @@ int main(void) test_printf_x("%x"); test_printf_x("%X"); test_printf_c(); + test_printf_p(); + test_printf_o(); return 0; } -- cgit v1.1