1 /*
2  * Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com>
3  *
4  * For general Scribus (>=1.3.2) copyright and licensing information please refer
5  * to the COPYING file provided with the program. Following this notice may exist
6  * a copyright and/or license notice that predates the release of Scribus 1.3.2
7  * for which a new license (GPL+exception) is in place.
8  */
9 #include <QtTest/QtTest>
10 
11 #include "cellareatests.h"
12 #include "cellarea.h"
13 
14 Q_DECLARE_METATYPE(CellArea);
15 
testConstructionAndSetters()16 void CellAreaTests::testConstructionAndSetters()
17 {
18 	// Default constructor should give invalid area.
19 	CellArea invalidArea1;
20 	QVERIFY(!invalidArea1.isValid());
21 
22 	// Negative width.
23 	CellArea invalidArea2(1, 1, -3, 3);
24 	QVERIFY(!invalidArea2.isValid());
25 
26 	// Negative height.
27 	CellArea invalidArea3(1, 1, 3, -3);
28 	QVERIFY(!invalidArea3.isValid());
29 
30 	// Both width and height negative.
31 	CellArea invalidArea4(1, 1, -3, -3);
32 	QVERIFY(!invalidArea4.isValid());
33 
34 	// Zero width.
35 	CellArea invalidArea5(1, 1, 0, 3);
36 	QVERIFY(!invalidArea5.isValid());
37 
38 	// Zero height.
39 	CellArea invalidArea6(1, 1, 3, 0);
40 	QVERIFY(!invalidArea6.isValid());
41 
42 	// Both width and height zero.
43 	CellArea invalidArea7(1, 1, 0, 0);
44 	QVERIFY(!invalidArea7.isValid());
45 
46 	// Valid cell area.
47 	CellArea validArea(5, 5, 5, 5);
48 	QVERIFY(validArea.isValid());
49 
50 	// Test setters/getters.
51 	validArea.setRow(3);
52 	QCOMPARE(validArea.row(), 3);
53 	QCOMPARE(validArea.bottom(), 7);
54 	validArea.setColumn(3);
55 	QCOMPARE(validArea.column(), 3);
56 	QCOMPARE(validArea.right(), 7);
57 	validArea.setWidth(3);
58 	QCOMPARE(validArea.width(), 3);
59 	QCOMPARE(validArea.right(), 5);
60 	validArea.setHeight(3);
61 	QCOMPARE(validArea.height(), 3);
62 	QCOMPARE(validArea.bottom(), 5);
63 }
64 
testComparison()65 void CellAreaTests::testComparison()
66 {
67 	// Identity test.
68 	CellArea area1(1, 3, 5, 7);
69 	QVERIFY(area1 == area1);
70 
71 	// Two equal areas.
72 	CellArea area2(1, 3, 5, 7);
73 	QVERIFY(area1 == area2);
74 
75 	// Row differs.
76 	CellArea area3(2, 3, 5, 7);
77 	QVERIFY(!(area1 == area3));
78 	QVERIFY(area1 != area3);
79 
80 	// Column differs.
81 	CellArea area4(1, 4, 5, 7);
82 	QVERIFY(!(area1 == area4));
83 	QVERIFY(area1 != area4);
84 
85 	// Width differs.
86 	CellArea area5(1, 3, 6, 7);
87 	QVERIFY(!(area1 == area5));
88 	QVERIFY(area1 != area5);
89 
90 	// Height differs.
91 	CellArea area6(1, 3, 5, 8);
92 	QVERIFY(!(area1 == area6));
93 	QVERIFY(area1 != area6);
94 }
95 
testContainsPoint()96 void CellAreaTests::testContainsPoint()
97 {
98 	QFETCH(int, row);
99 	QFETCH(int, column);
100 	QFETCH(bool, result);
101 
102 	CellArea area(1, 1, 2, 2);
103 
104 	QCOMPARE(area.contains(row, column), result);
105 }
106 
testContainsPoint_data()107 void CellAreaTests::testContainsPoint_data()
108 {
109 	QTest::addColumn<int>("row");
110 	QTest::addColumn<int>("column");
111 	QTest::addColumn<bool>("result");
112 
113 	// Tests for area.contains(row, column) where area is (1, 1, 2, 2).
114 
115 	// Points outside the area.
116 	QTest::newRow("outside1") << 0 << 0 << false;
117 	QTest::newRow("outside2") << 0 << 1 << false;
118 	QTest::newRow("outside3") << 0 << 2 << false;
119 	QTest::newRow("outside4") << 0 << 3 << false;
120 	QTest::newRow("outside5") << 1 << 3 << false;
121 	QTest::newRow("outside6") << 2 << 3 << false;
122 	QTest::newRow("outside7") << 3 << 3 << false;
123 	QTest::newRow("outside8") << 3 << 2 << false;
124 	QTest::newRow("outside9") << 3 << 1 << false;
125 	QTest::newRow("outside10") << 3 << 0 << false;
126 	QTest::newRow("outside11") << 2 << 0 << false;
127 	QTest::newRow("outside12") << 1 << 0 << false;
128 
129 	// Points inside the area.
130 	QTest::newRow("inside1") << 1 << 1 << true;
131 	QTest::newRow("inside2") << 1 << 2 << true;
132 	QTest::newRow("inside3") << 2 << 1 << true;
133 	QTest::newRow("inside4") << 2 << 2 << true;
134 }
135 
testContainsArea()136 void CellAreaTests::testContainsArea()
137 {
138 	QFETCH(CellArea, area1);
139 	QFETCH(CellArea, area2);
140 	QFETCH(bool, result);
141 
142 	QCOMPARE(area2.contains(area1), result);
143 }
144 
testContainsArea_data()145 void CellAreaTests::testContainsArea_data()
146 {
147 	QTest::addColumn<CellArea>("area1");
148 	QTest::addColumn<CellArea>("area2");
149 	QTest::addColumn<bool>("result");
150 
151 	// Tests for area2.contains(area1).
152 	QTest::newRow("area1 left of area2") << CellArea(1, 3, 2, 2) << CellArea(1, 1, 2, 2) << false;
153 	QTest::newRow("area1 above area2") << CellArea(1, 1, 2, 2) << CellArea(3, 1, 2, 2) << false;
154 	QTest::newRow("area1 intersects top right of area2") << CellArea(0, 2, 2, 2) << CellArea(1, 1, 2, 2) << false;
155 	QTest::newRow("area1 intersects top left of area2") << CellArea(0, 0, 2, 2) << CellArea(1, 1, 2, 2) << false;
156 	QTest::newRow("area1 same as area2") << CellArea(1, 1, 2, 2) << CellArea(1, 1, 2, 2) << true;
157 	QTest::newRow("area1 inside area2") << CellArea(1, 1, 3, 3) << CellArea(0, 0, 6, 6) << true;
158 	QTest::newRow("area1 inside area2") << CellArea(1, 1, 2, 2) << CellArea(1, 1, 4, 4) << true;
159 	QTest::newRow("area1 inside area2") << CellArea(2, 2, 3, 3) << CellArea(1, 1, 4, 4) << true;
160 	QTest::newRow("area2 inside area1") << CellArea(0, 0, 6, 6) << CellArea(1, 1, 3, 3) << false;
161 	QTest::newRow("area2 inside area1") << CellArea(1, 1, 4, 4) << CellArea(1, 1, 2, 2) << false;
162 	QTest::newRow("area2 inside area1") << CellArea(1, 1, 4, 4) << CellArea(2, 2, 3, 3) << false;
163 }
164 
testIntersects()165 void CellAreaTests::testIntersects()
166 {
167 	QFETCH(CellArea, area1);
168 	QFETCH(CellArea, area2);
169 	QFETCH(bool, result);
170 
171 	QCOMPARE(area1.intersects(area2), result);
172 	QCOMPARE(area2.intersects(area1), result);
173 }
174 
testIntersects_data()175 void CellAreaTests::testIntersects_data()
176 {
177 	QTest::addColumn<CellArea>("area1");
178 	QTest::addColumn<CellArea>("area2");
179 	QTest::addColumn<bool>("result");
180 
181 	// Tests for area1.intersects(area2) and area2.intersects(area1).
182 	QTest::newRow("area1 left of area2") << CellArea(1, 3, 2, 2) << CellArea(1, 1, 2, 2) << false;
183 	QTest::newRow("area1 above area2") << CellArea(1, 1, 2, 2) << CellArea(3, 1, 2, 2) << false;
184 	QTest::newRow("area1 same as area2") << CellArea(1, 1, 2, 2) << CellArea(1, 1, 2, 2) << true;
185 	QTest::newRow("area1 intersects top right of area2") << CellArea(0, 2, 2, 2) << CellArea(1, 1, 2, 2) << true;
186 	QTest::newRow("area1 intersects top left of area2") << CellArea(0, 0, 2, 2) << CellArea(1, 1, 2, 2) << true;
187 	QTest::newRow("area1 inside area2") << CellArea(1, 1, 3, 3) << CellArea(0, 0, 6, 6) << true;
188 }
189 
testTranslated()190 void CellAreaTests::testTranslated()
191 {
192 	QFETCH(CellArea, area);
193 	QFETCH(int, columns);
194 	QFETCH(int, rows);
195 	QFETCH(CellArea, result);
196 
197 	QCOMPARE(area.translated(rows, columns), result);
198 }
199 
testTranslated_data()200 void CellAreaTests::testTranslated_data()
201 {
202 	QTest::addColumn<CellArea>("area");
203 	QTest::addColumn<int>("columns");
204 	QTest::addColumn<int>("rows");
205 	QTest::addColumn<CellArea>("result");
206 
207 	// Tests for area.translated(rows, columns).
208 	QTest::newRow("no translation") << CellArea(1, 1, 2, 2) << 0 << 0 << CellArea(1, 1, 2, 2);
209 	QTest::newRow("translate right 1") << CellArea(1, 1, 2, 2) << 1 << 0 << CellArea(1, 2, 2, 2);
210 	QTest::newRow("translate left 1") << CellArea(1, 1, 2, 2) << -1 << 0 << CellArea(1, 0, 2, 2);
211 	QTest::newRow("translate down 1") << CellArea(1, 1, 2, 2) << 0 << 1 << CellArea(2, 1, 2, 2);
212 	QTest::newRow("translate up 1") << CellArea(1, 1, 2, 2) << 0 << -1 << CellArea(0, 1, 2, 2);
213 }
214 
testTranslate()215 void CellAreaTests::testTranslate()
216 {
217 	QFETCH(CellArea, area);
218 	QFETCH(int, columns);
219 	QFETCH(int, rows);
220 	QFETCH(CellArea, result);
221 
222 	area.translate(rows, columns);
223 
224 	QCOMPARE(area, result);
225 }
226 
testTranslate_data()227 void CellAreaTests::testTranslate_data()
228 {
229 	QTest::addColumn<CellArea>("area");
230 	QTest::addColumn<int>("columns");
231 	QTest::addColumn<int>("rows");
232 	QTest::addColumn<CellArea>("result");
233 
234 	// Tests for area.translate(rows, columns).
235 	QTest::newRow("no translation") << CellArea(1, 1, 2, 2) << 0 << 0 << CellArea(1, 1, 2, 2);
236 	QTest::newRow("translate right 1") << CellArea(1, 1, 2, 2) << 1 << 0 << CellArea(1, 2, 2, 2);
237 	QTest::newRow("translate left 1") << CellArea(1, 1, 2, 2) << -1 << 0 << CellArea(1, 0, 2, 2);
238 	QTest::newRow("translate down 1") << CellArea(1, 1, 2, 2) << 0 << 1 << CellArea(2, 1, 2, 2);
239 	QTest::newRow("translate up 1") << CellArea(1, 1, 2, 2) << 0 << -1 << CellArea(0, 1, 2, 2);
240 }
241 
testAdjusted()242 void CellAreaTests::testAdjusted()
243 {
244 	QFETCH(CellArea, area);
245 	QFETCH(int, rows);
246 	QFETCH(int, columns);
247 	QFETCH(int, width);
248 	QFETCH(int, height);
249 	QFETCH(CellArea, result);
250 
251 	QCOMPARE(area.adjusted(rows, columns, width, height), result);
252 }
253 
testAdjusted_data()254 void CellAreaTests::testAdjusted_data()
255 {
256 	QTest::addColumn<CellArea>("area");
257 	QTest::addColumn<int>("rows");
258 	QTest::addColumn<int>("columns");
259 	QTest::addColumn<int>("width");
260 	QTest::addColumn<int>("height");
261 	QTest::addColumn<CellArea>("result");
262 
263 	// Tests for area.adjusted(rows, columns, width, height).
264 	QTest::newRow("no adjustment") << CellArea(1, 1, 2, 2) << 0 << 0 << 0 << 0 << CellArea(1, 1, 2, 2);
265 	QTest::newRow("translate down 1") << CellArea(1, 1, 2, 2) << 1 << 0 << 0 << 0 << CellArea(2, 1, 2, 2);
266 	QTest::newRow("translate up 1") << CellArea(1, 1, 2, 2) << -1 << 0 << 0 << 0 << CellArea(0, 1, 2, 2);
267 	QTest::newRow("translate right 1") << CellArea(1, 1, 2, 2) << 0 << 1 << 0 << 0 << CellArea(1, 2, 2, 2);
268 	QTest::newRow("translate left 1") << CellArea(1, 1, 2, 2) << 0 << -1 << 0 << 0 << CellArea(1, 0, 2, 2);
269 	QTest::newRow("increase width") << CellArea(1, 1, 2, 2) << 0 << 0 << 1 << 0 << CellArea(1, 1, 3, 2);
270 	QTest::newRow("decrease width") << CellArea(1, 1, 2, 2) << 0 << 0 << -1 << 0 << CellArea(1, 1, 1, 2);
271 	QTest::newRow("increase height") << CellArea(1, 1, 2, 2) << 0 << 0 << 0 << 1 << CellArea(1, 1, 2, 3);
272 	QTest::newRow("decrease height") << CellArea(1, 1, 2, 2) << 0 << 0 << 0 << -1 << CellArea(1, 1, 2, 1);
273 }
274 
testAdjust()275 void CellAreaTests::testAdjust()
276 {
277 	QFETCH(CellArea, area);
278 	QFETCH(int, rows);
279 	QFETCH(int, columns);
280 	QFETCH(int, width);
281 	QFETCH(int, height);
282 	QFETCH(CellArea, result);
283 
284 	area.adjust(rows, columns, width, height);
285 	QCOMPARE(area, result);
286 }
287 
testAdjust_data()288 void CellAreaTests::testAdjust_data()
289 {
290 	QTest::addColumn<CellArea>("area");
291 	QTest::addColumn<int>("rows");
292 	QTest::addColumn<int>("columns");
293 	QTest::addColumn<int>("width");
294 	QTest::addColumn<int>("height");
295 	QTest::addColumn<CellArea>("result");
296 
297 	// Tests for area.adjust(rows, columns, width, height).
298 	QTest::newRow("no adjustment") << CellArea(1, 1, 2, 2) << 0 << 0 << 0 << 0 << CellArea(1, 1, 2, 2);
299 	QTest::newRow("translate down 1") << CellArea(1, 1, 2, 2) << 1 << 0 << 0 << 0 << CellArea(2, 1, 2, 2);
300 	QTest::newRow("translate up 1") << CellArea(1, 1, 2, 2) << -1 << 0 << 0 << 0 << CellArea(0, 1, 2, 2);
301 	QTest::newRow("translate right 1") << CellArea(1, 1, 2, 2) << 0 << 1 << 0 << 0 << CellArea(1, 2, 2, 2);
302 	QTest::newRow("translate left 1") << CellArea(1, 1, 2, 2) << 0 << -1 << 0 << 0 << CellArea(1, 0, 2, 2);
303 	QTest::newRow("increase width") << CellArea(1, 1, 2, 2) << 0 << 0 << 1 << 0 << CellArea(1, 1, 3, 2);
304 	QTest::newRow("decrease width") << CellArea(1, 1, 2, 2) << 0 << 0 << -1 << 0 << CellArea(1, 1, 1, 2);
305 	QTest::newRow("increase height") << CellArea(1, 1, 2, 2) << 0 << 0 << 0 << 1 << CellArea(1, 1, 2, 3);
306 	QTest::newRow("decrease height") << CellArea(1, 1, 2, 2) << 0 << 0 << 0 << -1 << CellArea(1, 1, 2, 1);
307 }
308 
testUnited()309 void CellAreaTests::testUnited()
310 {
311 	QFETCH(CellArea, area1);
312 	QFETCH(CellArea, area2);
313 	QFETCH(CellArea, result);
314 
315 	QCOMPARE(area1.united(area2), result);
316 	QCOMPARE(area2.united(area1), result);
317 }
318 
testUnited_data()319 void CellAreaTests::testUnited_data()
320 {
321 	QTest::addColumn<CellArea>("area1");
322 	QTest::addColumn<CellArea>("area2");
323 	QTest::addColumn<CellArea>("result");
324 
325 	// Tests for area1.united(area2) and area2.united(area1).
326 	QTest::newRow("areas same") << CellArea(1, 1, 2, 2) << CellArea(1, 1, 2, 2) << CellArea(1, 1, 2, 2);
327 	QTest::newRow("overlapping southeast/northwest") << CellArea(1, 1, 2, 2) << CellArea(2, 2, 2, 2) << CellArea(1, 1, 3, 3);
328 	QTest::newRow("overlapping southwest/northeast") << CellArea(1, 1, 2, 2) << CellArea(2, 0, 2, 2) << CellArea(1, 0, 3, 3);
329 	QTest::newRow("non-overlapping") << CellArea(1, 1, 2, 2) << CellArea(3, 3, 2, 2) << CellArea(1, 1, 4, 4);
330 }
331 
testAdjustedForRowInsertion()332 void CellAreaTests::testAdjustedForRowInsertion()
333 {
334 	QFETCH(CellArea, area);
335 	QFETCH(int, index);
336 	QFETCH(int, numRows);
337 	QFETCH(CellArea, result);
338 
339 	QCOMPARE(area.adjustedForRowInsertion(index, numRows), result);
340 }
341 
testAdjustedForRowInsertion_data()342 void CellAreaTests::testAdjustedForRowInsertion_data()
343 {
344 	QTest::addColumn<CellArea>("area");
345 	QTest::addColumn<int>("index");
346 	QTest::addColumn<int>("numRows");
347 	QTest::addColumn<CellArea>("result");
348 
349 	// Tests for area.adjustedForRowInsertion(index, numRows).
350 	QTest::newRow("well above") << CellArea(2, 2, 4, 4) << 0 << 3 << CellArea(5, 2, 4, 4);
351 	QTest::newRow("just above") << CellArea(2, 2, 4, 4) << 2 << 3 << CellArea(5, 2, 4, 4);
352 	QTest::newRow("just inside at top") << CellArea(2, 2, 4, 4) << 3 << 3 << CellArea(2, 2, 4, 7);
353 	QTest::newRow("well inside") << CellArea(2, 2, 4, 4) << 4 << 3 << CellArea(2, 2, 4, 7);
354 	QTest::newRow("just inside at bottom") << CellArea(2, 2, 4, 4) << 5 << 3 << CellArea(2, 2, 4, 7);
355 	QTest::newRow("just below") << CellArea(2, 2, 4, 4) << 6 << 3 << CellArea(2, 2, 4, 4);
356 	QTest::newRow("well below") << CellArea(2, 2, 4, 4) << 7 << 3 << CellArea(2, 2, 4, 4);
357 
358 	QTest::newRow("zero rows") << CellArea(2, 2, 4, 4) << 4 << 0 << CellArea(2, 2, 4, 4);
359 	QTest::newRow("negative rows") << CellArea(2, 2, 4, 4) << 4 << -1 << CellArea(2, 2, 4, 4);
360 }
361 
testAdjustedForRowRemoval()362 void CellAreaTests::testAdjustedForRowRemoval()
363 {
364 	QFETCH(CellArea, area);
365 	QFETCH(int, index);
366 	QFETCH(int, numRows);
367 	QFETCH(CellArea, result);
368 
369 	QCOMPARE(area.adjustedForRowRemoval(index, numRows), result);
370 }
371 
testAdjustedForRowRemoval_data()372 void CellAreaTests::testAdjustedForRowRemoval_data()
373 {
374 	QTest::addColumn<CellArea>("area");
375 	QTest::addColumn<int>("index");
376 	QTest::addColumn<int>("numRows");
377 	QTest::addColumn<CellArea>("result");
378 
379 	// Tests for area.adjustedForRowRemoval(index, numRows).
380 	QTest::newRow("well above") << CellArea(3, 3, 4, 4) << 0 << 2 << CellArea(1, 3, 4, 4);
381 	QTest::newRow("just above") << CellArea(3, 3, 4, 4) << 1 << 2 << CellArea(1, 3, 4, 4);
382 	QTest::newRow("overlapping top") << CellArea(3, 3, 4, 4) << 2 << 3 << CellArea(3, 3, 4, 2);
383 	QTest::newRow("just inside at top") << CellArea(3, 3, 4, 4) << 3 << 2 << CellArea(3, 3, 4, 2);
384 	QTest::newRow("completely overlapping") << CellArea(3, 3, 4, 4) << 3 << 4 << CellArea(3, 3, 4, 0);
385 	QTest::newRow("well inside") << CellArea(3, 3, 4, 4) << 4 << 2 << CellArea(3, 3, 4, 2);
386 	QTest::newRow("just inside at bottom") << CellArea(3, 3, 4, 4) << 5 << 2 << CellArea(3, 3, 4, 2);
387 	QTest::newRow("overlapping bottom") << CellArea(3, 3, 4, 4) << 5 << 3 << CellArea(3, 3, 4, 2);
388 	QTest::newRow("just below") << CellArea(3, 3, 4, 4) << 7 << 2 << CellArea(3, 3, 4, 4);
389 	QTest::newRow("well below") << CellArea(3, 3, 4, 4) << 8 << 2 << CellArea(3, 3, 4, 4);
390 
391 	QTest::newRow("zero rows") << CellArea(3, 3, 4, 4) << 4 << 0 << CellArea(3, 3, 4, 4);
392 	QTest::newRow("negative rows") << CellArea(3, 3, 4, 4) << 4 << -1 << CellArea(3, 3, 4, 4);
393 }
394 
testAdjustedForColumnInsertion()395 void CellAreaTests::testAdjustedForColumnInsertion()
396 {
397 	QFETCH(CellArea, area);
398 	QFETCH(int, index);
399 	QFETCH(int, numColumns);
400 	QFETCH(CellArea, result);
401 
402 	QCOMPARE(area.adjustedForColumnInsertion(index, numColumns), result);
403 }
404 
testAdjustedForColumnInsertion_data()405 void CellAreaTests::testAdjustedForColumnInsertion_data()
406 {
407 	QTest::addColumn<CellArea>("area");
408 	QTest::addColumn<int>("index");
409 	QTest::addColumn<int>("numColumns");
410 	QTest::addColumn<CellArea>("result");
411 
412 	// Tests for area.adjustedForColumnInsertion(index, numColumns).
413 	QTest::newRow("well left of") << CellArea(2, 2, 4, 4) << 0 << 3 << CellArea(2, 5, 4, 4);
414 	QTest::newRow("just left of") << CellArea(2, 2, 4, 4) << 2 << 3 << CellArea(2, 5, 4, 4);
415 	QTest::newRow("just inside at left") << CellArea(2, 2, 4, 4) << 3 << 3 << CellArea(2, 2, 7, 4);
416 	QTest::newRow("well inside") << CellArea(2, 2, 4, 4) << 4 << 3 << CellArea(2, 2, 7, 4);
417 	QTest::newRow("just inside at right") << CellArea(2, 2, 4, 4) << 5 << 3 << CellArea(2, 2, 7, 4);
418 	QTest::newRow("just right of") << CellArea(2, 2, 4, 4) << 6 << 3 << CellArea(2, 2, 4, 4);
419 	QTest::newRow("well right of") << CellArea(2, 2, 4, 4) << 7 << 3 << CellArea(2, 2, 4, 4);
420 
421 	QTest::newRow("zero columns") << CellArea(2, 2, 4, 4) << 4 << 0 << CellArea(2, 2, 4, 4);
422 	QTest::newRow("negative columns") << CellArea(2, 2, 4, 4) << 4 << -1 << CellArea(2, 2, 4, 4);
423 }
424 
testAdjustedForColumnRemoval()425 void CellAreaTests::testAdjustedForColumnRemoval()
426 {
427 	QFETCH(CellArea, area);
428 	QFETCH(int, index);
429 	QFETCH(int, numColumns);
430 	QFETCH(CellArea, result);
431 
432 	QCOMPARE(area.adjustedForColumnRemoval(index, numColumns), result);
433 }
434 
testAdjustedForColumnRemoval_data()435 void CellAreaTests::testAdjustedForColumnRemoval_data()
436 {
437 	QTest::addColumn<CellArea>("area");
438 	QTest::addColumn<int>("index");
439 	QTest::addColumn<int>("numColumns");
440 	QTest::addColumn<CellArea>("result");
441 
442 	// Tests for area.adjustedForColumnRemoval(index, numColumns).
443 	QTest::newRow("well left of") << CellArea(3, 3, 4, 4) << 0 << 2 << CellArea(3, 1, 4, 4);
444 	QTest::newRow("just left of") << CellArea(3, 3, 4, 4) << 1 << 2 << CellArea(3, 1, 4, 4);
445 	QTest::newRow("overlapping left") << CellArea(3, 3, 4, 4) << 2 << 3 << CellArea(3, 3, 2, 4);
446 	QTest::newRow("just inside at left") << CellArea(3, 3, 4, 4) << 3 << 2 << CellArea(3, 3, 2, 4);
447 	QTest::newRow("completely overlapping") << CellArea(3, 3, 4, 4) << 3 << 4 << CellArea(3, 3, 0, 4);
448 	QTest::newRow("well inside") << CellArea(3, 3, 4, 4) << 4 << 2 << CellArea(3, 3, 2, 4);
449 	QTest::newRow("just inside at right") << CellArea(3, 3, 4, 4) << 5 << 2 << CellArea(3, 3, 2, 4);
450 	QTest::newRow("overlapping right") << CellArea(3, 3, 4, 4) << 5 << 3 << CellArea(3, 3, 2, 4);
451 	QTest::newRow("just right of") << CellArea(3, 3, 4, 4) << 7 << 2 << CellArea(3, 3, 4, 4);
452 	QTest::newRow("well right of") << CellArea(3, 3, 4, 4) << 8 << 2 << CellArea(3, 3, 4, 4);
453 
454 	QTest::newRow("zero columns") << CellArea(3, 3, 4, 4) << 4 << 0 << CellArea(3, 3, 4, 4);
455 	QTest::newRow("negative columns") << CellArea(3, 3, 4, 4) << 4 << -1 << CellArea(3, 3, 4, 4);
456 }
457 
458 QTEST_APPLESS_MAIN(CellAreaTests)
459