1/****************************************************************************
2**
3** Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com>
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#include <QtTest/QtTest>
30#include <Qt3DCore/private/vector4d_p.h>
31
32class tst_Vector4D_Base: public QObject
33{
34 Q_OBJECT
35private Q_SLOTS:
36 void defaultConstruction()
37 {
38 // GIVEN
39 QVector4D vec4;
40
41 // THEN
42 QCOMPARE(vec4.x(), 0.0f);
43 QCOMPARE(vec4.y(), 0.0f);
44 QCOMPARE(vec4.z(), 0.0f);
45 QCOMPARE(vec4.w(), 0.0f);
46 }
47
48 void checkExplicitConstruction()
49 {
50 // GIVEN
51 QVector4D vec4(427.0f, 454.0f, 383.0f, 350.0f);
52
53 // THEN
54 QCOMPARE(vec4.x(), 427.0f);
55 QCOMPARE(vec4.y(), 454.0f);
56 QCOMPARE(vec4.z(), 383.0f);
57 QCOMPARE(vec4.w(), 350.0f);
58 }
59
60 void checkSelfAddition_data()
61 {
62 QTest::addColumn<float>(name: "xO");
63 QTest::addColumn<float>(name: "yO");
64 QTest::addColumn<float>(name: "zO");
65 QTest::addColumn<float>(name: "wO");
66
67 QTest::addColumn<float>(name: "xA");
68 QTest::addColumn<float>(name: "yA");
69 QTest::addColumn<float>(name: "zA");
70 QTest::addColumn<float>(name: "wA");
71
72 QTest::addColumn<float>(name: "xR");
73 QTest::addColumn<float>(name: "yR");
74 QTest::addColumn<float>(name: "zR");
75 QTest::addColumn<float>(name: "wR");
76
77 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 0.0f << 0.0f
78 << 1.0f << 5.0f << 8.0f << -5.0f
79 << 1.0f << 5.0f << 8.0f << -5.0f;
80
81 QTest::newRow(dataTag: "sample_2") << -5.0f << 8.0f << -4.0f << 6.0f
82 << 5.0f << -8.0f << 4.0f << -6.0f
83 << 0.0f << 0.0f << 0.0f << 0.0f;
84 }
85
86 void checkSelfAddition()
87 {
88 QFETCH(float, xO);
89 QFETCH(float, yO);
90 QFETCH(float, zO);
91 QFETCH(float, wO);
92
93 QFETCH(float, xA);
94 QFETCH(float, yA);
95 QFETCH(float, zA);
96 QFETCH(float, wA);
97
98 QFETCH(float, xR);
99 QFETCH(float, yR);
100 QFETCH(float, zR);
101 QFETCH(float, wR);
102
103 // GIVEN
104 QVector4D vo(xO, yO, zO, wO);
105
106 // WHEN
107 vo += QVector4D(xA, yA, zA, wA);
108
109 // THEN
110 QCOMPARE(vo.x(), xR);
111 QCOMPARE(vo.y(), yR);
112 QCOMPARE(vo.z(), zR);
113 QCOMPARE(vo.w(), wR);
114 }
115
116 void checkSelfSubstraction_data()
117 {
118 QTest::addColumn<float>(name: "xO");
119 QTest::addColumn<float>(name: "yO");
120 QTest::addColumn<float>(name: "zO");
121 QTest::addColumn<float>(name: "wO");
122
123 QTest::addColumn<float>(name: "xA");
124 QTest::addColumn<float>(name: "yA");
125 QTest::addColumn<float>(name: "zA");
126 QTest::addColumn<float>(name: "wA");
127
128 QTest::addColumn<float>(name: "xR");
129 QTest::addColumn<float>(name: "yR");
130 QTest::addColumn<float>(name: "zR");
131 QTest::addColumn<float>(name: "wR");
132
133 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 0.0f << 0.0f
134 << 1.0f << 5.0f << 8.0f << -5.0f
135 << -1.0f << -5.0f << -8.0f << 5.0f;
136
137 QTest::newRow(dataTag: "sample_2") << -5.0f << 8.0f << -4.0f << 6.0f
138 << 5.0f << -8.0f << 4.0f << -6.0f
139 << -10.0f << 16.0f << -8.0f << 12.0f;
140 }
141
142 void checkSelfSubstraction()
143 {
144 QFETCH(float, xO);
145 QFETCH(float, yO);
146 QFETCH(float, zO);
147 QFETCH(float, wO);
148
149 QFETCH(float, xA);
150 QFETCH(float, yA);
151 QFETCH(float, zA);
152 QFETCH(float, wA);
153
154 QFETCH(float, xR);
155 QFETCH(float, yR);
156 QFETCH(float, zR);
157 QFETCH(float, wR);
158
159 // GIVEN
160 QVector4D vo(xO, yO, zO, wO);
161
162 // WHEN
163 vo -= QVector4D(xA, yA, zA, wA);
164
165 // THEN
166 QCOMPARE(vo.x(), xR);
167 QCOMPARE(vo.y(), yR);
168 QCOMPARE(vo.z(), zR);
169 QCOMPARE(vo.w(), wR);
170 }
171
172 void checkSelfMultiplication_data()
173 {
174 QTest::addColumn<float>(name: "xO");
175 QTest::addColumn<float>(name: "yO");
176 QTest::addColumn<float>(name: "zO");
177 QTest::addColumn<float>(name: "wO");
178
179 QTest::addColumn<float>(name: "xA");
180 QTest::addColumn<float>(name: "yA");
181 QTest::addColumn<float>(name: "zA");
182 QTest::addColumn<float>(name: "wA");
183
184 QTest::addColumn<float>(name: "xR");
185 QTest::addColumn<float>(name: "yR");
186 QTest::addColumn<float>(name: "zR");
187 QTest::addColumn<float>(name: "wR");
188
189 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 2.0f << 1.0f
190 << 1.0f << 5.0f << 8.0f << -5.0f
191 << 0.0f << 0.0f << 16.0f << -5.0f;
192
193 QTest::newRow(dataTag: "sample_2") << -5.0f << 8.0f << 4.0f << 6.0f
194 << 5.0f << -8.0f << 4.0f << 6.0f
195 << -25.0f << -64.0f << 16.0f << 36.0f;
196 }
197
198 void checkSelfMultiplication()
199 {
200 QFETCH(float, xO);
201 QFETCH(float, yO);
202 QFETCH(float, zO);
203 QFETCH(float, wO);
204
205 QFETCH(float, xA);
206 QFETCH(float, yA);
207 QFETCH(float, zA);
208 QFETCH(float, wA);
209
210 QFETCH(float, xR);
211 QFETCH(float, yR);
212 QFETCH(float, zR);
213 QFETCH(float, wR);
214
215 // GIVEN
216 QVector4D vo(xO, yO, zO, wO);
217
218 // WHEN
219 vo *= QVector4D(xA, yA, zA, wA);
220
221 // THEN
222 QCOMPARE(vo.x(), xR);
223 QCOMPARE(vo.y(), yR);
224 QCOMPARE(vo.z(), zR);
225 QCOMPARE(vo.w(), wR);
226 }
227
228 void checkSelfDivision_data()
229 {
230 QTest::addColumn<float>(name: "xO");
231 QTest::addColumn<float>(name: "yO");
232 QTest::addColumn<float>(name: "zO");
233 QTest::addColumn<float>(name: "wO");
234
235 QTest::addColumn<float>(name: "xA");
236 QTest::addColumn<float>(name: "yA");
237 QTest::addColumn<float>(name: "zA");
238 QTest::addColumn<float>(name: "wA");
239
240 QTest::addColumn<float>(name: "xR");
241 QTest::addColumn<float>(name: "yR");
242 QTest::addColumn<float>(name: "zR");
243 QTest::addColumn<float>(name: "wR");
244
245 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 2.0f << 1.0f
246 << 1.0f << 5.0f << 8.0f << -5.0f
247 << 0.0f << 0.0f << 0.25f << -0.20f;
248
249 QTest::newRow(dataTag: "sample_2") << -5.0f << 8.0f << 4.0f << 6.0f
250 << 5.0f << -8.0f << 4.0f << 6.0f
251 << -1.0f << -1.0f << 1.0f << 1.0f;
252 }
253
254 void checkSelfDivision()
255 {
256 QFETCH(float, xO);
257 QFETCH(float, yO);
258 QFETCH(float, zO);
259 QFETCH(float, wO);
260
261 QFETCH(float, xA);
262 QFETCH(float, yA);
263 QFETCH(float, zA);
264 QFETCH(float, wA);
265
266 QFETCH(float, xR);
267 QFETCH(float, yR);
268 QFETCH(float, zR);
269 QFETCH(float, wR);
270
271 // GIVEN
272 QVector4D vo(xO, yO, zO, wO);
273
274 // WHEN
275 vo /= QVector4D(xA, yA, zA, wA);
276
277 // THEN
278 QCOMPARE(vo.x(), xR);
279 QCOMPARE(vo.y(), yR);
280 QCOMPARE(vo.z(), zR);
281 QCOMPARE(vo.w(), wR);
282 }
283
284 void checkSelfDivisionFactor_data()
285 {
286 QTest::addColumn<float>(name: "xO");
287 QTest::addColumn<float>(name: "yO");
288 QTest::addColumn<float>(name: "zO");
289 QTest::addColumn<float>(name: "wO");
290
291 QTest::addColumn<float>(name: "factor");
292
293 QTest::addColumn<float>(name: "xR");
294 QTest::addColumn<float>(name: "yR");
295 QTest::addColumn<float>(name: "zR");
296 QTest::addColumn<float>(name: "wR");
297
298 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 2.0f << 1.0f
299 << 1.0f
300 << 0.0f << 0.0f << 2.0f << 1.0f;
301
302 QTest::newRow(dataTag: "sample_2") << -5.0f << 20.0f << -25.0f << 10.0f
303 << 5.0f
304 << -1.0f << 4.0f << -5.0f << 2.0f;
305 }
306
307 void checkSelfDivisionFactor()
308 {
309 QFETCH(float, xO);
310 QFETCH(float, yO);
311 QFETCH(float, zO);
312 QFETCH(float, wO);
313
314 QFETCH(float, factor);
315
316 QFETCH(float, xR);
317 QFETCH(float, yR);
318 QFETCH(float, zR);
319 QFETCH(float, wR);
320
321 // GIVEN
322 QVector4D vo(xO, yO, zO, wO);
323
324 // WHEN
325 vo /= factor;
326
327 // THEN
328 QCOMPARE(vo.x(), xR);
329 QCOMPARE(vo.y(), yR);
330 QCOMPARE(vo.z(), zR);
331 QCOMPARE(vo.w(), wR);
332 }
333
334 void checkSelfMultiplicationFactor_data()
335 {
336 QTest::addColumn<float>(name: "xO");
337 QTest::addColumn<float>(name: "yO");
338 QTest::addColumn<float>(name: "zO");
339 QTest::addColumn<float>(name: "wO");
340
341 QTest::addColumn<float>(name: "factor");
342
343 QTest::addColumn<float>(name: "xR");
344 QTest::addColumn<float>(name: "yR");
345 QTest::addColumn<float>(name: "zR");
346 QTest::addColumn<float>(name: "wR");
347
348 QTest::newRow(dataTag: "sample_1") << 0.0f << -3.0f << 2.0f << 1.0f
349 << 1.0f
350 << 0.0f << -3.0f << 2.0f << 1.0f;
351
352 QTest::newRow(dataTag: "sample_2") << -5.0f << 20.0f << -25.0f << 10.0f
353 << 5.0f
354 << -25.0f << 100.0f << -125.0f << 50.0f;
355 }
356
357 void checkSelfMultiplicationFactor()
358 {
359 QFETCH(float, xO);
360 QFETCH(float, yO);
361 QFETCH(float, zO);
362 QFETCH(float, wO);
363
364 QFETCH(float, factor);
365
366 QFETCH(float, xR);
367 QFETCH(float, yR);
368 QFETCH(float, zR);
369 QFETCH(float, wR);
370
371 // GIVEN
372 QVector4D vo(xO, yO, zO, wO);
373
374 // WHEN
375 vo *= factor;
376
377 // THEN
378 QCOMPARE(vo.x(), xR);
379 QCOMPARE(vo.y(), yR);
380 QCOMPARE(vo.z(), zR);
381 QCOMPARE(vo.w(), wR);
382 }
383
384 void checkAddition_data()
385 {
386 QTest::addColumn<float>(name: "xO");
387 QTest::addColumn<float>(name: "yO");
388 QTest::addColumn<float>(name: "zO");
389 QTest::addColumn<float>(name: "wO");
390
391 QTest::addColumn<float>(name: "xA");
392 QTest::addColumn<float>(name: "yA");
393 QTest::addColumn<float>(name: "zA");
394 QTest::addColumn<float>(name: "wA");
395
396 QTest::addColumn<float>(name: "xR");
397 QTest::addColumn<float>(name: "yR");
398 QTest::addColumn<float>(name: "zR");
399 QTest::addColumn<float>(name: "wR");
400
401 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 0.0f << 0.0f
402 << 1.0f << 5.0f << 8.0f << -5.0f
403 << 1.0f << 5.0f << 8.0f << -5.0f;
404
405 QTest::newRow(dataTag: "sample_2") << -5.0f << 8.0f << -4.0f << 6.0f
406 << 5.0f << -8.0f << 4.0f << -6.0f
407 << 0.0f << 0.0f << 0.0f << 0.0f;
408 }
409
410 void checkAddition()
411 {
412 QFETCH(float, xO);
413 QFETCH(float, yO);
414 QFETCH(float, zO);
415 QFETCH(float, wO);
416
417 QFETCH(float, xA);
418 QFETCH(float, yA);
419 QFETCH(float, zA);
420 QFETCH(float, wA);
421
422 QFETCH(float, xR);
423 QFETCH(float, yR);
424 QFETCH(float, zR);
425 QFETCH(float, wR);
426
427 // GIVEN
428 QVector4D v0(xO, yO, zO, wO);
429 QVector4D v1(xA, yA, zA, wA);
430
431 // WHEN
432 QVector4D v2 = v0 + v1;
433
434 // THEN
435 QCOMPARE(v2.x(), xR);
436 QCOMPARE(v2.y(), yR);
437 QCOMPARE(v2.z(), zR);
438 QCOMPARE(v2.w(), wR);
439 }
440
441 void checkSubstraction_data()
442 {
443 QTest::addColumn<float>(name: "xO");
444 QTest::addColumn<float>(name: "yO");
445 QTest::addColumn<float>(name: "zO");
446 QTest::addColumn<float>(name: "wO");
447
448 QTest::addColumn<float>(name: "xA");
449 QTest::addColumn<float>(name: "yA");
450 QTest::addColumn<float>(name: "zA");
451 QTest::addColumn<float>(name: "wA");
452
453 QTest::addColumn<float>(name: "xR");
454 QTest::addColumn<float>(name: "yR");
455 QTest::addColumn<float>(name: "zR");
456 QTest::addColumn<float>(name: "wR");
457
458 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 0.0f << 0.0f
459 << 1.0f << 5.0f << 8.0f << -5.0f
460 << -1.0f << -5.0f << -8.0f << 5.0f;
461
462 QTest::newRow(dataTag: "sample_2") << -5.0f << 8.0f << -4.0f << 6.0f
463 << 5.0f << -8.0f << 4.0f << -6.0f
464 << -10.0f << 16.0f << -8.0f << 12.0f;
465 }
466
467 void checkSubstraction()
468 {
469 QFETCH(float, xO);
470 QFETCH(float, yO);
471 QFETCH(float, zO);
472 QFETCH(float, wO);
473
474 QFETCH(float, xA);
475 QFETCH(float, yA);
476 QFETCH(float, zA);
477 QFETCH(float, wA);
478
479 QFETCH(float, xR);
480 QFETCH(float, yR);
481 QFETCH(float, zR);
482 QFETCH(float, wR);
483
484 // GIVEN
485 QVector4D v0(xO, yO, zO, wO);
486 QVector4D v1(xA, yA, zA, wA);
487
488 // WHEN
489 QVector4D v2 = v0 - v1;
490
491 // THEN
492 QCOMPARE(v2.x(), xR);
493 QCOMPARE(v2.y(), yR);
494 QCOMPARE(v2.z(), zR);
495 QCOMPARE(v2.w(), wR);
496 }
497
498 void checkMultiplication_data()
499 {
500 QTest::addColumn<float>(name: "xO");
501 QTest::addColumn<float>(name: "yO");
502 QTest::addColumn<float>(name: "zO");
503 QTest::addColumn<float>(name: "wO");
504
505 QTest::addColumn<float>(name: "xA");
506 QTest::addColumn<float>(name: "yA");
507 QTest::addColumn<float>(name: "zA");
508 QTest::addColumn<float>(name: "wA");
509
510 QTest::addColumn<float>(name: "xR");
511 QTest::addColumn<float>(name: "yR");
512 QTest::addColumn<float>(name: "zR");
513 QTest::addColumn<float>(name: "wR");
514
515 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 2.0f << 1.0f
516 << 1.0f << 5.0f << 8.0f << -5.0f
517 << 0.0f << 0.0f << 16.0f << -5.0f;
518
519 QTest::newRow(dataTag: "sample_2") << -5.0f << 8.0f << 4.0f << 6.0f
520 << 5.0f << -8.0f << 4.0f << 6.0f
521 << -25.0f << -64.0f << 16.0f << 36.0f;
522 }
523
524 void checkMultiplication()
525 {
526 QFETCH(float, xO);
527 QFETCH(float, yO);
528 QFETCH(float, zO);
529 QFETCH(float, wO);
530
531 QFETCH(float, xA);
532 QFETCH(float, yA);
533 QFETCH(float, zA);
534 QFETCH(float, wA);
535
536 QFETCH(float, xR);
537 QFETCH(float, yR);
538 QFETCH(float, zR);
539 QFETCH(float, wR);
540
541 // GIVEN
542 QVector4D v0(xO, yO, zO, wO);
543 QVector4D v1(xA, yA, zA, wA);
544
545 // WHEN
546 QVector4D v2 = v0 * v1;
547
548 // THEN
549 QCOMPARE(v2.x(), xR);
550 QCOMPARE(v2.y(), yR);
551 QCOMPARE(v2.z(), zR);
552 QCOMPARE(v2.w(), wR);
553 }
554
555 void checkDivision_data()
556 {
557 QTest::addColumn<float>(name: "xO");
558 QTest::addColumn<float>(name: "yO");
559 QTest::addColumn<float>(name: "zO");
560 QTest::addColumn<float>(name: "wO");
561
562 QTest::addColumn<float>(name: "xA");
563 QTest::addColumn<float>(name: "yA");
564 QTest::addColumn<float>(name: "zA");
565 QTest::addColumn<float>(name: "wA");
566
567 QTest::addColumn<float>(name: "xR");
568 QTest::addColumn<float>(name: "yR");
569 QTest::addColumn<float>(name: "zR");
570 QTest::addColumn<float>(name: "wR");
571
572 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 2.0f << 1.0f
573 << 1.0f << 5.0f << 8.0f << -5.0f
574 << 0.0f << 0.0f << 0.25f << -0.20f;
575
576 QTest::newRow(dataTag: "sample_2") << -5.0f << 8.0f << 4.0f << 6.0f
577 << 5.0f << -8.0f << 4.0f << 6.0f
578 << -1.0f << -1.0f << 1.0f << 1.0f;
579 }
580
581 void checkDivision()
582 {
583 QFETCH(float, xO);
584 QFETCH(float, yO);
585 QFETCH(float, zO);
586 QFETCH(float, wO);
587
588 QFETCH(float, xA);
589 QFETCH(float, yA);
590 QFETCH(float, zA);
591 QFETCH(float, wA);
592
593 QFETCH(float, xR);
594 QFETCH(float, yR);
595 QFETCH(float, zR);
596 QFETCH(float, wR);
597
598 // GIVEN
599 QVector4D v0(xO, yO, zO, wO);
600 QVector4D v1(xA, yA, zA, wA);
601
602 // WHEN
603 QVector4D v2 = v0 / v1;
604
605 // THEN
606 QCOMPARE(v2.x(), xR);
607 QCOMPARE(v2.y(), yR);
608 QCOMPARE(v2.z(), zR);
609 QCOMPARE(v2.w(), wR);
610 }
611
612 void checkDivisionFactor_data()
613 {
614 QTest::addColumn<float>(name: "xO");
615 QTest::addColumn<float>(name: "yO");
616 QTest::addColumn<float>(name: "zO");
617 QTest::addColumn<float>(name: "wO");
618
619 QTest::addColumn<float>(name: "factor");
620
621 QTest::addColumn<float>(name: "xR");
622 QTest::addColumn<float>(name: "yR");
623 QTest::addColumn<float>(name: "zR");
624 QTest::addColumn<float>(name: "wR");
625
626 QTest::newRow(dataTag: "sample_1") << 0.0f << 0.0f << 2.0f << 1.0f
627 << 1.0f
628 << 0.0f << 0.0f << 2.0f << 1.0f;
629
630 QTest::newRow(dataTag: "sample_2") << -5.0f << 20.0f << -25.0f << 10.0f
631 << 5.0f
632 << -1.0f << 4.0f << -5.0f << 2.0f;
633 }
634
635 void checkDivisionFactor()
636 {
637 QFETCH(float, xO);
638 QFETCH(float, yO);
639 QFETCH(float, zO);
640 QFETCH(float, wO);
641
642 QFETCH(float, factor);
643
644 QFETCH(float, xR);
645 QFETCH(float, yR);
646 QFETCH(float, zR);
647 QFETCH(float, wR);
648
649 // GIVEN
650 QVector4D v0(xO, yO, zO, wO);
651
652 // WHEN
653 QVector4D v2 = v0 / factor;
654
655 // THEN
656 QCOMPARE(v2.x(), xR);
657 QCOMPARE(v2.y(), yR);
658 QCOMPARE(v2.z(), zR);
659 QCOMPARE(v2.w(), wR);
660 }
661
662 void checkMultiplicationFactor_data()
663 {
664 QTest::addColumn<float>(name: "xO");
665 QTest::addColumn<float>(name: "yO");
666 QTest::addColumn<float>(name: "zO");
667 QTest::addColumn<float>(name: "wO");
668
669 QTest::addColumn<float>(name: "factor");
670
671 QTest::addColumn<float>(name: "xR");
672 QTest::addColumn<float>(name: "yR");
673 QTest::addColumn<float>(name: "zR");
674 QTest::addColumn<float>(name: "wR");
675
676 QTest::newRow(dataTag: "sample_1") << 0.0f << -3.0f << 2.0f << 1.0f
677 << 1.0f
678 << 0.0f << -3.0f << 2.0f << 1.0f;
679
680 QTest::newRow(dataTag: "sample_2") << -5.0f << 20.0f << -25.0f << 10.0f
681 << 5.0f
682 << -25.0f << 100.0f << -125.0f << 50.0f;
683 }
684
685 void checkMultiplicationFactor()
686 {
687 QFETCH(float, xO);
688 QFETCH(float, yO);
689 QFETCH(float, zO);
690 QFETCH(float, wO);
691
692 QFETCH(float, factor);
693
694 QFETCH(float, xR);
695 QFETCH(float, yR);
696 QFETCH(float, zR);
697 QFETCH(float, wR);
698
699 // GIVEN
700 QVector4D v0(xO, yO, zO, wO);
701
702 // WHEN
703 QVector4D v2 = v0 * factor;
704
705 // THEN
706 QCOMPARE(v2.x(), xR);
707 QCOMPARE(v2.y(), yR);
708 QCOMPARE(v2.z(), zR);
709 QCOMPARE(v2.w(), wR);
710 }
711
712 void checkEquality()
713 {
714 {
715 // GIVEN
716 QVector4D v0;
717 QVector4D v1;
718
719 // THEN
720 QVERIFY(v0 == v1);
721 }
722 {
723 // GIVEN
724 QVector4D v0(1.0f, 2.0f, -5.0f, 10.0f);
725 QVector4D v1(1.0f, 2.0f, -5.0f, 10.0f);
726
727 // THEN
728 QVERIFY(v0 == v1);
729 }
730 }
731
732 void checkInequality()
733 {
734 {
735 // GIVEN
736 QVector4D v0;
737 QVector4D v1;
738
739 // THEN
740 QVERIFY(!(v0 != v1));
741 }
742 {
743 // GIVEN
744 QVector4D v0(1.0f, 2.0f, -5.0f, 10.0f);
745 QVector4D v1(1.0f, 5.0f, -5.0f, 10.0f);
746
747 // THEN
748 QVERIFY(v0 != v1);
749 }
750 }
751
752 void checkToQQVector4D()
753 {
754 {
755 // GIVEN
756 QVector4D v0;
757
758 // WHEN
759 QVector4D v1 = v0;
760
761 // THEN
762 QCOMPARE(v0.x(), v1.x());
763 QCOMPARE(v0.y(), v1.y());
764 QCOMPARE(v0.z(), v1.z());
765 QCOMPARE(v0.w(), v1.w());
766 }
767 {
768 // GIVEN
769 QVector4D v0(1.0f, 2.0f, -5.0f, 10.0f);
770
771 // WHEN
772 QVector4D v1 = v0;
773
774 // THEN
775 QCOMPARE(v0.x(), v1.x());
776 QCOMPARE(v0.y(), v1.y());
777 QCOMPARE(v0.z(), v1.z());
778 QCOMPARE(v0.w(), v1.w());
779 }
780 }
781};
782
783QTEST_APPLESS_MAIN(tst_Vector4D_Base)
784
785#include "tst_vector4d_base.moc"
786

source code of qt3d/tests/auto/core/vector4d_base/tst_vector4d_base.cpp