Andrew Nguyen : propsys/tests: Add tests for PSStringFromPropertyKey.
Alexandre Julliard
julliard at winehq.org
Mon Jul 26 13:22:33 CDT 2010
Module: wine
Branch: master
Commit: c20908bf560035826855a334d93bdc9150aa0eae
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c20908bf560035826855a334d93bdc9150aa0eae
Author: Andrew Nguyen <anguyen at codeweavers.com>
Date: Sun Jul 25 21:57:59 2010 -0500
propsys/tests: Add tests for PSStringFromPropertyKey.
---
configure | 1 +
configure.ac | 1 +
dlls/propsys/tests/Makefile.in | 11 +++
dlls/propsys/tests/propsys.c | 140 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 153 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 8f92437..a966b1b 100755
--- a/configure
+++ b/configure
@@ -14665,6 +14665,7 @@ wine_fn_config_dll pidgen enable_pidgen
wine_fn_config_dll powrprof enable_powrprof powrprof
wine_fn_config_dll printui enable_printui
wine_fn_config_dll propsys enable_propsys propsys
+wine_fn_config_test dlls/propsys/tests propsys_test
wine_fn_config_dll psapi enable_psapi psapi
wine_fn_config_test dlls/psapi/tests psapi_test
wine_fn_config_dll pstorec enable_pstorec
diff --git a/configure.ac b/configure.ac
index 0180928..b7373b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2534,6 +2534,7 @@ WINE_CONFIG_DLL(pidgen)
WINE_CONFIG_DLL(powrprof,,[powrprof])
WINE_CONFIG_DLL(printui)
WINE_CONFIG_DLL(propsys,,[propsys])
+WINE_CONFIG_TEST(dlls/propsys/tests)
WINE_CONFIG_DLL(psapi,,[psapi])
WINE_CONFIG_TEST(dlls/psapi/tests)
WINE_CONFIG_DLL(pstorec)
diff --git a/dlls/propsys/tests/Makefile.in b/dlls/propsys/tests/Makefile.in
new file mode 100644
index 0000000..d30f983
--- /dev/null
+++ b/dlls/propsys/tests/Makefile.in
@@ -0,0 +1,11 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = propsys.dll
+IMPORTS = propsys
+
+C_SRCS = \
+ propsys.c
+
+ at MAKE_TEST_RULES@
diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c
new file mode 100644
index 0000000..cc5585b
--- /dev/null
+++ b/dlls/propsys/tests/propsys.c
@@ -0,0 +1,140 @@
+/*
+ * Unit tests for Windows property system
+ *
+ * Copyright 2010 Andrew Nguyen
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "propsys.h"
+#include "initguid.h"
+#include "wine/test.h"
+
+DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
+
+static void test_PSStringFromPropertyKey(void)
+{
+ static const WCHAR fillerW[] = {'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
+ 'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
+ 'X','X','X','X','X','X','X','X','X','X'};
+ static const WCHAR zero_fillerW[] = {'\0','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
+ 'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
+ 'X','X','X','X','X','X','X','X','X','X','X','X','X','X'};
+ static const WCHAR zero_truncatedW[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
+ '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
+ '0','0','0','}',' ','\0','9','X','X','X','X','X','X','X','X','X'};
+ static const WCHAR zero_truncated2W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
+ '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
+ '0','0','0','}',' ','\0','9','2','7','6','9','4','9','2','X','X'};
+ static const WCHAR zero_truncated3W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
+ '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
+ '0','0','0','}',' ','\0','9','2','7','6','9','4','9','2','4','X'};
+ static const WCHAR zero_truncated4W[] = {'\0','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0',
+ '0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0',
+ '0','0','0','}',' ','\0','7','X','X','X','X','X','X','X','X','X'};
+ static const WCHAR truncatedW[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
+ '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
+ '0','}',' ','\0','9','X','X','X','X','X','X','X','X','X'};
+ static const WCHAR truncated2W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
+ '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
+ '0','}',' ','\0','9','2','7','6','9','4','9','2','X','X'};
+ static const WCHAR truncated3W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
+ '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
+ '0','}',' ','\0','9','2','7','6','9','4','9','2','4','X'};
+ static const WCHAR truncated4W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
+ '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
+ '0','}',' ','\0','7','X','X','X','X','X','X','X','X','X'};
+ static const WCHAR expectedW[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
+ '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
+ '0','}',' ','4','2','9','4','9','6','7','2','9','5',0};
+ static const WCHAR expected2W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
+ '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
+ '0','}',' ','1','3','5','7','9','\0','X','X','X','X','X'};
+ static const WCHAR expected3W[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0',
+ '0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0',
+ '0','}',' ','0','\0','X','X','X','X','X','X','X','X','X'};
+ PROPERTYKEY prop = {GUID_NULL, ~0U};
+ PROPERTYKEY prop2 = {GUID_NULL, 13579};
+ PROPERTYKEY prop3 = {GUID_NULL, 0};
+ WCHAR out[PKEYSTR_MAX];
+ HRESULT ret;
+
+ const struct
+ {
+ REFPROPERTYKEY pkey;
+ LPWSTR psz;
+ UINT cch;
+ HRESULT hr_expect;
+ const WCHAR *buf_expect;
+ int hr_broken;
+ HRESULT hr2;
+ int buf_broken;
+ const WCHAR *buf2;
+ } testcases[] =
+ {
+ {NULL, NULL, 0, E_POINTER},
+ {&prop, NULL, 0, E_POINTER},
+ {&prop, NULL, PKEYSTR_MAX, E_POINTER},
+ {NULL, out, 0, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
+ {NULL, out, PKEYSTR_MAX, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_fillerW, 0, 0, 1, fillerW},
+ {&prop, out, 0, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
+ {&prop, out, GUIDSTRING_MAX, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
+ {&prop, out, GUIDSTRING_MAX + 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
+ {&prop, out, GUIDSTRING_MAX + 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_truncatedW, 1, S_OK, 1, truncatedW},
+ {&prop, out, PKEYSTR_MAX - 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_truncated2W, 1, S_OK, 1, truncated2W},
+ {&prop, out, PKEYSTR_MAX - 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_truncated3W, 1, S_OK, 1, truncated3W},
+ {&prop, out, PKEYSTR_MAX, S_OK, expectedW},
+ {&prop2, out, GUIDSTRING_MAX + 2, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), zero_truncated4W, 1, S_OK, 1, truncated4W},
+ {&prop2, out, GUIDSTRING_MAX + 6, S_OK, expected2W},
+ {&prop2, out, PKEYSTR_MAX, S_OK, expected2W},
+ {&prop3, out, GUIDSTRING_MAX + 1, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), fillerW},
+ {&prop3, out, GUIDSTRING_MAX + 2, S_OK, expected3W},
+ {&prop3, out, PKEYSTR_MAX, S_OK, expected3W},
+ };
+
+ int i;
+
+ for (i = 0; i < sizeof(testcases)/sizeof(testcases[0]); i++)
+ {
+ if (testcases[i].psz)
+ memcpy(testcases[i].psz, fillerW, PKEYSTR_MAX * sizeof(WCHAR));
+
+ ret = PSStringFromPropertyKey(testcases[i].pkey,
+ testcases[i].psz,
+ testcases[i].cch);
+ ok(ret == testcases[i].hr_expect ||
+ broken(testcases[i].hr_broken && ret == testcases[i].hr2), /* Vista/Win2k8 */
+ "[%d] Expected PSStringFromPropertyKey to return 0x%08x, got 0x%08x\n",
+ i, testcases[i].hr_expect, ret);
+
+ if (testcases[i].psz)
+ ok(!memcmp(testcases[i].psz, testcases[i].buf_expect, PKEYSTR_MAX * sizeof(WCHAR)) ||
+ broken(testcases[i].buf_broken &&
+ !memcmp(testcases[i].psz, testcases[i].buf2, PKEYSTR_MAX * sizeof(WCHAR))), /* Vista/Win2k8 */
+ "[%d] Unexpected output contents\n", i);
+ }
+}
+
+START_TEST(propsys)
+{
+ test_PSStringFromPropertyKey();
+}
More information about the wine-cvs
mailing list