summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-01-26 18:04:42 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-01-27 07:48:47 +0000
commit4dc18dd3abf78b8451334e093dc84fb289a83336 (patch)
tree9b54db2eb28ce40c050e810863eb74c2702eb620
parentef99aad5868b308e1a421c3eaa8221f8f78d80d5 (diff)
add test for tdf#97308
Change-Id: If35a3d6ef7af619f9544ba15e994f663581de374 Reviewed-on: https://gerrit.libreoffice.org/21819 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/qa/unit/ucalc.hxx5
-rw-r--r--sc/qa/unit/ucalc_condformat.cxx38
2 files changed, 43 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index b3e5bf396504..9d8562bcc9f7 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -443,6 +443,9 @@ public:
void testDataBarLengthAutomaticAxis();
void testDataBarLengthMiddleAxis();
+ void testCondFormatEndsWithStr();
+ void testCondFormatEndsWithVal();
+
void testImportStream();
void testDeleteContents();
void testTransliterateText();
@@ -675,6 +678,8 @@ public:
CPPUNIT_TEST(testCondCopyPasteSingleCellToRange);
CPPUNIT_TEST(testCondCopyPasteSheetBetweenDoc);
CPPUNIT_TEST(testCondCopyPasteSheet);
+ CPPUNIT_TEST(testCondFormatEndsWithStr);
+ CPPUNIT_TEST(testCondFormatEndsWithVal);
CPPUNIT_TEST(testIconSet);
CPPUNIT_TEST(testDataBarLengthAutomaticAxis);
CPPUNIT_TEST(testDataBarLengthMiddleAxis);
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index d287fe0ff93f..b51b6808b1d3 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -19,6 +19,7 @@
#include "attrib.hxx"
#include "fillinfo.hxx"
+#include <svl/sharedstringpool.hxx>
#include <o3tl/make_unique.hxx>
void Test::testCopyPasteSkipEmptyConditionalFormatting()
@@ -626,5 +627,42 @@ void Test::testDataBarLengthMiddleAxis()
m_pDoc->DeleteTab(0);
}
+void Test::testCondFormatEndsWithStr()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ ScConditionEntry aEntry(SC_COND_ENDS_WITH, "\"TestString\"", "", m_pDoc, ScAddress(),
+ "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
+
+ svl::SharedStringPool& rStringPool = m_pDoc->GetSharedStringPool();
+ svl::SharedString aStr = rStringPool.intern("SimpleTestString");
+ ScRefCellValue aVal(&aStr);
+ ScAddress aPos(0, 0, 0);
+
+ bool bValid = aEntry.IsCellValid(aVal, aPos);
+ CPPUNIT_ASSERT(bValid);
+
+ m_pDoc->DeleteTab(0);
+}
+
+void Test::testCondFormatEndsWithVal()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ ScConditionEntry aEntry(SC_COND_ENDS_WITH, "2", "", m_pDoc, ScAddress(),
+ "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
+
+ for (sal_Int32 i = 0; i < 15; ++i)
+ {
+ ScRefCellValue aVal(i);
+ ScAddress aPos(0, 0, 0);
+
+ bool bValid = aEntry.IsCellValid(aVal, aPos);
+ bool bShouldBeValid = (i % 10) == 2;
+ CPPUNIT_ASSERT_EQUAL(bShouldBeValid, bValid);
+ }
+
+ m_pDoc->DeleteTab(0);
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */