Tests update
This commit is contained in:
@@ -3,11 +3,42 @@
|
||||
|
||||
const uint rows = 3;
|
||||
const uint cols = 3;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> vect;
|
||||
|
||||
bool cmpMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, double val)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
bool b;
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(matrix.at(j,k) == val)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
TEST(PIMathMatrixT_Test, identity)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathMatrixT<rows, cols, double> matrix;
|
||||
double d;
|
||||
double i = 1.0;
|
||||
@@ -38,6 +69,7 @@ TEST(PIMathMatrixT_Test, at)
|
||||
{
|
||||
uint i;
|
||||
bool b;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
matrix1 = matr.identity();
|
||||
@@ -60,6 +92,8 @@ TEST(PIMathMatrixT_Test, filled)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> vect;
|
||||
double g = 1.0;
|
||||
matrix2 = matr.fill(g);
|
||||
uint j = 0, i = 0;
|
||||
@@ -75,16 +109,20 @@ TEST(PIMathMatrixT_Test, filled)
|
||||
|
||||
TEST(PIMathMatrixT_Test, cols)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
ASSERT_EQ(cols,matr.cols());
|
||||
}
|
||||
|
||||
TEST(PIMathMatrixT_Test, rows)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
ASSERT_EQ(rows,matr.rows());
|
||||
}
|
||||
|
||||
TEST(PIMathMatrixT_Test, col)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> vect;
|
||||
uint i;
|
||||
uint g = 2;
|
||||
bool b;
|
||||
@@ -115,6 +153,8 @@ TEST(PIMathMatrixT_Test, col)
|
||||
|
||||
TEST(PIMathMatrixT_Test, row)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> vect;
|
||||
uint i;
|
||||
uint g = 2;
|
||||
bool b;
|
||||
@@ -145,6 +185,8 @@ TEST(PIMathMatrixT_Test, row)
|
||||
|
||||
TEST(PIMathMatrixT_Test, setCol)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> vect;
|
||||
vect.at(0) = 1.0;
|
||||
vect.at(1) = 3.0;
|
||||
vect.at(2) = 5.0;
|
||||
@@ -169,6 +211,8 @@ TEST(PIMathMatrixT_Test, setCol)
|
||||
|
||||
TEST(PIMathMatrixT_Test, setRow)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> vect;
|
||||
vect.at(0) = 1.0;
|
||||
vect.at(1) = 3.0;
|
||||
vect.at(2) = 5.0;
|
||||
@@ -193,6 +237,7 @@ TEST(PIMathMatrixT_Test, setRow)
|
||||
|
||||
TEST(PIMathMatrixT_Test, swapCols)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> before_Vect1;
|
||||
PIMathVectorT<rows, double> before_Vect2;
|
||||
PIMathVectorT<rows, double> after_Vect1;
|
||||
@@ -226,6 +271,7 @@ TEST(PIMathMatrixT_Test, swapCols)
|
||||
|
||||
TEST(PIMathMatrixT_Test, swapRows)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathVectorT<rows, double> before_Vect1;
|
||||
PIMathVectorT<rows, double> before_Vect2;
|
||||
PIMathVectorT<rows, double> after_Vect1;
|
||||
@@ -259,6 +305,7 @@ TEST(PIMathMatrixT_Test, swapRows)
|
||||
|
||||
TEST(PIMathMatrixT_Test, fill)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
double g = 1.0;
|
||||
matr.fill(g);
|
||||
@@ -275,6 +322,7 @@ TEST(PIMathMatrixT_Test, fill)
|
||||
|
||||
TEST(PIMathMatrixT_Test, isSquare)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
const uint new_Cols = 4;
|
||||
PIMathMatrixT<rows, new_Cols, double> matrix2;
|
||||
@@ -292,6 +340,7 @@ TEST(PIMathMatrixT_Test, isSquare)
|
||||
|
||||
TEST(PIMathMatrixT_Test, isIdentity)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
bool b;
|
||||
@@ -312,6 +361,7 @@ TEST(PIMathMatrixT_Test, isNull)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
bool b;
|
||||
matrix2 = matr.filled(3.67);
|
||||
if((matrix1.isNull() == true) && (matrix2.isNull() == false))
|
||||
@@ -329,34 +379,11 @@ TEST(PIMathMatrixT_Test, operator_Assignment)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
bool b;
|
||||
matrix2.fill(6.72);
|
||||
matrix1 = matrix2;
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(matrix1.at(j,k) == 6.72)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
b = cmpMatrixWithValue(matrix1, 6.72);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
|
||||
@@ -364,6 +391,7 @@ TEST(PIMathMatrixT_Test, operator_Equal)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
bool b;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
@@ -393,6 +421,7 @@ TEST(PIMathMatrixT_Test, operator_Not_Equal)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
bool b;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
@@ -421,34 +450,10 @@ TEST(PIMathMatrixT_Test, operator_Addition_Aassignment)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
bool b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
matrix2.fill(6.72);
|
||||
matrix1.fill(1.0);
|
||||
matrix1 += matrix2;
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(matrix1.at(j,k) == 7.72)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
b = cmpMatrixWithValue(matrix1, 7.72);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
|
||||
@@ -457,34 +462,10 @@ TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
bool b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
matrix2.fill(6.72);
|
||||
matrix1.fill(1.0);
|
||||
matrix1 -= matrix2;
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(matrix1.at(j,k) == -5.72)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
b = cmpMatrixWithValue(matrix1, -5.72);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
|
||||
@@ -492,33 +473,9 @@ TEST(PIMathMatrixT_Test, operator_Multiplication_Assignment)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
bool b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
matrix1.fill(6.72);
|
||||
matrix1 *= 2.0;
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(matrix1.at(j,k) == 13.44)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
b = cmpMatrixWithValue(matrix1, 13.44);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
|
||||
@@ -526,33 +483,9 @@ TEST(PIMathMatrixT_Test, operator_Division_Assignment)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
bool b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
matrix1.fill(6.72);
|
||||
matrix1 /= 2.0;
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(matrix1.at(j,k) == 3.36)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
b = cmpMatrixWithValue(matrix1, 3.36);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
|
||||
@@ -561,33 +494,9 @@ TEST(PIMathMatrixT_Test, operator_Addition)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
bool b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
matrix1.fill(6.72);
|
||||
matrix2.fill(8.28);
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if((matrix1 + matrix2).at(j,k) == 15.0)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
b = cmpMatrixWithValue(matrix1 + matrix2, 15.0);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
|
||||
@@ -596,33 +505,9 @@ TEST(PIMathMatrixT_Test, operator_Subtraction)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
bool b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
matrix1.fill(6.72);
|
||||
matrix2.fill(8.28);
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(round((matrix1 - matrix2).at(j,k) * 10000) / 10000 == -1.56)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
matrix1.fill(6.0);
|
||||
matrix2.fill(5.0);
|
||||
b = cmpMatrixWithValue(matrix1 - matrix2, 1.0);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
|
||||
@@ -631,33 +516,9 @@ TEST(PIMathMatrixT_Test, operator_Multiplication)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
bool b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
matrix1.fill(6.72);
|
||||
matrix2 = matrix1*4.0;
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(matrix2.at(j,k) == 26.88)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
b = cmpMatrixWithValue(matrix2, 26.88);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
TEST(PIMathMatrixT_Test, operator_Division)
|
||||
@@ -665,33 +526,9 @@ TEST(PIMathMatrixT_Test, operator_Division)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
bool b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
matrix1.fill(6.72);
|
||||
matrix2 = matrix1/4.0;
|
||||
while(i < 9)
|
||||
{
|
||||
if(k < 3)
|
||||
{
|
||||
if(matrix2.at(j,k) == 1.68)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
if(k == 3)
|
||||
{
|
||||
j++;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
b = cmpMatrixWithValue(matrix2, 1.68);
|
||||
ASSERT_TRUE(b);
|
||||
}
|
||||
|
||||
@@ -700,6 +537,7 @@ TEST(PIMathMatrixT_Test, determinant)
|
||||
{
|
||||
double d;
|
||||
double i = 59.0;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
@@ -718,6 +556,7 @@ TEST(PIMathMatrixT_Test, invert)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
PIMathMatrixT<rows, cols, double> matrix3;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
double d1, d2;
|
||||
bool b;
|
||||
matrix1 = matr.identity();
|
||||
@@ -752,6 +591,7 @@ TEST(PIMathMatrixT_Test, inverted)
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
PIMathMatrixT<rows, cols, double> matrix3;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
double d1, d2;
|
||||
bool b;
|
||||
matrix1 = matr.identity();
|
||||
@@ -784,6 +624,7 @@ TEST(PIMathMatrixT_Test, toUpperTriangular)
|
||||
PIMathMatrixT<rows, cols, double> matrix;
|
||||
double d1, d2 = 1;
|
||||
uint i;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
matr.at(0,0) = 3;
|
||||
matr.at(0,1) = 6;
|
||||
matr.at(0,2) = 8;
|
||||
@@ -806,6 +647,7 @@ TEST(PIMathMatrixT_Test, transposed)
|
||||
{
|
||||
PIMathMatrixT<rows, cols, double> matrix1;
|
||||
PIMathMatrixT<rows, cols, double> matrix2;
|
||||
PIMathMatrixT<rows, cols, double> matr;
|
||||
double d1, d2;
|
||||
bool b;
|
||||
matr.at(0,0) = 3;
|
||||
|
||||
Reference in New Issue
Block a user