summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorslideon <adamkasztenny@gmail.com>2016-05-21 11:38:15 -0400
committerjan iversen <jani@documentfoundation.org>2016-05-23 06:26:05 +0000
commitf3657368a6cab2e1931c8845035b914e49360eb3 (patch)
treec0809b3f8e14042fa41d79764075d299d94ebb4c /sw
parent945ce7e10a6a215595ec653b8697340a15943888 (diff)
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@libreoffice.org> Reviewed-by: jan iversen <jani@documentfoundation.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/unotbl.hxx2
-rw-r--r--sw/qa/core/uwriter.cxx37
2 files changed, 39 insertions, 0 deletions
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index f7ea6062db18..d902c84c1e27 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 242282da806c..8867b645e588 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();