aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-07-02 11:31:45 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-07-02 11:31:45 +1000
commit480c085ebc2583dfe1a580ae9d3d896460b95bf4 (patch)
tree10d42274968eed0290e50b818e067cfa828c76bc /libc
parent53df748bfa143426fc65c9a1653726ef25d07b8e (diff)
downloadskiboot-480c085ebc2583dfe1a580ae9d3d896460b95bf4.zip
skiboot-480c085ebc2583dfe1a580ae9d3d896460b95bf4.tar.gz
skiboot-480c085ebc2583dfe1a580ae9d3d896460b95bf4.tar.bz2
Increase unit test coverage of printf h and z length modifiers
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libc')
-rw-r--r--libc/test/run-snprintf.c31
1 files changed, 31 insertions, 0 deletions
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;
}