changeset 339:46a0fab6ca1f

Fix snprintf() test running.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 23 Feb 2016 17:38:59 +0200
parents b6f2efd0f6f2
children cde5415c4201
files tests.c
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/tests.c	Tue Feb 23 17:30:07 2016 +0200
+++ b/tests.c	Tue Feb 23 17:38:59 2016 +0200
@@ -192,10 +192,8 @@
     memset(buf1, SET_SENTINEL_BYTE, SET_BUF_SIZE+2); buf1[SET_BUF_SIZE+1] = 0;
     memset(buf2, SET_SENTINEL_BYTE, SET_BUF_SIZE+2); buf2[SET_BUF_SIZE+1] = 0;
 
-    va_copy(tmp, ap);
-
-    ret1 = th_vsnprintf(buf1, len, fmt, ap);
-    ret2 = vsnprintf(buf2, len, fmt, tmp);
+    va_copy(tmp, ap); ret1 = th_vsnprintf(buf1, len, fmt, tmp);
+    va_copy(tmp, ap); ret2 = vsnprintf(buf2, len, fmt, tmp);
 
     test_result_msg(&ctx, ret1 == ret2, "retval mismatch %d [th] != %d [libc]", ret1, ret2);
     test_result_msg(&ctx, strcmp(buf1, buf2) == 0, "result mismatch '%s' [th] != '%s' [libc]", buf1, buf2);
@@ -205,7 +203,8 @@
 
     // Test th_strdup_vprintf()
     test_start(&ctx, "th_strdup_vprintf('%s')", fmt);
-    char *str = th_strdup_vprintf(fmt, ap);
+    va_copy(tmp, ap);
+    char *str = th_strdup_vprintf(fmt, tmp);
     test_result_msg(&ctx, str != NULL, "result NULL");
     th_free(str);
 }