summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-07-12 22:09:10 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-07-12 22:11:12 -0400
commit47a82452b5040cd712ffafb7d153fd18940ee1af (patch)
tree125e87b39b0e8f6b2bc04c0875a22dc214816655
parentfdo#80462: Write test for this. (diff)
downloadcore-47a82452b5040cd712ffafb7d153fd18940ee1af.tar.gz
core-47a82452b5040cd712ffafb7d153fd18940ee1af.zip
Add another test case.
Change-Id: I1664bc3faf44abc978391d0f97820c468f4419b0
-rw-r--r--sc/qa/unit/ucalc.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index b10bf54c7c19..77084271e1ad 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5058,6 +5058,38 @@ void Test::testSortSingleRow()
bool bSorted = aFunc.Sort(0, aSortData, true, true, true);
CPPUNIT_ASSERT(bSorted);
+ // Another test case - single row horizontal sort with header column.
+ clearSheet(m_pDoc, 0);
+
+ // A1:G1
+ m_pDoc->SetString(ScAddress(0,0,0), "Header");
+ m_pDoc->SetValue(ScAddress(1,0,0), 1.0);
+ m_pDoc->SetValue(ScAddress(2,0,0), 10.0);
+ m_pDoc->SetValue(ScAddress(3,0,0), 3.0);
+ m_pDoc->SetValue(ScAddress(4,0,0), 9.0);
+ m_pDoc->SetValue(ScAddress(5,0,0), 12.0);
+ m_pDoc->SetValue(ScAddress(6,0,0), 2.0);
+
+ // Define A1:G1 as sheet-local anonymous database range.
+ m_pDoc->SetAnonymousDBData(
+ 0, new ScDBData(STR_DB_LOCAL_NONAME, 0, 0, 0, 6, 0, false, true));
+
+ // Update the sort data.
+ aSortData.nCol1 = 0;
+ aSortData.nCol2 = 6;
+ aSortData.bByRow = false;
+ bSorted = aFunc.Sort(0, aSortData, true, true, true);
+ CPPUNIT_ASSERT(bSorted);
+
+ // Check the result.
+ CPPUNIT_ASSERT_EQUAL(OUString("Header"), m_pDoc->GetString(ScAddress(0,0,0)));
+ CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+ CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc->GetValue(ScAddress(2,0,0)));
+ CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc->GetValue(ScAddress(3,0,0)));
+ CPPUNIT_ASSERT_EQUAL( 9.0, m_pDoc->GetValue(ScAddress(4,0,0)));
+ CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(5,0,0)));
+ CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(6,0,0)));
+
m_pDoc->DeleteTab(0);
}