comctl32/tests: Fix the CheckDPA() tests.

Francois Gouget fgouget at free.fr
Thu Nov 23 14:37:08 CST 2006


There is no guarantee that the compiler will compute the function arguments in left-to-right order.
---

I noticed this when Visual C++ complained that the dw variables could be 
used while still uninitialized.

 dlls/comctl32/tests/dpa.c |   60 +++++++++++++++++++++++++++++++-------------
 1 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/dlls/comctl32/tests/dpa.c b/dlls/comctl32/tests/dpa.c
index c05aecb..8940e4a 100644
--- a/dlls/comctl32/tests/dpa.c
+++ b/dlls/comctl32/tests/dpa.c
@@ -202,6 +202,7 @@ static void test_dpa(void)
     PVOID p;
     DWORD dw, dw2, dw3;
     HRESULT hRes;
+    BOOL rc;
     
     GetSystemInfo(&si);
     hHeap = HeapCreate(0, 1, 2);
@@ -219,7 +220,8 @@ static void test_dpa(void)
     ok(pDPA_SetPtr(dpa, 1, (PVOID)6), "\n");
     /* Fill the greated gap */
     ok(pDPA_SetPtr(dpa, 0, (PVOID)5), "\n");
-    ok(CheckDPA(dpa, 0x56, &dw), "dw=0x%x\n", dw);
+    rc=CheckDPA(dpa, 0x56, &dw);
+    ok(rc, "dw=0x%x\n", dw);
     
     /* Prepend item */
     ret = pDPA_InsertPtr(dpa, 1, (PVOID)1);
@@ -234,7 +236,8 @@ static void test_dpa(void)
     ret = pDPA_InsertPtr(dpa, DPA_APPEND, (PVOID)4);
     ok(ret == 5, "ret=%d\n", ret);
 
