summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-07-12 21:55:59 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-07-12 22:11:12 -0400
commit9e5b1eb98b8e97b184f8c6876b154f47b6e0730d (patch)
tree8665b55b5305d998270b0dab89a671d19a688a51 /sc
parent5902dcf0995cdd0a6c1dbd1f9c21b0b2b3f5609f (diff)
fdo#80462: Write test for this.
Change-Id: Icdc83c0264fd76239e8c8772c207cc22ce969a76
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx36
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 38 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index af272a54a532..b10bf54c7c19 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5025,6 +5025,42 @@ void Test::testSortHorizontal()
m_pDoc->DeleteTab(0);
}
+void Test::testSortSingleRow()
+{
+ // This test case is from fdo#80462.
+
+ m_pDoc->InsertTab(0, "Test");
+
+ // Sort range consists of only one row.
+ m_pDoc->SetString(ScAddress(0,0,0), "X");
+ m_pDoc->SetString(ScAddress(1,0,0), "Y");
+
+ // Define A1:B1 as sheet-local anonymous database range.
+ m_pDoc->SetAnonymousDBData(
+ 0, new ScDBData(STR_DB_LOCAL_NONAME, 0, 0, 0, 1, 0));
+
+ // Sort A1:B1 horizontally, ascending by row 1.
+ ScDBDocFunc aFunc(getDocShell());
+
+ ScSortParam aSortData;
+ aSortData.nCol1 = 0;
+ aSortData.nCol2 = 1;
+ aSortData.nRow1 = 0;
+ aSortData.nRow2 = 0;
+ aSortData.bHasHeader = true;
+ aSortData.bByRow = true;
+ aSortData.bIncludePattern = true;
+ aSortData.maKeyState[0].bDoSort = true;
+ aSortData.maKeyState[0].nField = 0;
+ aSortData.maKeyState[0].bAscending = true;
+
+ // Do the sorting. This should not crash.
+ bool bSorted = aFunc.Sort(0, aSortData, true, true, true);
+ CPPUNIT_ASSERT(bSorted);
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testSortInFormulaGroup()
{
static struct {
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2df47c0f1d0a..c592e692775d 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -341,6 +341,7 @@ public:
void testFindAreaPosColRight();
void testSort();
void testSortHorizontal();
+ void testSortSingleRow();
void testSortWithFormulaRefs();
void testSortWithStrings();
void testSortInFormulaGroup();
@@ -509,6 +510,7 @@ public:
CPPUNIT_TEST(testFindAreaPosColRight);
CPPUNIT_TEST(testSort);
CPPUNIT_TEST(testSortHorizontal);
+ CPPUNIT_TEST(testSortSingleRow);
CPPUNIT_TEST(testSortWithFormulaRefs);
CPPUNIT_TEST(testSortWithStrings);
CPPUNIT_TEST(testSortInFormulaGroup);