sc/qa/unit/ucalc.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ sc/qa/unit/ucalc.hxx | 7 +++++++ 2 files changed, 47 insertions(+)
New commits: commit 4796d5dde115cc56eeddb67f38ce7b9f490e886d Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Mon Jan 6 11:33:00 2014 -0500 Add unit test for getting data entries. This used to crash at MAXROW. Change-Id: Ia904f69ddebcbd61e4ad3b97a0ace3db2d3a33e7 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 283f763..cd0a9f3 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -636,6 +636,46 @@ void Test::testInput() m_pDoc->DeleteTab(0); } +void Test::testDataEntries() +{ + m_pDoc->InsertTab(0, "Test"); + + m_pDoc->SetString(ScAddress(0,5,0), "Andy"); + m_pDoc->SetString(ScAddress(0,6,0), "Bruce"); + m_pDoc->SetString(ScAddress(0,7,0), "Charlie"); + m_pDoc->SetString(ScAddress(0,10,0), "Andy"); + + std::vector<ScTypedStrData> aEntries; + m_pDoc->GetDataEntries(0, 0, 0, true, aEntries); // Try at the very top. + + // Entries are supposed to be sorted in ascending order, and are all unique. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aEntries.size()); + std::vector<ScTypedStrData>::const_iterator it = aEntries.begin(); + CPPUNIT_ASSERT_EQUAL(OUString("Andy"), it->GetString()); + ++it; + CPPUNIT_ASSERT_EQUAL(OUString("Bruce"), it->GetString()); + ++it; + CPPUNIT_ASSERT_EQUAL(OUString("Charlie"), it->GetString()); + ++it; + CPPUNIT_ASSERT_MESSAGE("The entries should have ended here.", it == aEntries.end()); + + aEntries.clear(); + m_pDoc->GetDataEntries(0, MAXROW, 0, true, aEntries); // Try at the very bottom. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aEntries.size()); + + // Make sure we get the same set of suggestions. + it = aEntries.begin(); + CPPUNIT_ASSERT_EQUAL(OUString("Andy"), it->GetString()); + ++it; + CPPUNIT_ASSERT_EQUAL(OUString("Bruce"), it->GetString()); + ++it; + CPPUNIT_ASSERT_EQUAL(OUString("Charlie"), it->GetString()); + ++it; + CPPUNIT_ASSERT_MESSAGE("The entries should have ended here.", it == aEntries.end()); + + m_pDoc->DeleteTab(0); +} + void Test::testCopyAttributes() { CPPUNIT_ASSERT_MESSAGE ("mashed up attributes", !(IDF_ATTRIB & IDF_CONTENTS)); diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 9ccc85a..6bbc86a 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -84,6 +84,12 @@ public: void testRangeList(); void testInput(); + /** + * The 'data entries' data is a list of strings used for suggestions as + * the user types in new cell value. + */ + void testDataEntries(); + void testFormulaCreateStringFromTokens(); void testFormulaParseReference(); void testFetchVectorRefArray(); @@ -299,6 +305,7 @@ public: CPPUNIT_TEST(testSharedStringPool); CPPUNIT_TEST(testRangeList); CPPUNIT_TEST(testInput); + CPPUNIT_TEST(testDataEntries); CPPUNIT_TEST(testFormulaCreateStringFromTokens); CPPUNIT_TEST(testFormulaParseReference); CPPUNIT_TEST(testFetchVectorRefArray); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits