summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2009-01-31 18:32:39 +0000
committerdas <das@FreeBSD.org>2009-01-31 18:32:39 +0000
commitea7687b30b0e418c465aa17ee2b2c6a342b2896f (patch)
tree026bdfdb43b23bfc3bcc6b5fe8bbf3b857b339d7 /tools
parent7003291a2c4e0d08ca1a5a17181fd36ea8e48e6d (diff)
downloadFreeBSD-src-ea7687b30b0e418c465aa17ee2b2c6a342b2896f.zip
FreeBSD-src-ea7687b30b0e418c465aa17ee2b2c6a342b2896f.tar.gz
Test wprintf() in addition to printf().
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/lib/libc/stdio/test-printfloat.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/regression/lib/libc/stdio/test-printfloat.c b/tools/regression/lib/libc/stdio/test-printfloat.c
index e7740b4..97bb1a8 100644
--- a/tools/regression/lib/libc/stdio/test-printfloat.c
+++ b/tools/regression/lib/libc/stdio/test-printfloat.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002, 2005 David Schultz <das@FreeBSD.org>
+ * Copyright (c) 2002-2009 David Schultz <das@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <wchar.h>
#define testfmt(result, fmt, ...) \
_testfmt((result), __LINE__, #__VA_ARGS__, fmt, __VA_ARGS__)
@@ -326,10 +327,13 @@ smash_stack(void)
void
_testfmt(const char *result, int line, const char *argstr, const char *fmt,...)
{
- char s[100];
- va_list ap;
+#define BUF 100
+ wchar_t ws[BUF], wfmt[BUF], wresult[BUF];
+ char s[BUF];
+ va_list ap, ap2;
va_start(ap, fmt);
+ va_copy(ap2, ap);
smash_stack();
vsnprintf(s, sizeof(s), fmt, ap);
if (strcmp(result, s) != 0) {
@@ -338,4 +342,16 @@ _testfmt(const char *result, int line, const char *argstr, const char *fmt,...)
line, fmt, argstr, s, result);
abort();
}
+
+ smash_stack();
+ mbstowcs(ws, s, BUF - 1);
+ mbstowcs(wfmt, fmt, BUF - 1);
+ mbstowcs(wresult, result, BUF - 1);
+ vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2);
+ if (wcscmp(wresult, ws) != 0) {
+ fprintf(stderr,
+ "%d: wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n",
+ line, wfmt, argstr, ws, wresult);
+ abort();
+ }
}
OpenPOWER on IntegriCloud