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

source code of qt3d/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp