[Libreoffice-commits] core.git: sw/inc sw/qa

slideon adamkasztenny at gmail.com
Mon May 23 06:26:32 UTC 2016


 sw/inc/unotbl.hxx      |    2 ++
 sw/qa/core/uwriter.cxx |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

New commits:
commit f3657368a6cab2e1931c8845035b914e49360eb3
Author: slideon <adamkasztenny at gmail.com>
Date:   Sat May 21 11:38:15 2016 -0400

    Add a test for comparing table cells and table cell ranges
    
    Also add the method sw_CompareCellsByRowFirst into unotbl.hxx so that
    it can be used elsewhere, just like sw_CompareCellsByColFirst can.
    Change-Id: I4a88455ba73356013f9f630d07610825568c263c
    Reviewed-on: https://gerrit.libreoffice.org/25260
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: jan iversen <jani at documentfoundation.org>

diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index f7ea606..d902c84 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -590,6 +590,8 @@ OUString sw_GetCellName( sal_Int32 nColumn, sal_Int32 nRow );
 
 int sw_CompareCellsByColFirst( const OUString &rCellName1, const OUString &rCellName2 );
 
+int sw_CompareCellsByRowFirst( const OUString &rCellName1, const OUString &rCellName2 );
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 242282d..8867b64 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -65,6 +65,8 @@
 #include "pagedesc.hxx"
 #include "calc.hxx"
 
+#include <unotbl.hxx>
+
 typedef tools::SvRef<SwDocShell> SwDocShellRef;
 
 using namespace ::com::sun::star;
@@ -113,6 +115,7 @@ public:
     void testClientModify();
     void test64kPageDescs();
     void testTdf92308();
+    void testTableCellComparison();
 
     CPPUNIT_TEST_SUITE(SwDocTest);
 
@@ -147,6 +150,7 @@ public:
     CPPUNIT_TEST(testClientModify);
     CPPUNIT_TEST(test64kPageDescs);
     CPPUNIT_TEST(testTdf92308);
+    CPPUNIT_TEST(testTableCellComparison);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1624,6 +1628,39 @@ void SwDocTest::testTdf92308()
     CPPUNIT_ASSERT_EQUAL(m_pDoc->HasInvisibleContent(), false);
 }
 
+void SwDocTest::testTableCellComparison()
+{
+    CPPUNIT_ASSERT_EQUAL( -1, sw_CompareCellsByColFirst(OUString("A1"), OUString("Z1")) );
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellsByColFirst(OUString("Z1"), OUString("A1")) );
+    CPPUNIT_ASSERT_EQUAL(  0, sw_CompareCellsByColFirst(OUString("A1"), OUString("A1")) );
+
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellsByColFirst(OUString("A2"), OUString("A1")) );
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellsByColFirst(OUString("Z3"), OUString("A2")) );
+    CPPUNIT_ASSERT_EQUAL( -1, sw_CompareCellsByColFirst(OUString("A3"), OUString("Z1")) );
+
+    CPPUNIT_ASSERT_EQUAL( -1, sw_CompareCellsByRowFirst(OUString("A1"), OUString("Z1")) );
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellsByRowFirst(OUString("Z1"), OUString("A1")) );
+    CPPUNIT_ASSERT_EQUAL(  0, sw_CompareCellsByRowFirst(OUString("A1"), OUString("A1")) );
+
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellsByRowFirst(OUString("A2"), OUString("A1")) );
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellsByRowFirst(OUString("Z3"), OUString("A2")) );
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellsByRowFirst(OUString("A3"), OUString("Z1")) );
+
+    CPPUNIT_ASSERT_EQUAL(  0, sw_CompareCellRanges(OUString("A1"), OUString("A1"), OUString("A1"), OUString("A1"), true) );
+    CPPUNIT_ASSERT_EQUAL(  0, sw_CompareCellRanges(OUString("A1"), OUString("Z1"), OUString("A1"), OUString("Z1"), true) );
+    CPPUNIT_ASSERT_EQUAL(  0, sw_CompareCellRanges(OUString("A1"), OUString("Z1"), OUString("A1"), OUString("Z1"), false) );
+
+    CPPUNIT_ASSERT_EQUAL( -1, sw_CompareCellRanges(OUString("A1"), OUString("Z1"), OUString("B1"), OUString("Z1"), true) );
+    CPPUNIT_ASSERT_EQUAL( -1, sw_CompareCellRanges(OUString("A1"), OUString("Z1"), OUString("A2"), OUString("Z2"), false) );
+    CPPUNIT_ASSERT_EQUAL( -1, sw_CompareCellRanges(OUString("A1"), OUString("Z1"), OUString("A2"), OUString("Z2"), true) );
+    CPPUNIT_ASSERT_EQUAL( -1, sw_CompareCellRanges(OUString("A1"), OUString("Z1"), OUString("A6"), OUString("Z2"), true) );
+
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellRanges(OUString("B1"), OUString("Z1"), OUString("A1"), OUString("Z1"), true) );
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellRanges(OUString("A2"), OUString("Z2"), OUString("A1"), OUString("Z1"), false) );
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellRanges(OUString("A2"), OUString("Z2"), OUString("A1"), OUString("Z1"), true) );
+    CPPUNIT_ASSERT_EQUAL( +1, sw_CompareCellRanges(OUString("A6"), OUString("Z2"), OUString("A1"), OUString("Z1"), true) );
+}
+
 void SwDocTest::setUp()
 {
     BootstrapFixture::setUp();


More information about the Libreoffice-commits mailing list