[Libreoffice-commits] core.git: sc/qa

kerem hallackerem at gmail.com
Sun Jan 8 02:14:10 UTC 2017


 sc/qa/unit/ucalc_sort.cxx |   99 +++++++++++++++-------------------------------
 1 file changed, 33 insertions(+), 66 deletions(-)

New commits:
commit 9aea56370ae78a43c3543159571ea0454c1619eb
Author: kerem <hallackerem at gmail.com>
Date:   Sat Jan 7 23:49:42 2017 +0200

    tdf#90290 use custom asserter in ucalc_sort.cxx
    
    Change-Id: Ie6123113e270e75e942716dda0ed4da71b2a2afc
    Reviewed-on: https://gerrit.libreoffice.org/32824
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index 7ec786d..b24a3da 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -182,12 +182,9 @@ void Test::testSortHorizontal()
         CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
     }
 
-    if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "CONCATENATE(C2;\"-\";D2)"))
-        CPPUNIT_FAIL("Wrong formula!");
-    if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "CONCATENATE(C3;\"-\";D3)"))
-        CPPUNIT_FAIL("Wrong formula!");
-    if (!checkFormula(*m_pDoc, ScAddress(1,3,0), "CONCATENATE(C4;\"-\";D4)"))
-        CPPUNIT_FAIL("Wrong formula!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "CONCATENATE(C2;\"-\";D2)", "Wrong formula!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "CONCATENATE(C3;\"-\";D3)", "Wrong formula!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,3,0), "CONCATENATE(C4;\"-\";D4)", "Wrong formula!");
 
     m_pDoc->DeleteTab(0);
 }
@@ -763,8 +760,7 @@ void Test::testSortRefUpdate()
     }
 
     // C2 should now point to A4.
-    if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]"))
-        CPPUNIT_FAIL("Wrong formula in C2!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]", "Wrong formula in C2!");
 
     // Undo the sort.
     SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
@@ -787,8 +783,7 @@ void Test::testSortRefUpdate()
     }
 
     // C2 should now point to A2.
-    if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "RC[-2]"))
-        CPPUNIT_FAIL("Wrong formula in C2!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "RC[-2]", "Wrong formula in C2!");
 
     // Redo.
     pUndoMgr->Redo();
@@ -809,8 +804,7 @@ void Test::testSortRefUpdate()
     }
 
     // C2 should now point to A4.
-    if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]"))
-        CPPUNIT_FAIL("Wrong formula in C2!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]", "Wrong formula in C2!");
 
     // Undo again.
     pUndoMgr->Undo();
@@ -913,8 +907,7 @@ void Test::testSortRefUpdate2()
     // Formulas in column B should still point to their respective left neighbor cell.
     for (SCROW i = 1; i <= 4; ++i)
     {
-        if (!checkFormula(*m_pDoc, ScAddress(1,i,0), "RC[-1]"))
-            CPPUNIT_FAIL("Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,i,0), "RC[-1]", "Wrong formula!");
     }
 
     // Undo and check the result in column B.
@@ -994,12 +987,9 @@ void Test::testSortRefUpdate3()
     CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,5,0)));
 
     // Make sure the formula cells have been adjusted correctly.
-    if (!checkFormula(*m_pDoc, ScAddress(0,3,0), "A2+A3"))
-        CPPUNIT_FAIL("Wrong formula in A4.");
-    if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "A2+10"))
-        CPPUNIT_FAIL("Wrong formula in A5.");
-    if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "A3+10"))
-        CPPUNIT_FAIL("Wrong formula in A6.");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,3,0), "A2+A3", "Wrong formula in A4.");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "A2+10", "Wrong formula in A5.");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "A3+10", "Wrong formula in A6.");
 
     // Undo and check the result.
     SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
@@ -1405,12 +1395,9 @@ void Test::testSortRefUpdate6()
     }
 
     // Make sure that the formulas in C2:C4 are not adjusted.
-    if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "C1+B2"))
-        CPPUNIT_FAIL("Wrong formula!");
-    if (!checkFormula(*m_pDoc, ScAddress(2,2,0), "C2+B3"))
-        CPPUNIT_FAIL("Wrong formula!");
-    if (!checkFormula(*m_pDoc, ScAddress(2,3,0), "C3+B4"))
-        CPPUNIT_FAIL("Wrong formula!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "C1+B2", "Wrong formula!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,2,0), "C2+B3", "Wrong formula!");
+    ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,3,0), "C3+B4", "Wrong formula!");
 
     // Undo and check.
     SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
@@ -1542,22 +1529,14 @@ void Test::testSortBroadcaster()
         }
 
         // Make sure that the formulas in D1:G2 are not adjusted.
-        if (!checkFormula(*m_pDoc, ScAddress(3,0,0), "B1"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(3,1,0), "B2"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(4,0,0), "$B$1"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(4,1,0), "$B$2"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(5,0,0), "SUM(A1:B1)"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(5,1,0), "SUM(A2:B2)"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(6,0,0), "SUM($A$1:$B$1)"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(6,1,0), "SUM($A$2:$B$2)"))
-            CPPUNIT_FAIL("Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,0,0), "B1", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "B2", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,0,0), "$B$1", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,1,0), "$B$2", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(5,0,0), "SUM(A1:B1)", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(5,1,0), "SUM(A2:B2)", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(6,0,0), "SUM($A$1:$B$1)", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(6,1,0), "SUM($A$2:$B$2)", "Wrong formula!");
 
         // Enter new value and check that it is broadcasted. First in empty cell.
         m_pDoc->SetString(1,1,0, "16");
@@ -1652,22 +1631,14 @@ void Test::testSortBroadcaster()
         }
 
         // Make sure that the formulas in A8:B11 are not adjusted.
-        if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "A6"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(1,7,0), "B6"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "$A$6"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(1,8,0), "$B$6"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM(A5:A6)"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(1,9,0), "SUM(B5:B6)"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(0,10,0), "SUM($A$5:$A$6)"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(1,10,0), "SUM($B$5:$B$6)"))
-            CPPUNIT_FAIL("Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "A6", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,7,0), "B6", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,8,0), "$A$6", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,8,0), "$B$6", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,9,0), "SUM(A5:A6)", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,9,0), "SUM(B5:B6)", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,10,0), "SUM($A$5:$A$6)", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,10,0), "SUM($B$5:$B$6)", "Wrong formula!");
 
         // Enter new value and check that it is broadcasted. First in empty cell.
         m_pDoc->SetString(1,5,0, "16");
@@ -1758,14 +1729,10 @@ void Test::testSortBroadcastBroadcaster()
         }
 
         // Make sure that the formulas in B1:C2 are not adjusted.
-        if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A1"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A2"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "B1"))
-            CPPUNIT_FAIL("Wrong formula!");
-        if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "B2"))
-            CPPUNIT_FAIL("Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A1", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "A2", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "B1", "Wrong formula!");
+        ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "B2", "Wrong formula!");
     }
 
     m_pDoc->DeleteTab(0);


More information about the Libreoffice-commits mailing list