Kaydet (Commit) 4796d5dd authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Add unit test for getting data entries. This used to crash at MAXROW.

Change-Id: Ia904f69ddebcbd61e4ad3b97a0ace3db2d3a33e7
üst 9e77ddcd
......@@ -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));
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment