Andrew Nguyen : ole32/tests: Add tests for output parameters in MkParseDisplayName.

Alexandre Julliard julliard at winehq.org
Fri May 21 12:15:22 CDT 2010


Module: wine
Branch: master
Commit: 07325c7d7cba3383cb1bd070263cc3b9a9679597
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=07325c7d7cba3383cb1bd070263cc3b9a9679597

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Wed May 19 22:26:10 2010 -0500

ole32/tests: Add tests for output parameters in MkParseDisplayName.

---

 dlls/ole32/tests/moniker.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c
index 4432f99..876d034 100644
--- a/dlls/ole32/tests/moniker.c
+++ b/dlls/ole32/tests/moniker.c
@@ -817,7 +817,7 @@ static void test_MkParseDisplayName(void)
     static const WCHAR wszEmpty[] = {0};
     char szDisplayNameFile[256];
     WCHAR wszDisplayNameFile[256];
-    int i;
+    int i, len;
 
     const struct
     {
@@ -861,15 +861,23 @@ static void test_MkParseDisplayName(void)
         ok(pmk == (IMoniker *)0xdeadbeef, "[%d] Output moniker pointer should have been 0xdeadbeef instead of %p\n", i, pmk);
     }
 
+    eaten = 0xdeadbeef;
+    pmk = (IMoniker *)0xdeadbeef;
     hr = MkParseDisplayName(pbc, wszNonExistentProgId, &eaten, &pmk);
     ok(hr == MK_E_SYNTAX || hr == MK_E_CANTOPENFILE /* Win9x */,
         "MkParseDisplayName should have failed with MK_E_SYNTAX or MK_E_CANTOPENFILE instead of 0x%08x\n", hr);
+    ok(eaten == 0, "Processed character count should have been 0 instead of %u\n", eaten);
+    ok(pmk == NULL, "Output moniker pointer should have been NULL instead of %p\n", pmk);
 
     /* no special handling of "clsid:" without the string form of the clsid
      * following */
+    eaten = 0xdeadbeef;
+    pmk = (IMoniker *)0xdeadbeef;
     hr = MkParseDisplayName(pbc, wszDisplayNameClsid, &eaten, &pmk);
     ok(hr == MK_E_SYNTAX || hr == MK_E_CANTOPENFILE /* Win9x */,
         "MkParseDisplayName should have failed with MK_E_SYNTAX or MK_E_CANTOPENFILE instead of 0x%08x\n", hr);
+    ok(eaten == 0, "Processed character count should have been 0 instead of %u\n", eaten);
+    ok(pmk == NULL, "Output moniker pointer should have been NULL instead of %p\n", pmk);
 
     /* shows clsid has higher precedence than a running object */
     hr = CreateFileMoniker(wszDisplayName, &pmk);
@@ -882,6 +890,8 @@ static void test_MkParseDisplayName(void)
     pmk = NULL;
     hr = MkParseDisplayName(pbc, wszDisplayName, &eaten, &pmk);
     ok_ole_success(hr, MkParseDisplayName);
+    ok(eaten == sizeof(wszDisplayName)/sizeof(WCHAR) - 1,
+        "Processed character count should have been 43 instead of %u\n", eaten);
     if (pmk)
     {
         IMoniker_IsSystemMoniker(pmk, &moniker_type);
@@ -902,6 +912,8 @@ static void test_MkParseDisplayName(void)
     pmk = NULL;
     hr = MkParseDisplayName(pbc, wszDisplayNameRunning, &eaten, &pmk);
     ok_ole_success(hr, MkParseDisplayName);
+    ok(eaten == sizeof(wszDisplayNameRunning)/sizeof(WCHAR) - 1,
+        "Processed character count should have been 15 instead of %u\n", eaten);
     if (pmk)
     {
         IMoniker_IsSystemMoniker(pmk, &moniker_type);
@@ -918,6 +930,8 @@ static void test_MkParseDisplayName(void)
     expected_display_name = wszDisplayNameProgId1;
     hr = MkParseDisplayName(pbc, wszDisplayNameProgId1, &eaten, &pmk);
     ok_ole_success(hr, MkParseDisplayName);
+    ok(eaten == sizeof(wszDisplayNameProgId1)/sizeof(WCHAR) - 1,
+        "Processed character count should have been 8 instead of %u\n", eaten);
     if (pmk)
     {
         IMoniker_IsSystemMoniker(pmk, &moniker_type);
@@ -928,6 +942,8 @@ static void test_MkParseDisplayName(void)
     expected_display_name = wszDisplayNameProgId2;
     hr = MkParseDisplayName(pbc, wszDisplayNameProgId2, &eaten, &pmk);
     ok_ole_success(hr, MkParseDisplayName);
+    ok(eaten == sizeof(wszDisplayNameProgId2)/sizeof(WCHAR) - 1,
+        "Processed character count should have been 8 instead of %u\n", eaten);
     if (pmk)
     {
         IMoniker_IsSystemMoniker(pmk, &moniker_type);
@@ -935,18 +951,23 @@ static void test_MkParseDisplayName(void)
         IMoniker_Release(pmk);
     }
 
+    eaten = 0xdeadbeef;
+    pmk = (IMoniker *)0xdeadbeef;
     hr = MkParseDisplayName(pbc, wszDisplayNameProgIdFail, &eaten, &pmk);
     ok(hr == MK_E_SYNTAX || hr == MK_E_CANTOPENFILE /* Win9x */,
         "MkParseDisplayName with ProgId without marker should fail with MK_E_SYNTAX or MK_E_CANTOPENFILE instead of 0x%08x\n", hr);
+    ok(eaten == 0, "Processed character count should have been 0 instead of %u\n", eaten);
+    ok(pmk == NULL, "Output moniker pointer should have been NULL instead of %p\n", pmk);
 
     hr = CoRevokeClassObject(pdwReg1);
     ok_ole_success(hr, CoRevokeClassObject);
 
     GetSystemDirectoryA(szDisplayNameFile, sizeof(szDisplayNameFile));
     strcat(szDisplayNameFile, "\\kernel32.dll");
-    MultiByteToWideChar(CP_ACP, 0, szDisplayNameFile, -1, wszDisplayNameFile, sizeof(wszDisplayNameFile)/sizeof(wszDisplayNameFile[0]));
+    len = MultiByteToWideChar(CP_ACP, 0, szDisplayNameFile, -1, wszDisplayNameFile, sizeof(wszDisplayNameFile)/sizeof(wszDisplayNameFile[0]));
     hr = MkParseDisplayName(pbc, wszDisplayNameFile, &eaten, &pmk);
     ok_ole_success(hr, MkParseDisplayName);
+    ok(eaten == len - 1, "Processed character count should have been %d instead of %u\n", len - 1, eaten);
     if (pmk)
     {
         IMoniker_IsSystemMoniker(pmk, &moniker_type);
@@ -956,6 +977,7 @@ static void test_MkParseDisplayName(void)
 
     hr = MkParseDisplayName(pbc, wszDisplayName, &eaten, &pmk);
     ok_ole_success(hr, MkParseDisplayName);
+    ok(eaten == sizeof(wszDisplayName)/sizeof(WCHAR) - 1, "Processed character count should have been 43 instead of %u\n", eaten);
 
     if (pmk)
     {




More information about the wine-cvs mailing list