msvcrt-B02: printf test
Jaco Greeff
jaco at puxedo.org
Tue Nov 5 05:21:31 CST 2002
Updated to make sure that the A?? patches applies cleanly to current CVS.
License:
LGPL
Changelog:
* dlls/msvcrt/tests/Makefile.in, dlls/msvcrt/tests/printf.c: Jaco Greeff
<jaco at puxedo.org>
- printf test case
-------------- next part --------------
diff -aurN msvcrt-B01/dlls/msvcrt/tests/Makefile.in msvcrt-B02/dlls/msvcrt/tests/Makefile.in
--- msvcrt-B01/dlls/msvcrt/tests/Makefile.in Thu Oct 31 01:49:03 2002
+++ msvcrt-B02/dlls/msvcrt/tests/Makefile.in Tue Nov 5 11:48:30 2002
@@ -7,6 +7,7 @@
EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
CTESTS = \
+ printf.c \
scanf.c
@MAKE_TEST_RULES@
diff -aurN msvcrt-B01/dlls/msvcrt/tests/printf.c msvcrt-B02/dlls/msvcrt/tests/printf.c
--- msvcrt-B01/dlls/msvcrt/tests/printf.c Thu Jan 1 02:00:00 1970
+++ msvcrt-B02/dlls/msvcrt/tests/printf.c Tue Nov 5 11:48:12 2002
@@ -0,0 +1,69 @@
+/*
+ * Unit test suite for *printf functions.
+ *
+ * Copyright 2002 Jaco Greeff
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "stdio.h"
+#include "wine/test.h"
+#include "wine/unicode.h"
+
+static void test_string(FILE *f, void *pExpected, INT nLen, INT nSize)
+{
+ CHAR szResult[1024];
+
+ ok(fread(szResult, nSize, nLen, f) == nLen, "Unexpected number of bytes read\n");
+ ok(memcmp(szResult, pExpected, nLen*nSize) == 0, "String comparison failed\n");
+}
+
+static void test_printf(void)
+{
+ /* test strings */
+ static const CHAR szTestA[] = "ASCII";
+ static const CHAR szTestU[] = "Unicode";
+ static const WCHAR wszTestA[] = { 'A', 'S', 'C', 'I', 'I', 0 };
+ static const WCHAR wszTestU[] = { 'U', 'n', 'i', 'c', 'o', 'd', 'e', 0 };
+
+ /* test formatting operations */
+ static const CHAR szFmtA[] = "%s";
+ static const CHAR szFmtW[] = "%S";
+ static const WCHAR wszFmtW[] = { '%', 's', 0 };
+ static const WCHAR wszFmtA[] = { '%', 'S', 0 };
+
+ FILE *f;
+
+ /* write the strings to disk */
+ ok((f = fopen("printf.txt", "w")) != NULL, "Unable to create printf.txt\n");
+ ok(fprintf(f, szFmtA, szTestA) == strlen(szTestA), "Failed writing string\n");
+ ok(fprintf(f, szFmtW, wszTestA) == strlenW(wszTestA), "Failed writing string\n");
+ ok(fwprintf(f, wszFmtA, szTestU) == strlen(szTestU), "Failed writing string\n");
+ ok(fwprintf(f, wszFmtW, wszTestU) == strlenW(wszTestU), "Failed writing string\n");
+ fclose(f);
+
+ /* read/test the strings on disk */
+ ok((f = fopen("printf.txt", "r")) != NULL, "Unable to open printf.txt\n");
+ test_string(f, (void *)szTestA, strlen(szTestA), sizeof(CHAR));
+ test_string(f, (void *)szTestA, strlen(szTestA), sizeof(CHAR));
+ test_string(f, (void *)wszTestU, strlenW(wszTestU), sizeof(WCHAR));
+ test_string(f, (void *)wszTestU, strlenW(wszTestU), sizeof(WCHAR));
+ fclose(f);
+}
+
+START_TEST(printf)
+{
+ test_printf();
+}
More information about the wine-patches
mailing list