Kaydet (Commit) 915b7b5b authored tarafından Kohei Yoshida's avatar Kohei Yoshida

rhbz#1080196: Write unit test for this.

Change-Id: I1c83afa40eaf8c81ca3b436c6fb7d22f7eb9f223
üst 37672f11
...@@ -3414,6 +3414,54 @@ void Test::testCopyPasteTranspose() ...@@ -3414,6 +3414,54 @@ void Test::testCopyPasteTranspose()
} }
void Test::testCopyPasteMultiRange()
{
m_pDoc->InsertTab(0, "Test");
// Fill A2:B6 with numbers.
for (SCROW nRow = 1; nRow <= 5; ++nRow)
{
for (SCCOL nCol = 0; nCol <= 1; ++nCol)
{
ScAddress aPos(nCol,nRow,0);
m_pDoc->SetValue(aPos, nRow+nCol);
}
}
// Fill D9:E11 with numbers.
for (SCROW nRow = 8; nRow <= 10; ++nRow)
{
for (SCCOL nCol = 3; nCol <= 4; ++nCol)
{
ScAddress aPos(nCol,nRow,0);
m_pDoc->SetValue(aPos, 10.0);
}
}
ScMarkData aMark;
aMark.SelectOneTable(0);
// Copy A2:B2, A4:B4, and A6:B6 to clipboard.
ScDocument aClipDoc(SCDOCMODE_CLIP);
ScClipParam aClipParam;
aClipParam.maRanges.Append(ScRange(0,1,0,1,1,0)); // A2:B2
aClipParam.maRanges.Append(ScRange(0,3,0,1,3,0)); // A4:B4
aClipParam.maRanges.Append(ScRange(0,5,0,1,5,0)); // A6:B6
aClipParam.meDirection = ScClipParam::Row;
m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark);
// Paste to D9:E11, and make sure it won't crash (rhbz#1080196).
m_pDoc->CopyMultiRangeFromClip(ScAddress(3,8,0), aMark, IDF_CONTENTS, &aClipDoc);
CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(3,8,0)));
CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(4,8,0)));
CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(3,9,0)));
CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(4,9,0)));
CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(3,10,0)));
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(4,10,0)));
m_pDoc->DeleteTab(0);
}
void Test::testCopyPasteSkipEmpty() void Test::testCopyPasteSkipEmpty()
{ {
struct Check struct Check
......
...@@ -255,6 +255,7 @@ public: ...@@ -255,6 +255,7 @@ public:
void testCopyPaste(); void testCopyPaste();
void testCopyPasteAsLink(); void testCopyPasteAsLink();
void testCopyPasteTranspose(); void testCopyPasteTranspose();
void testCopyPasteMultiRange();
void testCopyPasteSkipEmpty(); void testCopyPasteSkipEmpty();
void testCopyPasteSkipEmptyConditionalFormatting(); void testCopyPasteSkipEmptyConditionalFormatting();
void testUndoCut(); void testUndoCut();
...@@ -435,6 +436,7 @@ public: ...@@ -435,6 +436,7 @@ public:
CPPUNIT_TEST(testCopyPaste); CPPUNIT_TEST(testCopyPaste);
CPPUNIT_TEST(testCopyPasteAsLink); CPPUNIT_TEST(testCopyPasteAsLink);
CPPUNIT_TEST(testCopyPasteTranspose); CPPUNIT_TEST(testCopyPasteTranspose);
CPPUNIT_TEST(testCopyPasteMultiRange);
CPPUNIT_TEST(testCopyPasteSkipEmpty); CPPUNIT_TEST(testCopyPasteSkipEmpty);
//CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting); //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
CPPUNIT_TEST(testUndoCut); CPPUNIT_TEST(testUndoCut);
......
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