Browse Source

vector tests

develop
Robin Thoni 7 years ago
parent
commit
ab1e5b3cc6
1 changed files with 59 additions and 1 deletions
  1. 59
    1
      tests/testvector3d.cpp

+ 59
- 1
tests/testvector3d.cpp View File

@@ -37,8 +37,16 @@ private slots:
37 37
     void mult();
38 38
     void multOp();
39 39
 
40
-
41 40
     void div();
41
+    void divOp();
42
+
43
+    void dotProduct1();
44
+    void dotProduct1Op();
45
+    void dotProduct2();
46
+    void dotProduct2Op();
47
+
48
+    void norm1();
49
+    void norm2();
42 50
 };
43 51
 
44 52
 void TestVector3D::gettersSetters1()
@@ -306,5 +314,55 @@ void TestVector3D::div()
306 314
     QCOMPARE(v.getZ(), z / m);
307 315
 }
308 316
 
317
+void TestVector3D::divOp()
318
+{
319
+    double x = 1.42, y = 2.0, z = 3.0, m = 2.0;
320
+    Vector3D v1(x, y, z);
321
+    Vector3D v = v1 / m;
322
+    QCOMPARE(v.getX(), x / m);
323
+    QCOMPARE(v.getY(), y / m);
324
+    QCOMPARE(v.getZ(), z / m);
325
+}
326
+
327
+void TestVector3D::dotProduct1()
328
+{
329
+    Vector3D v1(1.5, 2.0, 3.0);
330
+    Vector3D v2(42.0, 5.0, 7.0);
331
+    QCOMPARE(v1.dotProduct(v2), 94.0);
332
+}
333
+
334
+void TestVector3D::dotProduct1Op()
335
+{
336
+    Vector3D v1(1.5, 2.0, 3.0);
337
+    Vector3D v2(42.0, 5.0, 7.0);
338
+    QCOMPARE(v1 * v2, 94.0);
339
+}
340
+
341
+void TestVector3D::dotProduct2()
342
+{
343
+    Vector3D v1(20, 42, 10);
344
+    Vector3D v2(42.0, 5.0, 7.0);
345
+    QCOMPARE(v1.dotProduct(v2), 1120.0);
346
+}
347
+
348
+void TestVector3D::dotProduct2Op()
349
+{
350
+    Vector3D v1(20, 42, 10);
351
+    Vector3D v2(42.0, 5.0, 7.0);
352
+    QCOMPARE(v1 * v2, 1120.0);
353
+}
354
+
355
+void TestVector3D::norm1()
356
+{
357
+    Vector3D v(3, 4, 0);;
358
+    QCOMPARE(v.norm(), 5.0);
359
+}
360
+
361
+void TestVector3D::norm2()
362
+{
363
+    Vector3D v(0, 30, 40);;
364
+    QCOMPARE(v.norm(), 50.0);
365
+}
366
+
309 367
 QTEST_MAIN(TestVector3D)
310 368
 #include "testvector3d.moc"

Loading…
Cancel
Save