[PATCH] =Conformance tests for LoadString (fixed)
Christopher Berner
raccoonone at procyongames.com
Sun Mar 2 11:01:55 CST 2008
---
dlls/user32/tests/resource.c | 52 +++++++++++++++++++++++++++++++++++++++++
dlls/user32/tests/resource.rc | 1 +
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/dlls/user32/tests/resource.c b/dlls/user32/tests/resource.c
index 59f86ef..e376758 100644
--- a/dlls/user32/tests/resource.c
+++ b/dlls/user32/tests/resource.c
@@ -31,6 +31,51 @@ static void init_function_pointers(void)
pPrivateExtractIconsA = (void*)GetProcAddress(hmod, "PrivateExtractIconsA");
}
+static void test_LoadStringW(void)
+{
+ HINSTANCE hInst = GetModuleHandle(NULL);
+ WCHAR copiedstringw[128], returnedstringw[128], *resourcepointer = NULL;
+ char copiedstring[128], returnedstring[128];
+ int length1, length2, retvalue;
+
+ /* Check that the string which is returned by LoadStringW matches
+ the string at the pointer returned by LoadStringW when called with buflen = 0 */
+ length1 = LoadStringW(hInst, 2, (WCHAR *) &resourcepointer, 0); /* get pointer to resource. */
+ length2 = LoadStringW(hInst, 2, returnedstringw, sizeof(returnedstringw) /sizeof(WCHAR)); /* get resource string */
+ ok(length2 > 0, "LoadStringW failed to load resource 2, ret %d, err %d \n", length2, GetLastError());
+ todo_wine
+ {
+ ok(length1 == length2, "LoadStringW returned different values dependent on buflen. ret1 %d, ret2 %d \n",
+ length1, length2);
+ ok(length1 > 0 && resourcepointer != NULL, "LoadStringW failed to get pointer to resource 2, ret %d, err %d \n",
+ length1, GetLastError());
+ }
+
+ /* Copy the resource since it is not '\0' terminated, and add '\0' to the end */
+ if(resourcepointer != NULL) /* Check that the resource pointer was loaded to avoid access violation */
+ {
+ memcpy(copiedstringw, resourcepointer, length1 * sizeof(WCHAR));
+ copiedstringw[length1] = '\0';
+ /* check that strings match */
+ WideCharToMultiByte( CP_ACP, 0, returnedstringw, -1, returnedstring, 128, NULL, NULL );
+ WideCharToMultiByte( CP_ACP, 0, copiedstringw, -1, copiedstring, 128, NULL, NULL );
+ ok(!memcmp(copiedstringw, returnedstringw, (length2 + 1)*sizeof(WCHAR)),
+ "LoadStringW returned a string that does not match the string pointed to by the pointer it returned. \
+ returnedstring = %s, copiedstring = %s", returnedstring, copiedstring);
+ }
+ todo_wine
+ {
+ /* check that calling LoadStringW with buffer = NULL returns zero */
+ retvalue = LoadStringW(hInst, 2, NULL, 0);
+ ok(!retvalue, "LoadStringW returned a non-zero value when called with buffer = NULL, retvalue = %d",
+ retvalue);
+ /* check again, with a different buflen value, that calling LoadStringW with buffer = NULL returns zero */
+ retvalue = LoadStringW(hInst, 2, NULL, 128);
+ ok(!retvalue, "LoadStringW returned a non-zero value when called with buffer = NULL, retvalue = %d",
+ retvalue);
+ }
+}
+
static void test_LoadStringA (void)
{
HINSTANCE hInst = GetModuleHandle (NULL);
@@ -74,6 +119,12 @@ static void test_LoadStringA (void)
"LoadString failed: ret %d err %d\n", ret, GetLastError());
ok( LoadStringA( hInst, MAKELONG( 65534, 0xffff ), buf, sizeof(buf)) == ret,
"LoadString failed: ret %d err %d\n", ret, GetLastError());
+
+ ret = LoadStringA(hInst, 0, buf, 0);
+ todo_wine
+ {
+ ok( ret == -1, "LoadStringA did not return -1 when called with buflen = 0, got %d, err %d", ret, GetLastError());
+ }
}
static void test_accel1(void)
@@ -317,6 +368,7 @@ START_TEST(resource)
{
init_function_pointers();
test_LoadStringA ();
+ test_LoadStringW();
test_accel1();
test_accel2();
test_PrivateExtractIcons();
diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc
index 31ec68f..f01c6f5 100644
--- a/dlls/user32/tests/resource.rc
+++ b/dlls/user32/tests/resource.rc
@@ -41,6 +41,7 @@ STRINGTABLE
{
0 "String resource"
1 "Another string resource"
+ 2 L"This is a wide string resource"
65534 "Test high id"
}
--
1.5.2.5
--------------020502090807000101030406--
More information about the wine-patches
mailing list