|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the test suite of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 |
|
43 #include <QtTest/QtTest> |
|
44 #include <qline.h> |
|
45 #include <math.h> |
|
46 |
|
47 #ifndef M_2PI |
|
48 #define M_2PI 6.28318530717958647692528676655900576 |
|
49 #endif |
|
50 |
|
51 //TESTED_CLASS= |
|
52 //TESTED_FILES= |
|
53 |
|
54 class tst_QLine : public QObject |
|
55 { |
|
56 Q_OBJECT |
|
57 |
|
58 public: |
|
59 tst_QLine(); |
|
60 |
|
61 private slots: |
|
62 void testIntersection(); |
|
63 void testIntersection_data(); |
|
64 |
|
65 void testLength(); |
|
66 void testLength_data(); |
|
67 |
|
68 void testNormalVector(); |
|
69 void testNormalVector_data(); |
|
70 |
|
71 void testAngle(); |
|
72 void testAngle_data(); |
|
73 |
|
74 void testAngle2(); |
|
75 void testAngle2_data(); |
|
76 |
|
77 void testAngle3(); |
|
78 |
|
79 void testAngleTo(); |
|
80 void testAngleTo_data(); |
|
81 |
|
82 void testSet(); |
|
83 }; |
|
84 |
|
85 // Square root of two |
|
86 #define SQRT2 1.4142135623731 |
|
87 |
|
88 // Length of unit vector projected to x from 45 degrees |
|
89 #define UNITX_45 0.707106781186547 |
|
90 |
|
91 const qreal epsilon = sizeof(qreal) == sizeof(double) ? 1e-8 : 1e-4; |
|
92 |
|
93 tst_QLine::tst_QLine() |
|
94 |
|
95 { |
|
96 } |
|
97 |
|
98 void tst_QLine::testSet() |
|
99 { |
|
100 { |
|
101 QLine l; |
|
102 l.setP1(QPoint(1, 2)); |
|
103 l.setP2(QPoint(3, 4)); |
|
104 |
|
105 QCOMPARE(l.x1(), 1); |
|
106 QCOMPARE(l.y1(), 2); |
|
107 QCOMPARE(l.x2(), 3); |
|
108 QCOMPARE(l.y2(), 4); |
|
109 |
|
110 l.setPoints(QPoint(5, 6), QPoint(7, 8)); |
|
111 QCOMPARE(l.x1(), 5); |
|
112 QCOMPARE(l.y1(), 6); |
|
113 QCOMPARE(l.x2(), 7); |
|
114 QCOMPARE(l.y2(), 8); |
|
115 |
|
116 l.setLine(9, 10, 11, 12); |
|
117 QCOMPARE(l.x1(), 9); |
|
118 QCOMPARE(l.y1(), 10); |
|
119 QCOMPARE(l.x2(), 11); |
|
120 QCOMPARE(l.y2(), 12); |
|
121 } |
|
122 |
|
123 { |
|
124 QLineF l; |
|
125 l.setP1(QPointF(1, 2)); |
|
126 l.setP2(QPointF(3, 4)); |
|
127 |
|
128 QCOMPARE(l.x1(), 1.0); |
|
129 QCOMPARE(l.y1(), 2.0); |
|
130 QCOMPARE(l.x2(), 3.0); |
|
131 QCOMPARE(l.y2(), 4.0); |
|
132 |
|
133 l.setPoints(QPointF(5, 6), QPointF(7, 8)); |
|
134 QCOMPARE(l.x1(), 5.0); |
|
135 QCOMPARE(l.y1(), 6.0); |
|
136 QCOMPARE(l.x2(), 7.0); |
|
137 QCOMPARE(l.y2(), 8.0); |
|
138 |
|
139 l.setLine(9.0, 10.0, 11.0, 12.0); |
|
140 QCOMPARE(l.x1(), 9.0); |
|
141 QCOMPARE(l.y1(), 10.0); |
|
142 QCOMPARE(l.x2(), 11.0); |
|
143 QCOMPARE(l.y2(), 12.0); |
|
144 } |
|
145 |
|
146 } |
|
147 |
|
148 void tst_QLine::testIntersection_data() |
|
149 { |
|
150 QTest::addColumn<double>("xa1"); |
|
151 QTest::addColumn<double>("ya1"); |
|
152 QTest::addColumn<double>("xa2"); |
|
153 QTest::addColumn<double>("ya2"); |
|
154 QTest::addColumn<double>("xb1"); |
|
155 QTest::addColumn<double>("yb1"); |
|
156 QTest::addColumn<double>("xb2"); |
|
157 QTest::addColumn<double>("yb2"); |
|
158 QTest::addColumn<int>("type"); |
|
159 QTest::addColumn<double>("ix"); |
|
160 QTest::addColumn<double>("iy"); |
|
161 |
|
162 QTest::newRow("parallel") << 1.0 << 1.0 << 3.0 << 4.0 |
|
163 << 5.0 << 6.0 << 7.0 << 9.0 |
|
164 << int(QLineF::NoIntersection) << 0.0 << 0.0; |
|
165 QTest::newRow("unbounded") << 1.0 << 1.0 << 5.0 << 5.0 |
|
166 << 0.0 << 4.0 << 3.0 << 4.0 |
|
167 << int(QLineF::UnboundedIntersection) << 4.0 << 4.0; |
|
168 QTest::newRow("bounded") << 1.0 << 1.0 << 5.0 << 5.0 |
|
169 << 0.0 << 4.0 << 5.0 << 4.0 |
|
170 << int(QLineF::BoundedIntersection) << 4.0 << 4.0; |
|
171 |
|
172 QTest::newRow("almost vertical") << 0.0 << 10.0 << 20.0000000000001 << 10.0 |
|
173 << 10.0 << 0.0 << 10.0 << 20.0 |
|
174 << int(QLineF::BoundedIntersection) << 10.0 << 10.0; |
|
175 |
|
176 QTest::newRow("almost horizontal") << 0.0 << 10.0 << 20.0 << 10.0 |
|
177 << 10.0000000000001 << 0.0 << 10.0 << 20.0 |
|
178 << int(QLineF::BoundedIntersection) << 10.0 << 10.0; |
|
179 |
|
180 QTest::newRow("task 241464") << 100.1599256468623 |
|
181 << 100.7861905065196 |
|
182 << 100.1599256468604 |
|
183 << -9999.78619050651 |
|
184 << 10.0 << 50.0 << 190.0 << 50.0 |
|
185 << int(QLineF::BoundedIntersection) |
|
186 << 100.1599256468622 |
|
187 << 50.0; |
|
188 |
|
189 QLineF baseA(0, -50, 0, 50); |
|
190 QLineF baseB(-50, 0, 50, 0); |
|
191 |
|
192 for (int i = 0; i < 1000; ++i) { |
|
193 QLineF a = QLineF::fromPolar(50, i); |
|
194 a.setP1(-a.p2()); |
|
195 |
|
196 QLineF b = QLineF::fromPolar(50, i * 0.997 + 90); |
|
197 b.setP1(-b.p2()); |
|
198 |
|
199 // make the qFuzzyCompare be a bit more lenient |
|
200 a = a.translated(1, 1); |
|
201 b = b.translated(1, 1); |
|
202 |
|
203 QTest::newRow(qPrintable(QString::fromLatin1("rotation-%0").arg(i))) |
|
204 << (double)a.x1() << (double)a.y1() << (double)a.x2() << (double)a.y2() |
|
205 << (double)b.x1() << (double)b.y1() << (double)b.x2() << (double)b.y2() |
|
206 << int(QLineF::BoundedIntersection) |
|
207 << 1.0 |
|
208 << 1.0; |
|
209 } |
|
210 } |
|
211 |
|
212 void tst_QLine::testIntersection() |
|
213 { |
|
214 QFETCH(double, xa1); |
|
215 QFETCH(double, ya1); |
|
216 QFETCH(double, xa2); |
|
217 QFETCH(double, ya2); |
|
218 QFETCH(double, xb1); |
|
219 QFETCH(double, yb1); |
|
220 QFETCH(double, xb2); |
|
221 QFETCH(double, yb2); |
|
222 QFETCH(int, type); |
|
223 QFETCH(double, ix); |
|
224 QFETCH(double, iy); |
|
225 |
|
226 QLineF a(xa1, ya1, xa2, ya2); |
|
227 QLineF b(xb1, yb1, xb2, yb2); |
|
228 |
|
229 |
|
230 QPointF ip; |
|
231 QLineF::IntersectType itype = a.intersect(b, &ip); |
|
232 |
|
233 QCOMPARE(int(itype), type); |
|
234 if (type != QLineF::NoIntersection) { |
|
235 QVERIFY(qAbs(ip.x() - ix) < epsilon); |
|
236 QVERIFY(qAbs(ip.y() - iy) < epsilon); |
|
237 } |
|
238 } |
|
239 |
|
240 void tst_QLine::testLength_data() |
|
241 { |
|
242 QTest::addColumn<double>("x1"); |
|
243 QTest::addColumn<double>("y1"); |
|
244 QTest::addColumn<double>("x2"); |
|
245 QTest::addColumn<double>("y2"); |
|
246 QTest::addColumn<double>("length"); |
|
247 QTest::addColumn<double>("lengthToSet"); |
|
248 QTest::addColumn<double>("vx"); |
|
249 QTest::addColumn<double>("vy"); |
|
250 |
|
251 QTest::newRow("[1,0]*2") << 0.0 << 0.0 << 1.0 << 0.0 << 1.0 << 2.0 << 2.0 << 0.0; |
|
252 QTest::newRow("[0,1]*2") << 0.0 << 0.0 << 0.0 << 1.0 << 1.0 << 2.0 << 0.0 << 2.0; |
|
253 QTest::newRow("[-1,0]*2") << 0.0 << 0.0 << -1.0 << 0.0 << 1.0 << 2.0 << -2.0 << 0.0; |
|
254 QTest::newRow("[0,-1]*2") << 0.0 << 0.0 << 0.0 << -1.0 << 1.0 << 2.0 << 0.0 << -2.0; |
|
255 QTest::newRow("[1,1]->|1|") << 0.0 << 0.0 << 1.0 << 1.0 |
|
256 << double(SQRT2) << 1.0 << double(UNITX_45) << double(UNITX_45); |
|
257 QTest::newRow("[-1,1]->|1|") << 0.0 << 0.0 << -1.0 << 1.0 |
|
258 << double(SQRT2) << 1.0 << double(-UNITX_45) << double(UNITX_45); |
|
259 QTest::newRow("[1,-1]->|1|") << 0.0 << 0.0 << 1.0 << -1.0 |
|
260 << double(SQRT2) << 1.0 << double(UNITX_45) << double(-UNITX_45); |
|
261 QTest::newRow("[-1,-1]->|1|") << 0.0 << 0.0 << -1.0 << -1.0 |
|
262 << double(SQRT2) << 1.0 << double(-UNITX_45) << double(-UNITX_45); |
|
263 QTest::newRow("[1,0]*2 (2,2)") << 2.0 << 2.0 << 3.0 << 2.0 << 1.0 << 2.0 << 2.0 << 0.0; |
|
264 QTest::newRow("[0,1]*2 (2,2)") << 2.0 << 2.0 << 2.0 << 3.0 << 1.0 << 2.0 << 0.0 << 2.0; |
|
265 QTest::newRow("[-1,0]*2 (2,2)") << 2.0 << 2.0 << 1.0 << 2.0 << 1.0 << 2.0 << -2.0 << 0.0; |
|
266 QTest::newRow("[0,-1]*2 (2,2)") << 2.0 << 2.0 << 2.0 << 1.0 << 1.0 << 2.0 << 0.0 << -2.0; |
|
267 QTest::newRow("[1,1]->|1| (2,2)") << 2.0 << 2.0 << 3.0 << 3.0 |
|
268 << double(SQRT2) << 1.0 << double(UNITX_45) << double(UNITX_45); |
|
269 QTest::newRow("[-1,1]->|1| (2,2)") << 2.0 << 2.0 << 1.0 << 3.0 |
|
270 << double(SQRT2) << 1.0 << double(-UNITX_45) << double(UNITX_45); |
|
271 QTest::newRow("[1,-1]->|1| (2,2)") << 2.0 << 2.0 << 3.0 << 1.0 |
|
272 << double(SQRT2) << 1.0 << double(UNITX_45) << double(-UNITX_45); |
|
273 QTest::newRow("[-1,-1]->|1| (2,2)") << 2.0 << 2.0 << 1.0 << 1.0 |
|
274 << double(SQRT2) << 1.0 << double(-UNITX_45) << double(-UNITX_45); |
|
275 } |
|
276 |
|
277 void tst_QLine::testLength() |
|
278 { |
|
279 QFETCH(double, x1); |
|
280 QFETCH(double, y1); |
|
281 QFETCH(double, x2); |
|
282 QFETCH(double, y2); |
|
283 QFETCH(double, length); |
|
284 QFETCH(double, lengthToSet); |
|
285 QFETCH(double, vx); |
|
286 QFETCH(double, vy); |
|
287 |
|
288 QLineF l(x1, y1, x2, y2); |
|
289 QCOMPARE(l.length(), qreal(length)); |
|
290 |
|
291 l.setLength(lengthToSet); |
|
292 QCOMPARE(l.length(), qreal(lengthToSet)); |
|
293 QCOMPARE(l.dx(), qreal(vx)); |
|
294 QCOMPARE(l.dy(), qreal(vy)); |
|
295 } |
|
296 |
|
297 |
|
298 void tst_QLine::testNormalVector_data() |
|
299 { |
|
300 QTest::addColumn<double>("x1"); |
|
301 QTest::addColumn<double>("y1"); |
|
302 QTest::addColumn<double>("x2"); |
|
303 QTest::addColumn<double>("y2"); |
|
304 QTest::addColumn<double>("nvx"); |
|
305 QTest::addColumn<double>("nvy"); |
|
306 |
|
307 QTest::newRow("[1, 0]") << 0.0 << 0.0 << 1.0 << 0.0 << 0.0 << -1.0; |
|
308 QTest::newRow("[-1, 0]") << 0.0 << 0.0 << -1.0 << 0.0 << 0.0 << 1.0; |
|
309 QTest::newRow("[0, 1]") << 0.0 << 0.0 << 0.0 << 1.0 << 1.0 << 0.0; |
|
310 QTest::newRow("[0, -1]") << 0.0 << 0.0 << 0.0 << -1.0 << -1.0 << 0.0; |
|
311 QTest::newRow("[2, 3]") << 2.0 << 3.0 << 4.0 << 6.0 << 3.0 << -2.0; |
|
312 } |
|
313 |
|
314 void tst_QLine::testNormalVector() |
|
315 { |
|
316 QFETCH(double, x1); |
|
317 QFETCH(double, y1); |
|
318 QFETCH(double, x2); |
|
319 QFETCH(double, y2); |
|
320 QFETCH(double, nvx); |
|
321 QFETCH(double, nvy); |
|
322 |
|
323 QLineF l(x1, y1, x2, y2); |
|
324 QLineF n = l.normalVector(); |
|
325 |
|
326 QCOMPARE(l.x1(), n.x1()); |
|
327 QCOMPARE(l.y1(), n.y1()); |
|
328 |
|
329 QCOMPARE(n.dx(), qreal(nvx)); |
|
330 QCOMPARE(n.dy(), qreal(nvy)); |
|
331 } |
|
332 |
|
333 void tst_QLine::testAngle_data() |
|
334 { |
|
335 QTest::addColumn<double>("xa1"); |
|
336 QTest::addColumn<double>("ya1"); |
|
337 QTest::addColumn<double>("xa2"); |
|
338 QTest::addColumn<double>("ya2"); |
|
339 QTest::addColumn<double>("xb1"); |
|
340 QTest::addColumn<double>("yb1"); |
|
341 QTest::addColumn<double>("xb2"); |
|
342 QTest::addColumn<double>("yb2"); |
|
343 QTest::addColumn<double>("angle"); |
|
344 |
|
345 QTest::newRow("parallel") << 1.0 << 1.0 << 3.0 << 4.0 |
|
346 << 5.0 << 6.0 << 7.0 << 9.0 |
|
347 << 0.0; |
|
348 QTest::newRow("[4,4]-[4,0]") << 1.0 << 1.0 << 5.0 << 5.0 |
|
349 << 0.0 << 4.0 << 3.0 << 4.0 |
|
350 << 45.0; |
|
351 QTest::newRow("[4,4]-[-4,0]") << 1.0 << 1.0 << 5.0 << 5.0 |
|
352 << 3.0 << 4.0 << 0.0 << 4.0 |
|
353 << 135.0; |
|
354 |
|
355 for (int i=0; i<180; ++i) { |
|
356 QTest::newRow(QString("angle:%1").arg(i).toLatin1()) |
|
357 << 0.0 << 0.0 << double(cos(i*M_2PI/360)) << double(sin(i*M_2PI/360)) |
|
358 << 0.0 << 0.0 << 1.0 << 0.0 |
|
359 << double(i); |
|
360 } |
|
361 } |
|
362 |
|
363 void tst_QLine::testAngle() |
|
364 { |
|
365 QFETCH(double, xa1); |
|
366 QFETCH(double, ya1); |
|
367 QFETCH(double, xa2); |
|
368 QFETCH(double, ya2); |
|
369 QFETCH(double, xb1); |
|
370 QFETCH(double, yb1); |
|
371 QFETCH(double, xb2); |
|
372 QFETCH(double, yb2); |
|
373 QFETCH(double, angle); |
|
374 |
|
375 QLineF a(xa1, ya1, xa2, ya2); |
|
376 QLineF b(xb1, yb1, xb2, yb2); |
|
377 |
|
378 double resultAngle = a.angle(b); |
|
379 QCOMPARE(qRound(resultAngle), qRound(angle)); |
|
380 } |
|
381 |
|
382 void tst_QLine::testAngle2_data() |
|
383 { |
|
384 QTest::addColumn<qreal>("x1"); |
|
385 QTest::addColumn<qreal>("y1"); |
|
386 QTest::addColumn<qreal>("x2"); |
|
387 QTest::addColumn<qreal>("y2"); |
|
388 QTest::addColumn<qreal>("angle"); |
|
389 |
|
390 QTest::newRow("right") << qreal(0.0) << qreal(0.0) << qreal(10.0) << qreal(0.0) << qreal(0.0); |
|
391 QTest::newRow("left") << qreal(0.0) << qreal(0.0) << qreal(-10.0) << qreal(0.0) << qreal(180.0); |
|
392 QTest::newRow("up") << qreal(0.0) << qreal(0.0) << qreal(0.0) << qreal(-10.0) << qreal(90.0); |
|
393 QTest::newRow("down") << qreal(0.0) << qreal(0.0) << qreal(0.0) << qreal(10.0) << qreal(270.0); |
|
394 |
|
395 QTest::newRow("diag a") << qreal(0.0) << qreal(0.0) << qreal(10.0) << qreal(-10.0) << qreal(45.0); |
|
396 QTest::newRow("diag b") << qreal(0.0) << qreal(0.0) << qreal(-10.0) << qreal(-10.0) << qreal(135.0); |
|
397 QTest::newRow("diag c") << qreal(0.0) << qreal(0.0) << qreal(-10.0) << qreal(10.0) << qreal(225.0); |
|
398 QTest::newRow("diag d") << qreal(0.0) << qreal(0.0) << qreal(10.0) << qreal(10.0) << qreal(315.0); |
|
399 } |
|
400 |
|
401 void tst_QLine::testAngle2() |
|
402 { |
|
403 QFETCH(qreal, x1); |
|
404 QFETCH(qreal, y1); |
|
405 QFETCH(qreal, x2); |
|
406 QFETCH(qreal, y2); |
|
407 QFETCH(qreal, angle); |
|
408 |
|
409 QLineF line(x1, y1, x2, y2); |
|
410 QCOMPARE(line.angle(), angle); |
|
411 |
|
412 QLineF polar = QLineF::fromPolar(line.length(), angle); |
|
413 |
|
414 QVERIFY(qAbs(line.x1() - polar.x1()) < epsilon); |
|
415 QVERIFY(qAbs(line.y1() - polar.y1()) < epsilon); |
|
416 QVERIFY(qAbs(line.x2() - polar.x2()) < epsilon); |
|
417 QVERIFY(qAbs(line.y2() - polar.y2()) < epsilon); |
|
418 } |
|
419 |
|
420 void tst_QLine::testAngle3() |
|
421 { |
|
422 for (int i = -720; i <= 720; ++i) { |
|
423 QLineF line(0, 0, 100, 0); |
|
424 line.setAngle(i); |
|
425 const int expected = (i + 720) % 360; |
|
426 |
|
427 QVERIFY2(qAbs(line.angle() - qreal(expected)) < epsilon, qPrintable(QString::fromLatin1("value: %1").arg(i))); |
|
428 |
|
429 QCOMPARE(line.length(), qreal(100.0)); |
|
430 |
|
431 QCOMPARE(QLineF::fromPolar(100.0, i), line); |
|
432 } |
|
433 } |
|
434 |
|
435 void tst_QLine::testAngleTo() |
|
436 { |
|
437 QFETCH(qreal, xa1); |
|
438 QFETCH(qreal, ya1); |
|
439 QFETCH(qreal, xa2); |
|
440 QFETCH(qreal, ya2); |
|
441 QFETCH(qreal, xb1); |
|
442 QFETCH(qreal, yb1); |
|
443 QFETCH(qreal, xb2); |
|
444 QFETCH(qreal, yb2); |
|
445 QFETCH(qreal, angle); |
|
446 |
|
447 QLineF a(xa1, ya1, xa2, ya2); |
|
448 QLineF b(xb1, yb1, xb2, yb2); |
|
449 |
|
450 const qreal resultAngle = a.angleTo(b); |
|
451 QVERIFY(qAbs(resultAngle - angle) < epsilon); |
|
452 |
|
453 a.translate(b.p1() - a.p1()); |
|
454 a.setAngle(a.angle() + resultAngle); |
|
455 a.setLength(b.length()); |
|
456 |
|
457 QCOMPARE(a, b); |
|
458 } |
|
459 |
|
460 void tst_QLine::testAngleTo_data() |
|
461 { |
|
462 QTest::addColumn<qreal>("xa1"); |
|
463 QTest::addColumn<qreal>("ya1"); |
|
464 QTest::addColumn<qreal>("xa2"); |
|
465 QTest::addColumn<qreal>("ya2"); |
|
466 QTest::addColumn<qreal>("xb1"); |
|
467 QTest::addColumn<qreal>("yb1"); |
|
468 QTest::addColumn<qreal>("xb2"); |
|
469 QTest::addColumn<qreal>("yb2"); |
|
470 QTest::addColumn<qreal>("angle"); |
|
471 |
|
472 QTest::newRow("parallel") << qreal(1.0) << qreal(1.0) << qreal(3.0) << qreal(4.0) |
|
473 << qreal(5.0) << qreal(6.0) << qreal(7.0) << qreal(9.0) |
|
474 << qreal(0.0); |
|
475 QTest::newRow("[4,4]-[4,0]") << qreal(1.0) << qreal(1.0) << qreal(5.0) << qreal(5.0) |
|
476 << qreal(0.0) << qreal(4.0) << qreal(3.0) << qreal(4.0) |
|
477 << qreal(45.0); |
|
478 QTest::newRow("[4,4]-[-4,0]") << qreal(1.0) << qreal(1.0) << qreal(5.0) << qreal(5.0) |
|
479 << qreal(3.0) << qreal(4.0) << qreal(0.0) << qreal(4.0) |
|
480 << qreal(225.0); |
|
481 |
|
482 for (int i = 0; i < 360; ++i) { |
|
483 const QLineF l = QLineF::fromPolar(1, i); |
|
484 QTest::newRow(QString("angle:%1").arg(i).toLatin1()) |
|
485 << qreal(0.0) << qreal(0.0) << qreal(1.0) << qreal(0.0) |
|
486 << qreal(0.0) << qreal(0.0) << l.p2().x() << l.p2().y() |
|
487 << qreal(i); |
|
488 } |
|
489 } |
|
490 |
|
491 QTEST_MAIN(tst_QLine) |
|
492 #include "tst_qline.moc" |