From 9b02325ba1bee410c91dfa27c475f52d0c4751b1 Mon Sep 17 00:00:00 2001 From: maakshishov Date: Thu, 8 Oct 2020 11:16:05 +0300 Subject: [PATCH] PIMathVector Tests bug fix --- tests/math/testpimathmatrixt.cpp | 4 ++-- tests/math/testpimathvector.cpp | 9 ++++----- tests/math/testpimathvectort.cpp | 7 ++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/math/testpimathmatrixt.cpp b/tests/math/testpimathmatrixt.cpp index 59cd14c9..97b37737 100644 --- a/tests/math/testpimathmatrixt.cpp +++ b/tests/math/testpimathmatrixt.cpp @@ -18,8 +18,8 @@ bool cmpSquareMatrixWithValue(PIMathMatrixT matrix, double v TEST(PIMathMatrixT_Test, identity) { auto matrix = PIMathMatrixT::identity(); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 3; j++){ + for(int i = 0; i < rows; i++){ + for(int j = 0; j < cols; j++){ if(i != j){ if(matrix[i][j] != 0.0){ ASSERT_TRUE(false); diff --git a/tests/math/testpimathvector.cpp b/tests/math/testpimathvector.cpp index 9ac59f1a..2320aa19 100644 --- a/tests/math/testpimathvector.cpp +++ b/tests/math/testpimathvector.cpp @@ -16,7 +16,7 @@ bool cmpVectorWithValue(PIMathVector vector, double val, int num) { TEST(PIMathVector_Test, size) { auto vector = PIMathVector(SIZE); - ASSERT_TRUE(vector.size() == SIZE); + ASSERT_EQ(vector.size(), SIZE); } TEST(PIMathVector_Test, resize) { @@ -24,8 +24,8 @@ TEST(PIMathVector_Test, resize) { double a = 5.0; PIMathVector vector; vector.resize(newSize, a); + ASSERT_EQ(vector.size(), newSize); ASSERT_TRUE(cmpVectorWithValue(vector, a, vector.size())); - ASSERT_TRUE(vector.size() == newSize); } TEST(PIMathVector_Test, resized) { @@ -33,8 +33,8 @@ TEST(PIMathVector_Test, resized) { double a = 5.0; PIMathVector vector; auto vect = vector.resized(newSize, a); + ASSERT_EQ(vect.size(), newSize); ASSERT_TRUE(cmpVectorWithValue(vect, a, vect.size())); - ASSERT_TRUE(vect.size() == newSize); } TEST(PIMathVector_Test, fill) { @@ -73,7 +73,7 @@ TEST(PIMathVector_Test, moveVecSizeNotEq) { vec.fill(b); vector.move(vec); ASSERT_TRUE(cmpVectorWithValue(vector, a, SIZE)); - ASSERT_TRUE(vector.size() == SIZE); + ASSERT_EQ(vector.size(), SIZE); } TEST(PIMathVector_Test, swap) { @@ -304,7 +304,6 @@ TEST(PIMathVector_Test, at) { ASSERT_TRUE(false); } } - ASSERT_TRUE(true); } TEST(PIMathVector_Test, operator_AssignmentValue) { diff --git a/tests/math/testpimathvectort.cpp b/tests/math/testpimathvectort.cpp index f29a7527..37d78c9e 100644 --- a/tests/math/testpimathvectort.cpp +++ b/tests/math/testpimathvectort.cpp @@ -230,7 +230,6 @@ TEST(PIMathVectorT_Test, at) { ASSERT_TRUE(false); } } - ASSERT_TRUE(true); } TEST(PIMathVectorT_Test, operator_AssignmentValue) { @@ -406,7 +405,10 @@ TEST(PIMathVectorT_Test, operator_MultiplicationVector2) { PIMathVectorT vector2; vector1[0] = a; vector2[1] = a; - ASSERT_TRUE(((vector1 * vector2)[0] < double(1E-200)) && ((vector1 * vector2)[1] < double(1E-200)) && ((vector1 * vector2)[2] - a < double(1E-200))); + auto vect = vector1 * vector2; + ASSERT_TRUE(vect[0] < double(1E-200)); + ASSERT_TRUE(vect[1] < double(1E-200)); + ASSERT_TRUE(vect[2] - a < double(1E-200)); } TEST(PIMathVectorT_Test, operator_DivisionVal) { @@ -458,7 +460,6 @@ TEST(PIMathVectorT_Test, transposed) { ASSERT_TRUE(false); } } - ASSERT_TRUE(true); } TEST(PIMathVectorT_Test, filled) {