-    ok(CheckDPA(dpa, 0x516324, &dw), "dw=0x%x\n", dw);
+    rc=CheckDPA(dpa, 0x516324, &dw);
+    ok(rc, "dw=0x%x\n", dw);
 
     for(i = 1; i <= 6; i++)
     {
@@ -247,24 +250,29 @@ static void test_dpa(void)
 
     /* Sort DPA */
     ok(pDPA_Sort(dpa, CB_CmpGT, 0xdeadbeef), "\n");
-    ok(CheckDPA(dpa, 0x654321, &dw), "dw=0x%x\n", dw);
+    rc=CheckDPA(dpa, 0x654321, &dw);
+    ok(rc, "dw=0x%x\n", dw);
     
     /* Clone into a new DPA */
     dpa2 = pDPA_Clone(dpa, NULL);
     ok(dpa2 != NULL, "\n");
     /* The old data should have been preserved */
-    ok(CheckDPA(dpa2, 0x654321, &dw2), "dw=0x%x\n", dw2);
+    rc=CheckDPA(dpa2, 0x654321, &dw2);
+    ok(rc, "dw=0x%x\n", dw2);
     ok(pDPA_Sort(dpa, CB_CmpLT, 0xdeadbeef), "\n");
     
     /* Test if the DPA itself was really copied */
-    ok(CheckDPA(dpa,  0x123456, &dw),  "dw=0x%x\n",  dw );
-    ok(CheckDPA(dpa2, 0x654321, &dw2), "dw2=0x%x\n", dw2);
+    rc=CheckDPA(dpa,  0x123456, &dw);
+    ok(rc, "dw=0x%x\n",  dw );
+    rc=CheckDPA(dpa2, 0x654321, &dw2);
+    ok(rc, "dw2=0x%x\n", dw2);
 
     /* Clone into an old DPA */
     p = NULL; SetLastError(ERROR_SUCCESS);
     p = pDPA_Clone(dpa, dpa3);
     ok(p == dpa3, "p=%p\n", p);
-    ok(CheckDPA(dpa3, 0x123456, &dw3), "dw3=0x%x\n", dw3);
+    rc=CheckDPA(dpa3, 0x123456, &dw3);
+    ok(rc, "dw3=0x%x\n", dw3);
 
     for(i = 1; i <= 6; i++)
     {
@@ -297,7 +305,8 @@ static void test_dpa(void)
     /* Delete the third item */
     p = pDPA_DeletePtr(dpa, 2);
     ok(p == (PVOID)3, "p=%p\n", p);
-    ok(CheckDPA(dpa, 0x12456, &dw), "dw=0x%x\n", dw);
+    rc=CheckDPA(dpa, 0x12456, &dw);
+    ok(rc, "dw=0x%x\n", dw);
 
     /* Check where to re-insert the deleted item */
     i = pDPA_Search(dpa, (PVOID)3, 0, 
@@ -315,7 +324,8 @@ static void test_dpa(void)
     /* Re-insert the item */
     ret = pDPA_InsertPtr(dpa, 2, (PVOID)3);
     ok(ret == 2, "ret=%d i=%d\n", ret, 2);
-    ok(CheckDPA(dpa, 0x123456, &dw), "dw=0x%x\n", dw);
+    rc=CheckDPA(dpa, 0x123456, &dw);
+    ok(rc, "dw=0x%x\n", dw);
     
     /* When doing a binary search while claiming reverse order all indexes
      * should be bogus */
@@ -332,12 +342,17 @@ static void test_dpa(void)
         p = pDPA_DeletePtr(dpa, 1);
         p = pDPA_DeletePtr(dpa, 2);
         p = pDPA_DeletePtr(dpa, 3);
-        ok(CheckDPA(dpa, 0x135, &dw), "dw=0x%x\n", dw);
+        rc=CheckDPA(dpa, 0x135, &dw);
+        ok(rc, "dw=0x%x\n", dw);
     
         /* Delete all odd entries from dpa2 */
         pDPA_Merge(dpa2, dpa, DPAM_DELETE, 
                    CB_CmpLT, CB_MergeDeleteOddSrc, 0xdeadbeef);
-        todo_wine ok(CheckDPA(dpa2, 0x246, &dw2), "dw=0x%x\n", dw2);
+        todo_wine
+        {
+            rc=CheckDPA(dpa2, 0x246, &dw2);
+            ok(rc, "dw=0x%x\n", dw2);
+        }
     
         /* Merge dpa3 into dpa2 and dpa */
         pDPA_Merge(dpa, dpa3, DPAM_INSERT|DPAM_NOSORT, 
@@ -345,16 +360,20 @@ static void test_dpa(void)
         pDPA_Merge(dpa2, dpa3, DPAM_INSERT|DPAM_NOSORT, 
                    CB_CmpLT, CB_MergeInsertSrc, 0xdeadbeef);
     
-        ok(CheckDPA(dpa,  0x123456, &dw ), "dw=0x%x\n",  dw);
-        ok(CheckDPA(dpa2, 0x123456, &dw2), "dw2=0x%x\n", dw2);
-        ok(CheckDPA(dpa3, 0x123456, &dw3), "dw3=0x%x\n", dw3);
+        rc=CheckDPA(dpa,  0x123456, &dw);
+        ok(rc, "dw=0x%x\n",  dw);
+        rc=CheckDPA(dpa2, 0x123456, &dw2);
+        ok(rc, "dw2=0x%x\n", dw2);
+        rc=CheckDPA(dpa3, 0x123456, &dw3);
+        ok(rc, "dw3=0x%x\n", dw3);
     }
 
     if(pDPA_EnumCallback)
     {
         nEnum = 0;
         pDPA_EnumCallback(dpa2, CB_EnumFirstThree, (PVOID)dpa2);
-        ok(CheckDPA(dpa2, 0x777456, &dw2), "dw=0x%x\n", dw2);
+        rc=CheckDPA(dpa2, 0x777456, &dw2);
+        ok(rc, "dw=0x%x\n", dw2);
         ok(nEnum == 3, "nEnum=%d\n", nEnum);
     }
     
@@ -364,7 +383,8 @@ static void test_dpa(void)
     ok(ret == 0x12345, "ret=%d\n", ret);
           
     pDPA_DeleteAllPtrs(dpa2);
-    ok(CheckDPA(dpa2, 0, &dw2), "dw2=0x%x\n", dw2);
+    rc=CheckDPA(dpa2, 0, &dw2);
+    ok(rc, "dw2=0x%x\n", dw2);
     pDPA_Destroy(dpa2);
 
     if(pDPA_DestroyCallback)
@@ -402,8 +422,12 @@ static void test_dpa(void)
         hRes = IStream_Seek(pStm, liZero, STREAM_SEEK_SET, NULL);
         ok(hRes == S_OK, "hRes=0x%x\n", hRes);
         hRes = pDPA_LoadStream(&dpa, CB_Load, pStm, 0xdeadbeef);
-        todo_wine ok(hRes == S_OK, "hRes=0x%x\n", hRes);
-        todo_wine ok(CheckDPA(dpa, 0x123456, &dw), "dw=0x%x\n", dw);
+        todo_wine
+        {
+            ok(hRes == S_OK, "hRes=0x%x\n", hRes);
+            rc=CheckDPA(dpa, 0x123456, &dw);
+            ok(rc, "dw=0x%x\n", dw);
+        }
         pDPA_Destroy(dpa);
 
         ret = IStream_Release(pStm);
-- 
1.4.3.3




More information about the wine-patches mailing list