Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / unit / mark_test.cxx
blob400392d7873ce9ad702b9225e3fe7cc4aaa83c77
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
11 #include <cppunit/TestFixture.h>
12 #include <cppunit/extensions/HelperMacros.h>
13 #include <cppunit/TestAssert.h>
14 #include <cppunit/plugin/TestPlugIn.h>
16 #include <markdata.hxx>
17 #include "../../source/core/data/markarr.cxx"
18 #include "../../source/core/data/markmulti.cxx"
19 #include "../../source/core/data/segmenttree.cxx"
21 #include <utility>
23 struct MarkTestData // To represent a single rectangle part of a multiselection
25 ScRange aRange;
26 bool bMark;
28 // Cumulative Test data follows
29 std::vector<ScAddress> aInsideAddresses;
30 std::vector<ScAddress> aOutsideAddresses;
32 std::vector<SCCOL> aColumnsWithFullMarks;
33 std::vector<SCCOL> aColumnsWithoutFullMarks;
35 std::vector<SCROW> aRowsWithFullMarks;
36 std::vector<SCROW> aRowsWithoutFullMarks;
38 std::vector<ScRange> aRangesWithFullMarks;
39 std::vector<ScRange> aRangesWithoutFullMarks;
41 // To test ScMarkData::GetNextMarked()
42 // Encoding : EndRow is the next marked row in the column = StartCol after StartRow.
43 // EndCol = 0 means search up, 1 means to search down
44 std::vector<ScRange> aNextMarked;
46 std::vector<SCCOL> aColumnsWithAtLeastOneMark;
47 std::vector<SCCOL> aColumnsWithoutAnyMarks;
51 struct MarkArrayTestData
53 SCCOL nCol;
54 std::vector<std::pair<SCROW,SCROW>> aMarkedRowSegs;
57 struct MultiMarkTestData
59 std::vector<MarkTestData> aMarks;
60 ScRange aSelectionCover;
61 ScRangeList aLeftEnvelope;
62 ScRangeList aRightEnvelope;
63 ScRangeList aTopEnvelope;
64 ScRangeList aBottomEnvelope;
65 std::vector<MarkArrayTestData> aMarkArrays;
67 // To test ScMultiSel::HasOneMark()
68 // Encoding : StartCol is the column to test, StartRow is the beginning of the one mark,
69 // EndRow is the end of the one mark, EndCol is not used
70 std::vector<ScRange> aColsWithOneMark;
71 std::vector<SCCOL> aColsWithoutOneMark;
73 // To test ScMultiSel::IsAllMarked()
74 // Encoding StartCol is the column to be queried, [StartRow,EndRow] is the range to test.
75 std::vector<ScRange> aColsAllMarked;
76 std::vector<ScRange> aColsNotAllMarked;
78 // To test ScMultiSel::HasEqualRowsMarked()
79 std::vector<std::pair<SCCOL,SCCOL>> aColsWithEqualMarksList;
80 std::vector<std::pair<SCCOL,SCCOL>> aColsWithUnequalMarksList;
83 class Test : public CppUnit::TestFixture
85 public:
86 void testSimpleMark( const ScRange& rRange, const ScRange& rSelectionCover,
87 const ScRangeList& rLeftEnvelope, const ScRangeList& rRightEnvelope,
88 const ScRangeList& rTopEnvelope, const ScRangeList& rBottomEnvelope );
89 void testSimpleMark_Simple();
90 void testSimpleMark_Column();
91 void testSimpleMark_Row();
93 void testMultiMark( const MultiMarkTestData& rData );
94 void testMultiMark_FourRanges();
95 void testMultiMark_NegativeMarking();
97 void testInsertTabBeforeSelected();
98 void testInsertTabAfterSelected();
99 void testDeleteTabBeforeSelected();
100 void testDeleteTabAfterSelected();
102 void testScMarkArraySearch();
104 CPPUNIT_TEST_SUITE(Test);
105 CPPUNIT_TEST(testSimpleMark_Simple);
106 CPPUNIT_TEST(testSimpleMark_Column);
107 CPPUNIT_TEST(testSimpleMark_Row);
108 CPPUNIT_TEST(testMultiMark_FourRanges);
109 CPPUNIT_TEST(testMultiMark_NegativeMarking);
110 CPPUNIT_TEST(testInsertTabBeforeSelected);
111 CPPUNIT_TEST(testInsertTabAfterSelected);
112 CPPUNIT_TEST(testDeleteTabBeforeSelected);
113 CPPUNIT_TEST(testDeleteTabAfterSelected);
114 CPPUNIT_TEST(testScMarkArraySearch);
115 CPPUNIT_TEST_SUITE_END();
117 private:
118 void testScMarkArraySearch_check(const ScMarkArray & ar, SCROW nRow, bool expectStatus, SCSIZE nIndexExpect);
121 static void lcl_GetSortedRanges( const ScRangeList& rRangeList, ScRangeList& rRangeListOut )
123 rRangeListOut.RemoveAll();
124 std::vector<ScRange> aRanges;
125 size_t nSize = rRangeList.size();
126 aRanges.reserve( nSize );
127 for ( size_t nIdx = 0; nIdx < nSize; ++nIdx )
128 aRanges.push_back( rRangeList[nIdx] );
129 std::sort( aRanges.begin(), aRanges.end() );
130 for ( size_t nIdx = 0; nIdx < nSize; ++nIdx )
131 rRangeListOut.push_back( aRanges[nIdx] );
134 void Test::testSimpleMark( const ScRange& rRange, const ScRange& rSelectionCover,
135 const ScRangeList& rLeftEnvelope, const ScRangeList& rRightEnvelope,
136 const ScRangeList& rTopEnvelope, const ScRangeList& rBottomEnvelope )
138 ScMarkData aMark(MAXROW, MAXCOL);
139 CPPUNIT_ASSERT( !aMark.IsMarked() && !aMark.IsMultiMarked() );
141 aMark.SetMarkArea( rRange );
142 CPPUNIT_ASSERT( aMark.IsMarked() && !aMark.IsMultiMarked() );
144 ScRange aRangeResult;
145 aMark.GetMarkArea( aRangeResult );
146 CPPUNIT_ASSERT_EQUAL( rRange, aRangeResult );
148 SCROW nMidRow = ( rRange.aStart.Row() + rRange.aEnd.Row() ) / 2;
149 SCCOL nMidCol = ( rRange.aStart.Col() + rRange.aEnd.Col() ) / 2;
150 SCROW nOutRow1 = rRange.aEnd.Row() + 1;
151 SCCOL nOutCol1 = rRange.aEnd.Col() + 1;
152 SCROW nOutRow2 = rRange.aStart.Row() - 1;
153 SCCOL nOutCol2 = rRange.aStart.Col() - 1;
155 CPPUNIT_ASSERT( aMark.IsCellMarked( nMidCol, nMidRow ) );
156 if ( ValidCol( nOutCol1 ) && ValidRow( nOutRow1 ) )
157 CPPUNIT_ASSERT( !aMark.IsCellMarked( nOutCol1, nOutRow1 ) );
159 if ( ValidCol( nOutCol2 ) && ValidRow( nOutRow2 ) )
160 CPPUNIT_ASSERT( !aMark.IsCellMarked( nOutCol2, nOutRow2 ) );
162 if ( ValidRow( nOutRow1 ) )
163 CPPUNIT_ASSERT( !aMark.IsCellMarked( nMidCol, nOutRow1 ) );
165 if ( ValidCol( nOutCol1 ) )
166 CPPUNIT_ASSERT( !aMark.IsCellMarked( nOutCol1, nMidRow ) );
168 if ( ValidRow( nOutRow2 ) )
169 CPPUNIT_ASSERT( !aMark.IsCellMarked( nMidCol, nOutRow2 ) );
171 if ( ValidCol( nOutCol2 ) )
172 CPPUNIT_ASSERT( !aMark.IsCellMarked( nOutCol2, nMidRow ) );
174 if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
175 CPPUNIT_ASSERT( aMark.IsColumnMarked( nMidCol ) );
176 else
177 CPPUNIT_ASSERT( !aMark.IsColumnMarked( nMidCol ) );
178 if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL )
179 CPPUNIT_ASSERT( aMark.IsRowMarked( nMidRow ) );
180 else
181 CPPUNIT_ASSERT( !aMark.IsRowMarked( nMidRow ) );
183 ScRange aSelectionCoverOutput;
184 aMark.GetSelectionCover( aSelectionCoverOutput );
185 CPPUNIT_ASSERT_EQUAL( rSelectionCover, aSelectionCoverOutput );
186 CPPUNIT_ASSERT_EQUAL( rLeftEnvelope, aMark.GetLeftEnvelope() );
187 CPPUNIT_ASSERT_EQUAL( rRightEnvelope, aMark.GetRightEnvelope() );
188 CPPUNIT_ASSERT_EQUAL( rTopEnvelope, aMark.GetTopEnvelope() );
189 CPPUNIT_ASSERT_EQUAL( rBottomEnvelope, aMark.GetBottomEnvelope() );
192 void Test::testSimpleMark_Simple()
194 testSimpleMark( ScRange( 10, 15, 0, 20, 30, 0 ), // Simple range
195 ScRange( 9, 14, 0, 21, 31, 0 ), // Cover
196 ScRangeList( ScRange( 9, 15, 0, 9, 30, 0 ) ), // Left envelope
197 ScRangeList( ScRange( 21, 15, 0, 21, 30, 0 ) ), // Right envelope
198 ScRangeList( ScRange( 10, 14, 0, 20, 14, 0 ) ), // Top envelope
199 ScRangeList( ScRange( 10, 31, 0, 20, 31, 0 ) ) ); // Bottom envelope
202 void Test::testSimpleMark_Column()
204 // Column 10, rows from 15 to 30
205 testSimpleMark( ScRange( 10, 15, 0, 10, 30, 0 ), // Simple range
206 ScRange( 9, 14, 0, 11, 31, 0 ), // Cover
207 ScRangeList( ScRange( 9, 15, 0, 9, 30, 0 ) ), // Left envelope
208 ScRangeList( ScRange( 11, 15, 0, 11, 30, 0 ) ), // Right envelope
209 ScRangeList( ScRange( 10, 14, 0, 10, 14, 0 ) ), // Top envelope
210 ScRangeList( ScRange( 10, 31, 0, 10, 31, 0 ) ) ); // Bottom envelope
212 // Full Column 10
213 testSimpleMark( ScRange( 10, 0, 0, 10, MAXROW, 0 ), // Simple range
214 ScRange( 9, 0, 0, 11, MAXROW, 0 ), // Cover
215 ScRangeList( ScRange( 9, 0, 0, 9, MAXROW, 0 ) ), // Left envelope
216 ScRangeList( ScRange( 11, 0, 0, 11, MAXROW, 0 ) ), // Right envelope
217 ScRangeList(), // Top envelope
218 ScRangeList()); // Bottom envelope
221 void Test::testSimpleMark_Row()
223 // Row 15, cols from 10 to 20
224 testSimpleMark( ScRange( 10, 15, 0, 20, 15, 0 ), // Simple range
225 ScRange( 9, 14, 0, 21, 16, 0 ), // Cover
226 ScRangeList( ScRange( 9, 15, 0, 9, 15, 0 ) ), // Left envelope
227 ScRangeList( ScRange( 21, 15, 0, 21, 15, 0 ) ), // Right envelope
228 ScRangeList( ScRange( 10, 14, 0, 20, 14, 0 ) ), // Top envelope
229 ScRangeList( ScRange( 10, 16, 0, 20, 16, 0 ) ) ); // Bottom envelope
231 // Full Row 15
232 testSimpleMark( ScRange( 0, 15, 0, MAXCOL, 15, 0 ), // Simple range
233 ScRange( 0, 14, 0, MAXCOL, 16, 0 ), // Cover
234 ScRangeList(), // Left envelope
235 ScRangeList(), // Right envelope
236 ScRangeList( ScRange( 0, 14, 0, MAXCOL, 14, 0 ) ), // Top envelope
237 ScRangeList( ScRange( 0, 16, 0, MAXCOL, 16, 0 ) ) ); // Bottom envelope
240 void Test::testMultiMark( const MultiMarkTestData& rMarksData )
243 ScMarkData aMark(MAXROW, MAXCOL);
244 ScMultiSel aMultiSel(MAXROW, MAXCOL);
245 CPPUNIT_ASSERT( !aMark.IsMarked() && !aMark.IsMultiMarked() );
246 CPPUNIT_ASSERT_EQUAL( SCCOL(0), aMultiSel.GetMultiSelectionCount() );
247 CPPUNIT_ASSERT( !aMultiSel.HasAnyMarks() );
249 for ( const auto& rAreaTestData : rMarksData.aMarks )
251 aMultiSel.SetMarkArea( rAreaTestData.aRange.aStart.Col(), rAreaTestData.aRange.aEnd.Col(),
252 rAreaTestData.aRange.aStart.Row(), rAreaTestData.aRange.aEnd.Row(),
253 rAreaTestData.bMark );
254 aMark.SetMultiMarkArea( rAreaTestData.aRange, rAreaTestData.bMark );
255 CPPUNIT_ASSERT( aMark.IsMultiMarked() );
257 for ( const auto& rMarkedAddress : rAreaTestData.aInsideAddresses )
259 CPPUNIT_ASSERT( aMultiSel.GetMark( rMarkedAddress.Col(), rMarkedAddress.Row() ) );
260 CPPUNIT_ASSERT( aMark.IsCellMarked( rMarkedAddress.Col(), rMarkedAddress.Row() ) );
263 for ( const auto& rUnMarkedAddress : rAreaTestData.aOutsideAddresses )
265 CPPUNIT_ASSERT( !aMark.IsCellMarked( rUnMarkedAddress.Col(), rUnMarkedAddress.Row() ) );
266 CPPUNIT_ASSERT( !aMark.IsCellMarked( rUnMarkedAddress.Col(), rUnMarkedAddress.Row() ) );
269 for ( const auto& rCol : rAreaTestData.aColumnsWithFullMarks )
271 CPPUNIT_ASSERT( aMark.IsColumnMarked( rCol ) );
272 CPPUNIT_ASSERT( aMultiSel.IsAllMarked( rCol, 0, MAXROW ) );
275 for ( const auto& rCol : rAreaTestData.aColumnsWithoutFullMarks )
277 CPPUNIT_ASSERT( !aMark.IsColumnMarked( rCol ) );
278 CPPUNIT_ASSERT( !aMultiSel.IsAllMarked( rCol, 0, MAXROW ) );
281 for ( const auto& rRow : rAreaTestData.aRowsWithFullMarks )
283 CPPUNIT_ASSERT( aMark.IsRowMarked( rRow ) );
284 CPPUNIT_ASSERT( aMultiSel.IsRowMarked( rRow ) );
287 for ( const auto& rRow : rAreaTestData.aRowsWithoutFullMarks )
289 CPPUNIT_ASSERT( !aMark.IsRowMarked( rRow ) );
290 CPPUNIT_ASSERT( !aMultiSel.IsRowMarked( rRow ) );
293 for ( const auto& rRange : rAreaTestData.aRangesWithFullMarks )
295 CPPUNIT_ASSERT( aMark.IsAllMarked( rRange ) );
296 SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
297 SCCOL nCol1 = rRange.aStart.Col(), nCol2 = rRange.aEnd.Col();
298 for ( SCROW nColIter = nCol1; nColIter <= nCol2; ++nColIter )
299 CPPUNIT_ASSERT( aMultiSel.IsAllMarked( nColIter, nRow1, nRow2 ) );
302 for ( const auto& rRange : rAreaTestData.aRangesWithoutFullMarks )
303 CPPUNIT_ASSERT( !aMark.IsAllMarked( rRange ) );
305 for ( const auto& rRange : rAreaTestData.aNextMarked )
307 SCROW nNextRow1 = aMark.GetNextMarked( rRange.aStart.Col(), rRange.aStart.Row(), !static_cast<bool>(rRange.aEnd.Col()) );
308 CPPUNIT_ASSERT_EQUAL( rRange.aEnd.Row(), nNextRow1 );
309 SCROW nNextRow2 = aMultiSel.GetNextMarked( rRange.aStart.Col(), rRange.aStart.Row(), !static_cast<bool>(rRange.aEnd.Col()) );
310 CPPUNIT_ASSERT_EQUAL( rRange.aEnd.Row(), nNextRow2 );
313 for ( const auto& rCol : rAreaTestData.aColumnsWithAtLeastOneMark )
315 CPPUNIT_ASSERT( aMark.HasMultiMarks( rCol ) );
316 CPPUNIT_ASSERT( aMultiSel.HasMarks( rCol ) );
319 for ( const auto& rCol : rAreaTestData.aColumnsWithoutAnyMarks )
321 CPPUNIT_ASSERT( !aMark.HasMultiMarks( rCol ) );
322 CPPUNIT_ASSERT( !aMultiSel.HasMarks( rCol ) );
327 ScRange aSelectionCoverOutput;
328 aMark.GetSelectionCover( aSelectionCoverOutput );
329 CPPUNIT_ASSERT_EQUAL( rMarksData.aSelectionCover, aSelectionCoverOutput );
331 ScRangeList aRangesExpected, aRangesActual;
332 lcl_GetSortedRanges( rMarksData.aLeftEnvelope, aRangesExpected );
333 lcl_GetSortedRanges( aMark.GetLeftEnvelope(), aRangesActual );
334 CPPUNIT_ASSERT_EQUAL( aRangesExpected, aRangesActual );
335 lcl_GetSortedRanges( rMarksData.aRightEnvelope, aRangesExpected );
336 lcl_GetSortedRanges( aMark.GetRightEnvelope(), aRangesActual );
337 CPPUNIT_ASSERT_EQUAL( aRangesExpected, aRangesActual );
338 lcl_GetSortedRanges( rMarksData.aTopEnvelope, aRangesExpected );
339 lcl_GetSortedRanges( aMark.GetTopEnvelope(), aRangesActual );
340 CPPUNIT_ASSERT_EQUAL( aRangesExpected, aRangesActual );
341 lcl_GetSortedRanges( rMarksData.aBottomEnvelope, aRangesExpected );
342 lcl_GetSortedRanges( aMark.GetBottomEnvelope(), aRangesActual );
343 CPPUNIT_ASSERT_EQUAL( aRangesExpected, aRangesActual );
345 for ( const auto& rMarkArrayTestData : rMarksData.aMarkArrays )
347 ScMarkArray aArray( aMark.GetMarkArray( rMarkArrayTestData.nCol ) );
348 std::vector<std::pair<SCROW, SCROW>> aMarkedRowSegs;
349 ScMarkArrayIter aIter( &aArray );
350 SCROW nStart, nEnd;
351 while ( aIter.Next( nStart, nEnd ) )
352 aMarkedRowSegs.emplace_back( nStart, nEnd );
354 CPPUNIT_ASSERT_EQUAL( rMarkArrayTestData.aMarkedRowSegs.size(), aMarkedRowSegs.size() );
355 size_t nIdx = 0;
356 for ( const auto& rPair : rMarkArrayTestData.aMarkedRowSegs )
358 CPPUNIT_ASSERT_EQUAL( rPair.first, aMarkedRowSegs[nIdx].first );
359 CPPUNIT_ASSERT_EQUAL( rPair.second, aMarkedRowSegs[nIdx].second );
360 ++nIdx;
364 for ( const auto& rColWithOneMark : rMarksData.aColsWithOneMark )
366 SCROW nRow1 = -1, nRow2 = -1;
367 CPPUNIT_ASSERT( aMultiSel.HasOneMark( rColWithOneMark.aStart.Col(), nRow1, nRow2 ) );
368 CPPUNIT_ASSERT_EQUAL( rColWithOneMark.aStart.Row(), nRow1 );
369 CPPUNIT_ASSERT_EQUAL( rColWithOneMark.aEnd.Row(), nRow2 );
373 SCROW nRow1 = -1, nRow2 = -1;
374 for ( const SCCOL& rCol : rMarksData.aColsWithoutOneMark )
375 CPPUNIT_ASSERT( !aMultiSel.HasOneMark( rCol, nRow1, nRow2 ) );
378 for ( const auto& rColAllMarked : rMarksData.aColsAllMarked )
379 CPPUNIT_ASSERT( aMultiSel.IsAllMarked( rColAllMarked.aStart.Col(),
380 rColAllMarked.aStart.Row(),
381 rColAllMarked.aEnd.Row() ) );
383 for ( const auto& rColNotAllMarked : rMarksData.aColsNotAllMarked )
384 CPPUNIT_ASSERT( !aMultiSel.IsAllMarked( rColNotAllMarked.aStart.Col(),
385 rColNotAllMarked.aStart.Row(),
386 rColNotAllMarked.aEnd.Row() ) );
388 for ( const auto& rColsWithEqualMarks : rMarksData.aColsWithEqualMarksList )
389 CPPUNIT_ASSERT( aMultiSel.HasEqualRowsMarked( rColsWithEqualMarks.first, rColsWithEqualMarks.second ) );
391 for ( const auto& rColsWithUnequalMarks : rMarksData.aColsWithUnequalMarksList )
392 CPPUNIT_ASSERT( !aMultiSel.HasEqualRowsMarked( rColsWithUnequalMarks.first, rColsWithUnequalMarks.second ) );
394 aMultiSel.Clear();
395 CPPUNIT_ASSERT_EQUAL( SCCOL(0), aMultiSel.GetMultiSelectionCount() );
396 CPPUNIT_ASSERT( !aMultiSel.HasAnyMarks() );
399 void Test::testMultiMark_FourRanges()
401 MultiMarkTestData aData;
402 MarkTestData aSingle1;
404 // Create rectangle ( 10, 5, 20, 10 )
405 aSingle1.aRange = ScRange( 10, 5, 0, 20, 10, 0 );
406 aSingle1.bMark = true;
408 aSingle1.aInsideAddresses.emplace_back( 15, 6, 0 );
409 aSingle1.aInsideAddresses.emplace_back( 10, 5, 0 );
410 aSingle1.aInsideAddresses.emplace_back( 20, 5, 0 );
411 aSingle1.aInsideAddresses.emplace_back( 10, 10, 0 );
412 aSingle1.aInsideAddresses.emplace_back( 20, 10, 0 );
414 aSingle1.aOutsideAddresses.emplace_back( 15, 4, 0 );
415 aSingle1.aOutsideAddresses.emplace_back( 15, 11, 0 );
416 aSingle1.aOutsideAddresses.emplace_back( 9, 6, 0 );
417 aSingle1.aOutsideAddresses.emplace_back( 21, 6, 0 );
418 aSingle1.aOutsideAddresses.emplace_back( 26, 10, 0 );
420 aSingle1.aColumnsWithoutFullMarks.push_back( 16 );
421 aSingle1.aColumnsWithoutFullMarks.push_back( 21 );
423 aSingle1.aRowsWithoutFullMarks.push_back( 7 );
424 aSingle1.aRowsWithoutFullMarks.push_back( 11 );
426 aSingle1.aRangesWithFullMarks.emplace_back( 10, 5, 0, 20, 10, 0 );
427 aSingle1.aRangesWithFullMarks.emplace_back( 11, 6, 0, 19, 8, 0 );
429 aSingle1.aRangesWithoutFullMarks.emplace_back( 9, 4, 0, 21, 11, 0 );
430 aSingle1.aRangesWithoutFullMarks.emplace_back( 25, 7, 0, 30, 15, 0 );
432 aSingle1.aNextMarked.emplace_back( 15, 1, 0, 1, 5, 0 ); // Search down
433 aSingle1.aNextMarked.emplace_back( 15, 15, 0, 0, 10, 0 ); // Search up
435 aSingle1.aNextMarked.emplace_back( 15, 15, 0, 1, MAXROWCOUNT, 0 ); // Search down fail
436 aSingle1.aNextMarked.emplace_back( 15, 4, 0, 0, -1, 0 ); // Search up fail
438 aSingle1.aColumnsWithAtLeastOneMark.push_back( 10 );
439 aSingle1.aColumnsWithAtLeastOneMark.push_back( 15 );
440 aSingle1.aColumnsWithAtLeastOneMark.push_back( 20 );
442 aSingle1.aColumnsWithoutAnyMarks.push_back( 21 );
443 aSingle1.aColumnsWithoutAnyMarks.push_back( 9 );
445 // Create rectangle ( 25, 7, 30, 15 )
446 MarkTestData aSingle2;
447 aSingle2.aRange = ScRange( 25, 7, 0, 30, 15, 0 );
448 aSingle2.bMark = true;
450 aSingle2.aInsideAddresses = aSingle1.aInsideAddresses;
451 aSingle2.aInsideAddresses.emplace_back( 27, 10, 0 );
452 aSingle2.aInsideAddresses.emplace_back( 25, 7, 0 );
453 aSingle2.aInsideAddresses.emplace_back( 30, 7, 0 );
454 aSingle2.aInsideAddresses.emplace_back( 25, 15, 0 );
455 aSingle2.aInsideAddresses.emplace_back( 30, 15, 0 );
457 aSingle2.aOutsideAddresses.emplace_back( 15, 4, 0 );
458 aSingle2.aOutsideAddresses.emplace_back( 15, 11, 0 );
459 aSingle2.aOutsideAddresses.emplace_back( 9, 6, 0 );
460 aSingle2.aOutsideAddresses.emplace_back( 21, 6, 0 );
461 aSingle2.aOutsideAddresses.emplace_back( 26, 6, 0 );
462 aSingle2.aOutsideAddresses.emplace_back( 26, 16, 0 );
463 aSingle2.aOutsideAddresses.emplace_back( 24, 8, 0 );
464 aSingle2.aOutsideAddresses.emplace_back( 31, 11, 0 );
466 aSingle2.aColumnsWithoutFullMarks = aSingle1.aColumnsWithoutAnyMarks;
468 aSingle2.aRowsWithoutFullMarks = aSingle1.aRowsWithoutFullMarks;
470 aSingle2.aRangesWithFullMarks = aSingle1.aRangesWithFullMarks;
471 aSingle2.aRangesWithFullMarks.emplace_back( 25, 7, 0, 30, 15, 0 );
472 aSingle2.aRangesWithFullMarks.emplace_back( 26, 8, 0, 29, 14, 0 );
474 aSingle2.aRangesWithoutFullMarks.emplace_back( 9, 4, 0, 21, 11, 0 );
475 aSingle2.aRangesWithoutFullMarks.emplace_back( 24, 6, 0, 31, 16, 0 );
476 aSingle2.aRangesWithoutFullMarks.emplace_back( 10, 5, 0, 30, 15, 0 );
478 aSingle2.aNextMarked.emplace_back( 27, 16, 0, 0, 15, 0 ); // up ok
479 aSingle2.aNextMarked.emplace_back( 27, 4, 0, 1, 7, 0 ); // down ok
480 aSingle2.aNextMarked.emplace_back( 27, 4, 0, 0, -1, 0 ); // up fail
481 aSingle2.aNextMarked.emplace_back( 27, 16, 0, 1, MAXROWCOUNT, 0 ); // down fail
483 aSingle2.aColumnsWithAtLeastOneMark = aSingle1.aColumnsWithAtLeastOneMark;
484 aSingle2.aColumnsWithAtLeastOneMark.push_back( 25 );
485 aSingle2.aColumnsWithAtLeastOneMark.push_back( 27 );
486 aSingle2.aColumnsWithAtLeastOneMark.push_back( 30 );
488 aSingle2.aColumnsWithoutAnyMarks.push_back( 9 );
489 aSingle2.aColumnsWithoutAnyMarks.push_back( 21 );
490 aSingle2.aColumnsWithoutAnyMarks.push_back( 24 );
491 aSingle2.aColumnsWithoutAnyMarks.push_back( 31 );
493 // Full row = 20
494 MarkTestData aSingle3;
496 aSingle3.aRange = ScRange( 0, 20, 0, MAXCOL, 20, 0 );
497 aSingle3.bMark = true;
499 aSingle3.aInsideAddresses = aSingle2.aInsideAddresses;
500 aSingle3.aInsideAddresses.emplace_back( 5, 20, 0 );
501 aSingle3.aInsideAddresses.emplace_back( 100, 20, 0 );
503 aSingle3.aOutsideAddresses.emplace_back( 0, 21, 0 );
504 aSingle3.aOutsideAddresses.emplace_back( 27, 19, 0 );
506 aSingle3.aColumnsWithoutFullMarks = aSingle2.aColumnsWithoutAnyMarks;
508 aSingle3.aRowsWithFullMarks.push_back( 20 );
510 aSingle3.aRangesWithFullMarks = aSingle2.aRangesWithFullMarks;
511 aSingle3.aRangesWithFullMarks.emplace_back( 0, 20, 0, MAXCOL, 20, 0 );
512 aSingle3.aRangesWithFullMarks.emplace_back( 15, 20, 0, 55, 20, 0 );
514 aSingle3.aNextMarked.emplace_back( 15, 16, 0, 0, 10, 0 ); // up ok
515 aSingle3.aNextMarked.emplace_back( 15, 16, 0, 1, 20, 0 ); // down ok
516 aSingle3.aNextMarked.emplace_back( 22, 15, 0, 0, -1, 0 ); // up fail
517 aSingle3.aNextMarked.emplace_back( 22, 25, 0, 1, MAXROWCOUNT, 0 ); // down fail
519 aSingle3.aColumnsWithAtLeastOneMark = aSingle2.aColumnsWithAtLeastOneMark;
520 aSingle3.aColumnsWithAtLeastOneMark.push_back( 39 );
522 // Full col = 35
523 MarkTestData aSingle4;
525 aSingle4.aRange = ScRange( 35, 0, 0, 35, MAXROW, 0 );
526 aSingle4.bMark = true;
528 aSingle4.aInsideAddresses = aSingle3.aInsideAddresses;
529 aSingle4.aInsideAddresses.emplace_back( 35, 10, 0 );
530 aSingle4.aInsideAddresses.emplace_back( 35, 25, 0 );
532 aSingle4.aOutsideAddresses.emplace_back( 33, 10, 0 );
533 aSingle4.aOutsideAddresses.emplace_back( 39, 10, 0 );
534 aSingle4.aOutsideAddresses.emplace_back( 33, 25, 0 );
535 aSingle4.aOutsideAddresses.emplace_back( 39, 25, 0 );
537 aSingle4.aColumnsWithFullMarks.push_back( 35 );
539 aSingle4.aRowsWithFullMarks.push_back( 20 );
541 aSingle4.aRangesWithFullMarks = aSingle3.aRangesWithFullMarks;
542 aSingle4.aRangesWithFullMarks.emplace_back( 35, 0, 0, 35, MAXROW, 0 );
543 aSingle4.aRangesWithFullMarks.emplace_back( 35, 10, 0, 35, 25, 0 );
545 // Add the rectangle data to aData
546 aData.aMarks.push_back( aSingle1 );
547 aData.aMarks.push_back( aSingle2 );
548 aData.aMarks.push_back( aSingle3 );
549 aData.aMarks.push_back( aSingle4 );
551 aData.aSelectionCover = ScRange( 0, 0, 0, MAXCOL, MAXROW, 0 );
552 aData.aLeftEnvelope.push_back( ScRange( 9, 5, 0, 9, 10, 0 ) );
553 aData.aLeftEnvelope.push_back( ScRange( 24, 7, 0, 24, 15, 0 ) );
554 aData.aLeftEnvelope.push_back( ScRange( 34, 0, 0, 34, 19, 0 ) );
555 aData.aLeftEnvelope.push_back( ScRange( 34, 21, 0, 34, MAXROW, 0 ) );
557 aData.aRightEnvelope.push_back( ScRange( 21, 5, 0, 21, 10, 0 ) );
558 aData.aRightEnvelope.push_back( ScRange( 31, 7, 0, 31, 15, 0 ) );
559 aData.aRightEnvelope.push_back( ScRange( 36, 0, 0, 36, 19, 0 ) );
560 aData.aRightEnvelope.push_back( ScRange( 36, 21, 0, 36, MAXROW, 0 ) );
562 aData.aTopEnvelope.push_back( ScRange( 10, 4, 0, 20, 4, 0 ) );
563 aData.aTopEnvelope.push_back( ScRange( 25, 6, 0, 30, 6, 0 ) );
564 aData.aTopEnvelope.push_back( ScRange( 0, 19, 0, 34, 19, 0 ) );
565 aData.aTopEnvelope.push_back( ScRange( 36, 19, 0, MAXCOL, 19, 0 ) );
567 aData.aBottomEnvelope.push_back( ScRange( 10, 11, 0, 20, 11, 0 ) );
568 aData.aBottomEnvelope.push_back( ScRange( 25, 16, 0, 30, 16, 0 ) );
569 aData.aBottomEnvelope.push_back( ScRange( 0, 21, 0, 34, 21, 0 ) );
570 aData.aBottomEnvelope.push_back( ScRange( 36, 21, 0, MAXCOL, 21, 0 ) );
572 MarkArrayTestData aMarkArrayTestData1;
573 aMarkArrayTestData1.nCol = 5;
574 aMarkArrayTestData1.aMarkedRowSegs.emplace_back( 20, 20 );
576 MarkArrayTestData aMarkArrayTestData2;
577 aMarkArrayTestData2.nCol = 15;
578 aMarkArrayTestData2.aMarkedRowSegs.emplace_back( 5, 10 );
579 aMarkArrayTestData2.aMarkedRowSegs.emplace_back( 20, 20 );
581 MarkArrayTestData aMarkArrayTestData3;
582 aMarkArrayTestData3.nCol = 22;
583 aMarkArrayTestData3.aMarkedRowSegs.emplace_back( 20, 20 );
585 MarkArrayTestData aMarkArrayTestData4;
586 aMarkArrayTestData4.nCol = 27;
587 aMarkArrayTestData4.aMarkedRowSegs.emplace_back( 7, 15 );
588 aMarkArrayTestData4.aMarkedRowSegs.emplace_back( 20, 20 );
590 MarkArrayTestData aMarkArrayTestData5;
591 aMarkArrayTestData5.nCol = 33;
592 aMarkArrayTestData5.aMarkedRowSegs.emplace_back( 20, 20 );
594 MarkArrayTestData aMarkArrayTestData6;
595 aMarkArrayTestData6.nCol = 35;
596 aMarkArrayTestData6.aMarkedRowSegs.emplace_back( 0, MAXROW );
598 MarkArrayTestData aMarkArrayTestData7;
599 aMarkArrayTestData7.nCol = 40;
600 aMarkArrayTestData7.aMarkedRowSegs.emplace_back( 20, 20 );
602 aData.aMarkArrays.push_back( aMarkArrayTestData1 );
603 aData.aMarkArrays.push_back( aMarkArrayTestData2 );
604 aData.aMarkArrays.push_back( aMarkArrayTestData3 );
605 aData.aMarkArrays.push_back( aMarkArrayTestData4 );
606 aData.aMarkArrays.push_back( aMarkArrayTestData5 );
607 aData.aMarkArrays.push_back( aMarkArrayTestData6 );
608 aData.aMarkArrays.push_back( aMarkArrayTestData7 );
610 aData.aColsWithOneMark.emplace_back( 5, 20, 0, 0, 20, 0 );
611 aData.aColsWithOneMark.emplace_back( 22, 20, 0, 0, 20, 0 );
612 aData.aColsWithOneMark.emplace_back( 32, 20, 0, 0, 20, 0 );
613 aData.aColsWithOneMark.emplace_back( 35, 0, 0, 0, MAXROW, 0 );
614 aData.aColsWithOneMark.emplace_back( 50, 20, 0, 0, 20, 0 );
616 aData.aColsWithoutOneMark.push_back( 10 );
617 aData.aColsWithoutOneMark.push_back( 15 );
618 aData.aColsWithoutOneMark.push_back( 20 );
619 aData.aColsWithoutOneMark.push_back( 25 );
620 aData.aColsWithoutOneMark.push_back( 30 );
622 aData.aColsAllMarked.emplace_back( 10, 5, 0, 0, 10, 0 );
623 aData.aColsAllMarked.emplace_back( 15, 5, 0, 0, 10, 0 );
624 aData.aColsAllMarked.emplace_back( 5, 20, 0, 0, 20, 0 );
625 aData.aColsAllMarked.emplace_back( 10, 20, 0, 0, 20, 0 );
626 aData.aColsAllMarked.emplace_back( 25, 7, 0, 0, 15, 0 );
627 aData.aColsAllMarked.emplace_back( 30, 7, 0, 0, 15, 0 );
628 aData.aColsAllMarked.emplace_back( 35, 0, 0, 0, MAXROW, 0 );
629 aData.aColsAllMarked.emplace_back( 100, 20, 0, 0, 20, 0 );
631 aData.aColsNotAllMarked.emplace_back( 5, 5, 0, 0, 25, 0 );
632 aData.aColsNotAllMarked.emplace_back( 15, 5, 0, 0, 25, 0 );
633 aData.aColsNotAllMarked.emplace_back( 22, 15, 0, 0, 25, 0 );
634 aData.aColsNotAllMarked.emplace_back( 27, 7, 0, 0, 20, 0 );
635 aData.aColsNotAllMarked.emplace_back( 100, 19, 0, 0, 21, 0 );
637 aData.aColsWithEqualMarksList.emplace_back( 0, 9 );
638 aData.aColsWithEqualMarksList.emplace_back( 10, 20 );
639 aData.aColsWithEqualMarksList.emplace_back( 21, 24 );
640 aData.aColsWithEqualMarksList.emplace_back( 25, 30 );
641 aData.aColsWithEqualMarksList.emplace_back( 31, 34 );
642 aData.aColsWithEqualMarksList.emplace_back( 36, 100 );
643 aData.aColsWithEqualMarksList.emplace_back( 0, 22 );
644 aData.aColsWithEqualMarksList.emplace_back( 0, 34 );
646 aData.aColsWithUnequalMarksList.emplace_back( 0, 10 );
647 aData.aColsWithUnequalMarksList.emplace_back( 0, 20 );
648 aData.aColsWithUnequalMarksList.emplace_back( 10, 21 );
649 aData.aColsWithUnequalMarksList.emplace_back( 20, 25 );
650 aData.aColsWithUnequalMarksList.emplace_back( 20, 30 );
651 aData.aColsWithUnequalMarksList.emplace_back( 24, 30 );
652 aData.aColsWithUnequalMarksList.emplace_back( 30, 31 );
653 aData.aColsWithUnequalMarksList.emplace_back( 30, 34 );
654 aData.aColsWithUnequalMarksList.emplace_back( 30, 35 );
655 aData.aColsWithUnequalMarksList.emplace_back( 35, 100 );
657 testMultiMark( aData );
660 void Test::testMultiMark_NegativeMarking()
662 MultiMarkTestData aData;
664 // Create full row = 5
665 MarkTestData aSingle1;
666 aSingle1.aRange = ScRange( 0, 5, 0, MAXCOL, 5, 0 );
667 aSingle1.bMark = true;
669 // Create rectangle ( 10, 8, 25, 20 )
670 MarkTestData aSingle2;
671 aSingle2.aRange = ScRange( 10, 8, 0, 25, 20, 0 );
672 aSingle2.bMark = true;
674 // Create full row = 12
675 MarkTestData aSingle3;
676 aSingle3.aRange = ScRange( 0, 12, 0, MAXCOL, 12, 0 );
677 aSingle3.bMark = true;
679 // Create deselection rectangle ( 17, 5, 20, 5 )
680 MarkTestData aSingle4;
681 aSingle4.aRange = ScRange( 17, 5, 0, 20, 5, 0 );
682 aSingle4.bMark = false;
684 aSingle4.aInsideAddresses.emplace_back( 6, 5, 0 );
685 aSingle4.aInsideAddresses.emplace_back( 30, 5, 0 );
686 aSingle4.aInsideAddresses.emplace_back( 6, 12, 0 );
687 aSingle4.aInsideAddresses.emplace_back( 30, 12, 0 );
688 aSingle4.aInsideAddresses.emplace_back( 13, 14, 0 );
689 aSingle4.aInsideAddresses.emplace_back( 16, 12, 0 );
691 aSingle4.aOutsideAddresses.emplace_back( 5, 2, 0 );
692 aSingle4.aOutsideAddresses.emplace_back( 18, 5, 0 );
693 aSingle4.aOutsideAddresses.emplace_back( 17, 5, 0 );
694 aSingle4.aOutsideAddresses.emplace_back( 20, 5, 0 );
695 aSingle4.aOutsideAddresses.emplace_back( 18, 7, 0 );
696 aSingle4.aOutsideAddresses.emplace_back( 5, 10, 0 );
697 aSingle4.aOutsideAddresses.emplace_back( 30, 10, 0 );
698 aSingle4.aOutsideAddresses.emplace_back( 5, 14, 0 );
699 aSingle4.aOutsideAddresses.emplace_back( 30, 14, 0 );
700 aSingle4.aOutsideAddresses.emplace_back( 18, 25, 0 );
702 aSingle4.aRowsWithFullMarks.push_back( 12 );
704 aSingle4.aRowsWithoutFullMarks.push_back( 5 );
706 aSingle4.aRangesWithFullMarks.emplace_back( 5, 5, 0, 16, 5, 0 );
707 aSingle4.aRangesWithFullMarks.emplace_back( 21, 5, 0, 30, 5, 0 );
708 aSingle4.aRangesWithFullMarks.emplace_back( 5, 12, 0, 9, 12, 0 );
709 aSingle4.aRangesWithFullMarks.emplace_back( 26, 12, 0, 30, 12, 0 );
710 aSingle4.aRangesWithFullMarks.emplace_back( 10, 8, 0, 25, 20, 0 );
712 aSingle4.aRangesWithoutFullMarks.emplace_back( 10, 5, 0, 25, 5, 0 );
714 aSingle4.aNextMarked.emplace_back( 18, 7, 0, 0, -1, 0 ); // up fail
715 aSingle4.aNextMarked.emplace_back( 18, 4, 0, 1, 8, 0 ); // down ok
717 // Create deselection rectangle ( 15, 10, 18, 14 )
718 MarkTestData aSingle5;
719 aSingle5.aRange = ScRange( 15, 10, 0, 18, 14, 0 );
720 aSingle5.bMark = false;
722 aSingle5.aInsideAddresses.emplace_back( 6, 5, 0 );
723 aSingle5.aInsideAddresses.emplace_back( 30, 5, 0 );
724 aSingle5.aInsideAddresses.emplace_back( 6, 12, 0 );
725 aSingle5.aInsideAddresses.emplace_back( 30, 12, 0 );
726 aSingle5.aInsideAddresses.emplace_back( 13, 14, 0 );
728 aSingle5.aOutsideAddresses = aSingle4.aOutsideAddresses;
729 aSingle5.aOutsideAddresses.emplace_back( 17, 12, 0 );
730 aSingle5.aOutsideAddresses.emplace_back( 15, 10, 0 );
731 aSingle5.aOutsideAddresses.emplace_back( 18, 10, 0 );
732 aSingle5.aOutsideAddresses.emplace_back( 15, 14, 0 );
733 aSingle5.aOutsideAddresses.emplace_back( 18, 14, 0 );
735 aSingle5.aRowsWithoutFullMarks.push_back( 12 );
736 aSingle5.aRowsWithoutFullMarks.push_back( 5 );
738 aSingle5.aRangesWithoutFullMarks.emplace_back( 10, 8, 0, 25, 20, 0 );
740 aSingle5.aNextMarked = aSingle4.aNextMarked;
741 aSingle5.aNextMarked.emplace_back( 17, 12, 0, 0, 9, 0 ); // up ok
742 aSingle5.aNextMarked.emplace_back( 17, 12, 0, 1, 15, 0 ); // down ok
744 // Add the rectangle data to aData
745 aData.aMarks.push_back( aSingle1 );
746 aData.aMarks.push_back( aSingle2 );
747 aData.aMarks.push_back( aSingle3 );
748 aData.aMarks.push_back( aSingle4 );
749 aData.aMarks.push_back( aSingle5 );
751 aData.aSelectionCover = ScRange( 0, 4, 0, MAXCOL, 21, 0 );
752 aData.aLeftEnvelope.push_back( ScRange( 9, 8, 0, 9, 11, 0 ) );
753 aData.aLeftEnvelope.push_back( ScRange( 9, 13, 0, 9, 20, 0 ) );
754 aData.aLeftEnvelope.push_back( ScRange( 18, 10, 0, 18, 14, 0 ) );
755 aData.aLeftEnvelope.push_back( ScRange( 20, 5, 0, 20, 5, 0 ) );
757 aData.aRightEnvelope.push_back( ScRange( 17, 5, 0, 17, 5, 0 ) );
758 aData.aRightEnvelope.push_back( ScRange( 15, 10, 0, 15, 14, 0 ) );
759 aData.aRightEnvelope.push_back( ScRange( 26, 8, 0, 26, 11, 0 ) );
760 aData.aRightEnvelope.push_back( ScRange( 26, 13, 0, 26, 20, 0 ) );
762 aData.aTopEnvelope.push_back( ScRange( 0, 4, 0, 16, 4, 0 ) );
763 aData.aTopEnvelope.push_back( ScRange( 21, 4, 0, MAXCOL, 4, 0 ) );
764 aData.aTopEnvelope.push_back( ScRange( 10, 7, 0, 25, 7, 0 ) );
765 aData.aTopEnvelope.push_back( ScRange( 0, 11, 0, 9, 11, 0 ) );
766 aData.aTopEnvelope.push_back( ScRange( 26, 11, 0, MAXCOL, 11, 0 ) );
767 aData.aTopEnvelope.push_back( ScRange( 15, 14, 0, 18, 14, 0 ) );
769 aData.aBottomEnvelope.push_back( ScRange( 0, 6, 0, 16, 6, 0 ) );
770 aData.aBottomEnvelope.push_back( ScRange( 21, 6, 0, MAXCOL, 6, 0 ) );
771 aData.aBottomEnvelope.push_back( ScRange( 15, 10, 0, 18, 10, 0 ) );
772 aData.aBottomEnvelope.push_back( ScRange( 0, 13, 0, 9, 13, 0 ) );
773 aData.aBottomEnvelope.push_back( ScRange( 26, 13, 0, MAXCOL, 13, 0 ) );
774 aData.aBottomEnvelope.push_back( ScRange( 10, 21, 0, 25, 21, 0 ) );
776 aData.aColsWithOneMark.emplace_back( 19, 8, 0, 0, 20, 0 );
777 aData.aColsWithOneMark.emplace_back( 20, 8, 0, 0, 20, 0 );
779 aData.aColsWithoutOneMark.push_back( 5 );
780 aData.aColsWithoutOneMark.push_back( 10 );
781 aData.aColsWithoutOneMark.push_back( 12 );
782 aData.aColsWithoutOneMark.push_back( 16 );
783 aData.aColsWithoutOneMark.push_back( 17 );
784 aData.aColsWithoutOneMark.push_back( 24 );
785 aData.aColsWithoutOneMark.push_back( 100 );
787 aData.aColsAllMarked.emplace_back( 10, 8, 0, 0, 20, 0 );
788 aData.aColsAllMarked.emplace_back( 17, 8, 0, 0, 9, 0 );
789 aData.aColsAllMarked.emplace_back( 20, 8, 0, 0, 20, 0 );
790 aData.aColsAllMarked.emplace_back( 100, 5, 0, 0, 5, 0 );
791 aData.aColsAllMarked.emplace_back( 100, 12, 0, 0, 12, 0 );
793 aData.aColsNotAllMarked.emplace_back( 5, 5, 0, 0, 12, 0 );
794 aData.aColsNotAllMarked.emplace_back( 10, 5, 0, 0, 20, 0 );
795 aData.aColsNotAllMarked.emplace_back( 15, 8, 0, 0, 20, 0 );
796 aData.aColsNotAllMarked.emplace_back( 18, 8, 0, 0, 20, 0 );
797 aData.aColsNotAllMarked.emplace_back( 25, 5, 0, 0, 20, 0 );
799 aData.aColsWithEqualMarksList.emplace_back( 0, 9 );
800 aData.aColsWithEqualMarksList.emplace_back( 10, 14 );
801 aData.aColsWithEqualMarksList.emplace_back( 15, 16 );
802 aData.aColsWithEqualMarksList.emplace_back( 17, 18 );
803 aData.aColsWithEqualMarksList.emplace_back( 19, 20 );
804 aData.aColsWithEqualMarksList.emplace_back( 21, 25 );
805 aData.aColsWithEqualMarksList.emplace_back( 26, 100 );
806 aData.aColsWithEqualMarksList.emplace_back( 0, 100 );
808 aData.aColsWithUnequalMarksList.emplace_back( 0, 10 );
809 aData.aColsWithUnequalMarksList.emplace_back( 10, 15 );
810 aData.aColsWithUnequalMarksList.emplace_back( 15, 17 );
811 aData.aColsWithUnequalMarksList.emplace_back( 17, 19 );
812 aData.aColsWithUnequalMarksList.emplace_back( 19, 21 );
813 aData.aColsWithUnequalMarksList.emplace_back( 21, 26 );
815 testMultiMark( aData );
818 void Test::testInsertTabBeforeSelected()
820 ScMarkData aMark(MAXROW, MAXCOL);
821 aMark.SelectOneTable(0);
822 aMark.InsertTab(0);
823 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
824 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetFirstSelected());
827 void Test::testInsertTabAfterSelected()
829 ScMarkData aMark(MAXROW, MAXCOL);
830 aMark.SelectOneTable(0);
831 aMark.InsertTab(1);
832 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
833 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
836 void Test::testDeleteTabBeforeSelected()
838 ScMarkData aMark(MAXROW, MAXCOL);
839 aMark.SelectOneTable(1);
840 aMark.DeleteTab(0);
841 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
842 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
845 void Test::testDeleteTabAfterSelected()
847 ScMarkData aMark(MAXROW, MAXCOL);
848 aMark.SelectOneTable(0);
849 aMark.DeleteTab(1);
850 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
851 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
854 void Test::testScMarkArraySearch_check(const ScMarkArray & ar, SCROW nRow, bool expectStatus, SCSIZE nIndexExpect)
856 SCSIZE nIndex = 0;
857 bool status = ar.Search(nRow, nIndex);
858 CPPUNIT_ASSERT_EQUAL(expectStatus, status);
859 CPPUNIT_ASSERT_EQUAL(nIndexExpect, nIndex);
862 void Test::testScMarkArraySearch()
864 // empty
866 ScMarkArray ar(MAXROW);
867 testScMarkArraySearch_check(ar, -1, false, 0);
868 testScMarkArraySearch_check(ar, 100, false, 0);
871 // one range
873 ScMarkArray ar(MAXROW);
874 ar.SetMarkArea(10, 20, true);
876 // 0-9,10-20,21+
878 testScMarkArraySearch_check(ar, -100, true, 0);
879 testScMarkArraySearch_check(ar, -1, true, 0);
881 testScMarkArraySearch_check(ar, 0, true, 0);
882 testScMarkArraySearch_check(ar, 5, true, 0);
883 testScMarkArraySearch_check(ar, 9, true, 0);
884 testScMarkArraySearch_check(ar, 10, true, 1);
885 testScMarkArraySearch_check(ar, 11, true, 1);
886 testScMarkArraySearch_check(ar, 19, true, 1);
887 testScMarkArraySearch_check(ar, 20, true, 1);
888 testScMarkArraySearch_check(ar, 21, true, 2);
889 testScMarkArraySearch_check(ar, 22, true, 2);
892 // three ranges
894 ScMarkArray ar(MAXROW);
895 ar.SetMarkArea(10, 20, true);
896 ar.SetMarkArea(21, 30, true);
897 ar.SetMarkArea(50, 100, true);
899 // 0-9,10-30,31-49,50-100,101+
901 testScMarkArraySearch_check(ar, -100, true, 0);
902 testScMarkArraySearch_check(ar, -1, true, 0);
904 testScMarkArraySearch_check(ar, 5, true, 0);
905 testScMarkArraySearch_check(ar, 15, true, 1);
906 testScMarkArraySearch_check(ar, 25, true, 1);
907 testScMarkArraySearch_check(ar, 35, true, 2);
908 testScMarkArraySearch_check(ar, 55, true, 3);
909 testScMarkArraySearch_check(ar, 20, true, 1);
910 testScMarkArraySearch_check(ar, 21, true, 1);
913 // three single-row ranges
915 ScMarkArray ar(MAXROW);
916 ar.SetMarkArea(4, 4, true);
917 ar.SetMarkArea(6, 6, true);
918 ar.SetMarkArea(8, 8, true);
920 testScMarkArraySearch_check(ar, -100, true, 0);
921 testScMarkArraySearch_check(ar, -1, true, 0);
923 testScMarkArraySearch_check(ar, 3, true, 0);
924 testScMarkArraySearch_check(ar, 4, true, 1);
925 testScMarkArraySearch_check(ar, 5, true, 2);
926 testScMarkArraySearch_check(ar, 6, true, 3);
927 testScMarkArraySearch_check(ar, 7, true, 4);
928 testScMarkArraySearch_check(ar, 8, true, 5);
929 testScMarkArraySearch_check(ar, 9, true, 6);
930 testScMarkArraySearch_check(ar, 10, true, 6);
933 // one range
935 ScMarkArray ar(MAXROW);
936 ar.SetMarkArea(10, MAXROW, true);
938 // 0-10,11+
940 testScMarkArraySearch_check(ar, -100, true, 0);
941 testScMarkArraySearch_check(ar, -1, true, 0);
943 testScMarkArraySearch_check(ar, 0, true, 0);
944 testScMarkArraySearch_check(ar, 5, true, 0);
945 testScMarkArraySearch_check(ar, 9, true, 0);
946 testScMarkArraySearch_check(ar, 10, true, 1);
947 testScMarkArraySearch_check(ar, 11, true, 1);
948 testScMarkArraySearch_check(ar, 12, true, 1);
949 testScMarkArraySearch_check(ar, 200, true, 1);
950 testScMarkArraySearch_check(ar, MAXROW, true, 1);
954 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
956 CPPUNIT_PLUGIN_IMPLEMENT();
958 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */