[Libreoffice-commits] core.git: 2 commits - test/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 6 15:37:27 UTC 2019


 test/source/sheet/xspreadsheets2.cxx |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

New commits:
commit 766ce853d18da813e8d435776f462470cd072538
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Fri Dec 6 15:17:38 2019 +0100
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Fri Dec 6 16:35:54 2019 +0100

    Swap expected and actual values
    
    in CPPUNIT_ASSERT... the first parameter is the expected value and
    the second the actual value. Passing them swapped is confusing if
    the test is failing.
    
    Change-Id: I06f8f345d52c3743d10441aae6d8c943f9b49b41
    Reviewed-on: https://gerrit.libreoffice.org/84635
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx
index a65d68716c9a..fc7f1023fc1c 100644
--- a/test/source/sheet/xspreadsheets2.cxx
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -85,7 +85,7 @@ void XSpreadsheets2::testImportString()
     uno::Reference< text::XTextRange > xDestTextRange(xDestCell, UNO_QUERY_THROW);
     OUString aDestString = xDestTextRange->getString();
 
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong string imported", aDestString, aSrcString);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong string imported", aSrcString, aDestString);
 }
 
 void XSpreadsheets2::testImportValue()
@@ -119,7 +119,7 @@ void XSpreadsheets2::testImportFormulaBasicMath()
 
     // potential problem later: formulas might be adjusted
     // add some tests that the formulas are correctly adjusted
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula imported", aDestFormula, aSrcFormula);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula imported", aSrcFormula, aDestFormula);
 }
 
 void XSpreadsheets2::testImportFormulaWithNamedRange()
@@ -135,7 +135,7 @@ void XSpreadsheets2::testImportFormulaWithNamedRange()
     uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0);
     OUString aDestFormula = xDestCell->getFormula();
 
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Namedrange formula imported", aDestFormula, aSrcFormula);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Namedrange formula imported", aSrcFormula, aDestFormula);
 }
 
 void XSpreadsheets2::testImportOverExistingNamedRange()
@@ -157,7 +157,7 @@ void XSpreadsheets2::testImportOverExistingNamedRange()
     OUString const aExpectedContent("$Sheet1.$B$1");
 
     std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl;
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for initial1", aNrDestContent, aExpectedContent);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for initial1", aExpectedContent, aNrDestContent);
 
 }
 
@@ -182,7 +182,7 @@ void XSpreadsheets2::testImportNamedRangeDefinedInSource()
 
     std::cout << "testImportSheet : InSheetRangeName content " << aNewInSheetNrDestContent << std::endl;
     std::cout << "testImportSheet : InSheetRangeName expected " << aNewInSheetExpectedContent << std::endl;
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetNrDestContent, aNewInSheetExpectedContent);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetExpectedContent, aNewInSheetNrDestContent);
 }
 
 void XSpreadsheets2::testImportNamedRangeRedefinedInSource()
@@ -204,7 +204,7 @@ void XSpreadsheets2::testImportNamedRangeRedefinedInSource()
     OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent();
     OUString const aRedefinedInSheetExpectedContent("$Sheet1.$B$2");
     std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl;
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetNrDestContent, aRedefinedInSheetExpectedContent);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetExpectedContent, aRedefinedInSheetNrDestContent);
 }
 
 void XSpreadsheets2::testImportNewNamedRange()
@@ -258,7 +258,7 @@ void XSpreadsheets2::testImportCellStyle()
     OUString aDestStyleName;
     CPPUNIT_ASSERT(xDestCellPropSet->getPropertyValue(aCellProperty) >>= aDestStyleName);
 
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong imported Cell Style", aDestStyleName, aSrcStyleName);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong imported Cell Style", aSrcStyleName, aDestStyleName);
 
     uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier (xDestDoc, UNO_QUERY_THROW);
     uno::Reference< container::XNameAccess > xFamiliesNameAccess (xFamiliesSupplier->getStyleFamilies(), UNO_SET_THROW);
@@ -307,7 +307,7 @@ void XSpreadsheets2::importSheetToCopy()
     uno::Reference< sheet::XSpreadsheets2 > xDestSheets (xDestDoc->getSheets(), UNO_QUERY_THROW);
     sal_Int32 nDestPos = 0;
     sal_Int32 nDestPosEffective = xDestSheets->importSheet(xDocument, gaSrcSheetName, nDestPos);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet index", nDestPosEffective, nDestPos);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet index", nDestPos, nDestPosEffective);
 
     uno::Reference< container::XIndexAccess > xDestSheetIndexAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
     xDestSheet.set( xDestSheetIndexAccess->getByIndex(nDestPosEffective), UNO_QUERY_THROW);
commit e749fd947c3eead198a4b702428a41ae3d6e2c9d
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Fri Dec 6 14:54:22 2019 +0100
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Fri Dec 6 16:35:42 2019 +0100

    Use correct destination sheet instead of arbitrary leftover of expected name
    
    Tests are executed in sequence, inserting a sheet with each
    importSheetToCopy(), ended up with 'SheetToCopy_4' as the first
    sheet (last sheet inserted), but obtained "destination" values
    from sheet 'SheetToCopy' (the first sheet inserted) whatever may
    have happened to its references during the previous tests or by
    inserting more sheets in front of it.
    
    Instead of obtaining the destination sheet by name 'SheetToCopy',
    obtain it by index 0 where it was inserted
    
    We could also remove the inserted sheet after each test, but
    likely a cleaner approach would be to setup a fresh document to be
    inserted into for each test to avoid any side effects like names
    already being present from a previous insertion.
    
    Change-Id: I38f35ccac7d656026b6fec8d3c5faa68d6f4a642
    Reviewed-on: https://gerrit.libreoffice.org/84631
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx
index 9b500977fe5d..a65d68716c9a 100644
--- a/test/source/sheet/xspreadsheets2.cxx
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -309,8 +309,8 @@ void XSpreadsheets2::importSheetToCopy()
     sal_Int32 nDestPosEffective = xDestSheets->importSheet(xDocument, gaSrcSheetName, nDestPos);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet index", nDestPosEffective, nDestPos);
 
-    uno::Reference< container::XNameAccess > xDestSheetNameAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
-    xDestSheet.set( xDestSheetNameAccess->getByName(gaSrcSheetName), UNO_QUERY_THROW);
+    uno::Reference< container::XIndexAccess > xDestSheetIndexAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
+    xDestSheet.set( xDestSheetIndexAccess->getByIndex(nDestPosEffective), UNO_QUERY_THROW);
 }
 
 bool XSpreadsheets2::isExternalReference(const OUString& aDestContent, const OUString& aSrcContent )


More information about the Libreoffice-commits mailing list