changeset 261:f1decaee6157

Improve tests.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 17 Feb 2016 12:59:55 +0200
parents ab18ebbb5529
children e459a28ee1be
files tests.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests.c	Wed Feb 17 12:59:51 2016 +0200
+++ b/tests.c	Wed Feb 17 12:59:55 2016 +0200
@@ -88,6 +88,11 @@
     
     test_result_msg((unsigned char) buf1[len] == SET_SENTINEL_BYTE, "buffer #1 overflow, sentinel 0x%02x", buf1[len]);
     test_result_msg((unsigned char) buf2[len] == SET_SENTINEL_BYTE, "buffer #2 overflow, sentinel 0x%02x", buf2[len]);
+
+    test_start("th_strdup_vprintf('%s')", fmt);
+    char *str = th_strdup_vprintf(fmt, ap);
+    test_result_msg(str != NULL, "result NULL");
+    th_free(str);
 }
 
 
@@ -115,7 +120,7 @@
     // Initialization
     //
     th_init("th-test", "th-libs unit tests", "0.0.1", NULL, NULL);
-    th_verbosityLevel = 1;
+    th_verbosityLevel = 0;
 
     if (sizeof(char) != sizeof(unsigned char))
     {
@@ -130,14 +135,14 @@
     //
     THPRINT(0, "printf() family function tests.\n");
     int i_vals[] = { 2, 612342, -2, -612342, 0x1fff, 0x8000000, };
-    char *i_fmts[] = { "%d", "%x", "%05d", "%5d", "%-5d", "%05x", "%5x", };
+    char *i_fmts[] = { "%d", "%x", "%05d", "%5d", "%-5d", "%05x", "%5x", "", };
     size_t i1, i2;
 
     for (i1 = 0; i1 < sizeof(i_vals) / sizeof(i_vals[0]); i1++)
     for (i2 = 0; i2 < sizeof(i_fmts) / sizeof(i_fmts[0]); i2++)
         test_snprintf(i_fmts[i2], i_vals);
 
-    char *s_vals[] = { "", "asdf", "xxx yyy zzz ppp fff", NULL, "X" };
+    char *s_vals[] = { "", "asdf", "xxx yyy zzz ppp fff", NULL, "X", "abcde", };
     char *s_fmts[] = { "%s", "%2s", "%-2s", "%5s", "%-5s", "%16s", "%-16s", "%1s", "%-1s", };
 
     for (i1 = 0; i1 < sizeof(s_vals) / sizeof(s_vals[0]); i1++)
@@ -145,7 +150,10 @@
         test_snprintf(s_fmts[i2], s_vals);
 
     test_snprintf("a%cBC", 'x');
+    test_snprintf("%c", 'x');
+    test_snprintf("", 'x');
 
+    THPRINT(0, "printf() family function tests.\n");
 
     //
     // Print summary and exit