選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

testmatrix3x3.cpp 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include <QtTest/QtTest>
  2. #include "utils/matrix3x3.h"
  3. #include "testmatrix3x3.h"
  4. void TestMatrix3x3::gettersSetters1()
  5. {
  6. Matrix3x3 m;
  7. QCOMPARE(m.getScalar(0, 0), 0.0);
  8. QCOMPARE(m.getScalar(0, 1), 0.0);
  9. QCOMPARE(m.getScalar(1, 0), 0.0);
  10. }
  11. void TestMatrix3x3::gettersSetters2()
  12. {
  13. double scalars[3][3] = {{0.0, 1.0, 2.0},
  14. {3.0, 4.0, 5.0},
  15. {6.0, 7.0, 8.0}};
  16. Matrix3x3 m(scalars);
  17. QCOMPARE(m.getScalar(0, 0), 0.0);
  18. QCOMPARE(m.getScalar(0, 1), 1.0);
  19. QCOMPARE(m.getScalar(1, 0), 3.0);
  20. QCOMPARE(m.getScalar(1, 2), 5.0);
  21. }
  22. void TestMatrix3x3::gettersSetters3()
  23. {
  24. Matrix3x3 m;
  25. m.setScalar(0, 0, 42.0).setScalar(0, 1, 24.0).setScalar(1, 0, 10.0);
  26. QCOMPARE(m.getScalar(0, 0), 42.0);
  27. QCOMPARE(m.getScalar(0, 1), 24.0);
  28. QCOMPARE(m.getScalar(1, 0), 10.0);
  29. }
  30. void TestMatrix3x3::isNull1()
  31. {
  32. double scalars[3][3] = {{0.0, 1.0, 2.0},
  33. {3.0, 4.0, 5.0},
  34. {6.0, 7.0, 8.0}};
  35. Matrix3x3 m(scalars);
  36. QCOMPARE(m.isNull(), false);
  37. }
  38. void TestMatrix3x3::isNull1Op()
  39. {
  40. double scalars[3][3] = {{0.0, 1.0, 2.0},
  41. {3.0, 4.0, 5.0},
  42. {6.0, 7.0, 8.0}};
  43. Matrix3x3 m(scalars);
  44. QCOMPARE((bool)m, true);
  45. }
  46. void TestMatrix3x3::isNull2()
  47. {
  48. Matrix3x3 m;
  49. QCOMPARE(m.isNull(), true);
  50. }
  51. void TestMatrix3x3::isNull2Op()
  52. {
  53. Matrix3x3 m;
  54. QCOMPARE((bool)m, false);
  55. }
  56. void TestMatrix3x3::mult1()
  57. {
  58. double scalars1[3][3] = {{42.0, 5.0, 6.0},
  59. {2.0, 10.0, 9.0},
  60. {69.0, 35.0, 51.0}};
  61. double scalars2[3][3] = {{26.0, 17.0, 35.0},
  62. {6.0, 48.0, 52.0},
  63. {12.0, 25.0, 62.0}};
  64. double scalars3[3][3] = {{1194.0, 1104.0, 2102.0},
  65. {220.0, 739.0, 1148.0},
  66. {2616.0, 4128.0, 7397.0}};
  67. Matrix3x3 m1(scalars1);
  68. Matrix3x3 m2(scalars2);
  69. Matrix3x3 m3(scalars3);
  70. Matrix3x3 m = m1.multMatrix(m2);
  71. QCOMPARE(m.equal(m3), true);
  72. }