indentation in strings

This commit is contained in:
Шишов Максим Денисович
2020-09-10 17:13:02 +03:00
committed by Федоренко Дмитрий Витальевич
parent f72d4bcda4
commit 9505669780
2 changed files with 98 additions and 206 deletions

View File

@@ -5,8 +5,7 @@ const uint rows = 3;
const uint cols = 3;
template<typename Type>
bool cmpSquareMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, Type val, int num)
{
bool cmpSquareMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, Type val, int num) {
bool b = true;
for(int i = 0; i < num; i++) {
for(int j = 0; j < num; j++) {
@@ -18,8 +17,7 @@ bool cmpSquareMatrixWithValue(PIMathMatrixT<rows, cols, double> matrix, Type val
return b;
}
TEST(PIMathMatrixT_Test, identity)
{
TEST(PIMathMatrixT_Test, identity) {
auto matrix = PIMathMatrixT<rows, cols, double>::identity();
for(int i = 0; i < 3; i++){
if(matrix[i][i] != 1.0){
@@ -38,8 +36,7 @@ TEST(PIMathMatrixT_Test, identity)
ASSERT_TRUE(true);
}
TEST(PIMathMatrixT_Test, at)
{
TEST(PIMathMatrixT_Test, at) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
for(uint i = 0; i < rows; i++) {
if(matrix1.at(i,i) != 1.0) {
@@ -48,26 +45,22 @@ TEST(PIMathMatrixT_Test, at)
}
ASSERT_TRUE(true);
}
TEST(PIMathMatrixT_Test, filled)
{
TEST(PIMathMatrixT_Test, filled) {
auto matr = PIMathMatrixT<rows, cols, double>::filled(1.0);
ASSERT_TRUE(cmpSquareMatrixWithValue(matr, 1.0, rows));
}
TEST(PIMathMatrixT_Test, cols)
{
TEST(PIMathMatrixT_Test, cols) {
PIMathMatrixT<rows, cols, double> matr;
ASSERT_EQ(cols,matr.cols());
}
TEST(PIMathMatrixT_Test, rows)
{
TEST(PIMathMatrixT_Test, rows) {
PIMathMatrixT<rows, cols, double> matr;
ASSERT_EQ(rows,matr.rows());
}
TEST(PIMathMatrixT_Test, col)
{
TEST(PIMathMatrixT_Test, col) {
PIMathMatrixT<rows, cols, double> matr;
PIMathVectorT<rows, double> vect;
uint g = 2;
@@ -89,8 +82,8 @@ TEST(PIMathMatrixT_Test, col)
ASSERT_TRUE(true);
}
TEST(PIMathMatrixT_Test, row)
{ PIMathMatrixT<rows, cols, double> matr;
TEST(PIMathMatrixT_Test, row) {
PIMathMatrixT<rows, cols, double> matr;
PIMathVectorT<rows, double> vect;
uint g = 2;
matr.at(0,0) = 3;
@@ -111,8 +104,7 @@ TEST(PIMathMatrixT_Test, row)
ASSERT_TRUE(true);
}
TEST(PIMathMatrixT_Test, setCol)
{
TEST(PIMathMatrixT_Test, setCol) {
PIMathMatrixT<rows, cols, double> matr;
PIMathVectorT<rows, double> vect;
vect.at(0) = 1.0;
@@ -128,8 +120,7 @@ TEST(PIMathMatrixT_Test, setCol)
ASSERT_TRUE(true);
}
TEST(PIMathMatrixT_Test, setRow)
{
TEST(PIMathMatrixT_Test, setRow) {
PIMathMatrixT<rows, cols, double> matr;
PIMathVectorT<rows, double> vect;
vect.at(0) = 1.0;
@@ -145,8 +136,7 @@ TEST(PIMathMatrixT_Test, setRow)
ASSERT_TRUE(true);
}
TEST(PIMathMatrixT_Test, swapCols)
{
TEST(PIMathMatrixT_Test, swapCols) {
PIMathMatrixT<rows, cols, double> matr;
int g1 = 1, g2 = 2;
matr.at(0,0) = 3;
@@ -171,8 +161,7 @@ TEST(PIMathMatrixT_Test, swapCols)
}
}
TEST(PIMathMatrixT_Test, swapRows)
{
TEST(PIMathMatrixT_Test, swapRows) {
PIMathMatrixT<rows, cols, double> matr;
int g1 = 1, g2 = 2;
matr.at(0,0) = 3;
@@ -197,8 +186,7 @@ TEST(PIMathMatrixT_Test, swapRows)
}
}
TEST(PIMathMatrixT_Test, fill)
{
TEST(PIMathMatrixT_Test, fill) {
PIMathMatrixT<rows, cols, double> matr;
PIMathMatrixT<rows, cols, double> matrix1;
double g = 1.0;
@@ -211,53 +199,45 @@ TEST(PIMathMatrixT_Test, fill)
ASSERT_TRUE(matr == matrix1);
}
TEST(PIMathMatrixT_Test, isSquareTrue)
{
TEST(PIMathMatrixT_Test, isSquareTrue) {
PIMathMatrixT<rows, cols, double> matrix1;
ASSERT_TRUE(matrix1.isSquare());
}
TEST(PIMathMatrixT_Test, isSquareFalse)
{
TEST(PIMathMatrixT_Test, isSquareFalse) {
const uint new_Cols = 4;
PIMathMatrixT<rows, new_Cols, double> matrix2;
ASSERT_FALSE(matrix2.isSquare());
}
TEST(PIMathMatrixT_Test, isIdentityTrue)
{
TEST(PIMathMatrixT_Test, isIdentityTrue) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
ASSERT_TRUE(matrix1.isIdentity());
}
TEST(PIMathMatrixT_Test, isIdentityFalse)
{
TEST(PIMathMatrixT_Test, isIdentityFalse) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(2.5);
ASSERT_FALSE(matrix1.isIdentity());
}
TEST(PIMathMatrixT_Test, isNullTrue)
{
TEST(PIMathMatrixT_Test, isNullTrue) {
PIMathMatrixT<rows, cols, double> matrix1;
ASSERT_TRUE(matrix1.isNull());
}
TEST(PIMathMatrixT_Test, isNullFalse)
{
TEST(PIMathMatrixT_Test, isNullFalse) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::identity();
ASSERT_FALSE(matrix1.isNull());
}
TEST(PIMathMatrixT_Test, operator_Assignment)
{
TEST(PIMathMatrixT_Test, operator_Assignment) {
PIMathMatrixT<rows, cols, double> matrix1;
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(6.72);
matrix1 = matrix2;
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 6.72, rows));
}
TEST(PIMathMatrixT_Test, operator_EqualTrue)
{
TEST(PIMathMatrixT_Test, operator_EqualTrue) {
PIMathMatrixT<rows, cols, double> matrix1;
PIMathMatrixT<rows, cols, double> matrix2;
matrix1.at(0, 0) = 5.1;
@@ -271,8 +251,7 @@ TEST(PIMathMatrixT_Test, operator_EqualTrue)
ASSERT_TRUE(matrix1 == matrix2);
}
TEST(PIMathMatrixT_Test, operator_EqualFalse)
{
TEST(PIMathMatrixT_Test, operator_EqualFalse) {
PIMathMatrixT<rows, cols, double> matrix1;
PIMathMatrixT<rows, cols, double> matrix2;
matrix1.at(0, 0) = 5.1;
@@ -286,8 +265,7 @@ TEST(PIMathMatrixT_Test, operator_EqualFalse)
ASSERT_FALSE(matrix1 == matrix2);
}
TEST(PIMathMatrixT_Test, operator_Not_EqualTrue)
{
TEST(PIMathMatrixT_Test, operator_Not_EqualTrue) {
PIMathMatrixT<rows, cols, double> matrix1;
PIMathMatrixT<rows, cols, double> matrix2;
matrix1.at(0, 0) = 5.1;
@@ -301,8 +279,7 @@ TEST(PIMathMatrixT_Test, operator_Not_EqualTrue)
ASSERT_TRUE(matrix1 != matrix2);
}
TEST(PIMathMatrixT_Test, operator_Not_EqualFalse)
{
TEST(PIMathMatrixT_Test, operator_Not_EqualFalse) {
PIMathMatrixT<rows, cols, double> matrix1;
PIMathMatrixT<rows, cols, double> matrix2;
matrix1.at(0, 0) = 5.1;
@@ -316,63 +293,54 @@ TEST(PIMathMatrixT_Test, operator_Not_EqualFalse)
ASSERT_FALSE(matrix1 != matrix2);
}
TEST(PIMathMatrixT_Test, operator_Addition_Aassignment)
{
TEST(PIMathMatrixT_Test, operator_Addition_ ssignment) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72) ;
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(1.0) ;
matrix1 += matrix2;
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 7.72, rows));
}
TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment)
{
TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.0);
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(6.72);
matrix1 -= matrix2;
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, -5.72, rows));
}
TEST(PIMathMatrixT_Test, operator_Multiplication_Assignment)
{
TEST(PIMathMatrixT_Test, operator_Multiplication_Assignment) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
matrix1 *= 2.0;
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 13.44, rows));
}
TEST(PIMathMatrixT_Test, operator_Division_Assignment)
{
TEST(PIMathMatrixT_Test, operator_Division_Assignment) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
matrix1 /= 2.0;
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 3.36, rows));
}
TEST(PIMathMatrixT_Test, operator_Addition)
{
TEST(PIMathMatrixT_Test, operator_Addition) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(8.28);
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 + matrix2, 15.0, rows));
}
TEST(PIMathMatrixT_Test, operator_Subtraction)
{
TEST(PIMathMatrixT_Test, operator_Subtraction) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.0);
auto matrix2 = PIMathMatrixT<rows, cols, double>::filled(5.0);
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 - matrix2, 1.0, rows));
}
TEST(PIMathMatrixT_Test, operator_Multiplication)
{
TEST(PIMathMatrixT_Test, operator_Multiplication) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * 4.0, 26.88, rows));
}
TEST(PIMathMatrixT_Test, operator_Division)
{
TEST(PIMathMatrixT_Test, operator_Division) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(6.72);
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 / 4.0, 1.68, rows));
}
TEST(PIMathMatrixT_Test, determinantIfSquare)
{
TEST(PIMathMatrixT_Test, determinantIfSquare) {
double d;
double i = 59.0;
PIMathMatrixT<rows, cols, double> matr;
@@ -389,8 +357,7 @@ TEST(PIMathMatrixT_Test, determinantIfSquare)
ASSERT_DOUBLE_EQ(i, d);
}
TEST(PIMathMatrixT_Test, determinantIfNotSquare)
{
TEST(PIMathMatrixT_Test, determinantIfNotSquare) {
PIMathMatrixT<rows, 5u, double> matr;
matr.at(0,0) = 3;
matr.at(0,1) = 6;
@@ -404,8 +371,7 @@ TEST(PIMathMatrixT_Test, determinantIfNotSquare)
ASSERT_FALSE(matr.determinant());
}
TEST(PIMathMatrixT_Test, invert)
{
TEST(PIMathMatrixT_Test, invert) {
PIMathMatrixT<rows, cols, double> matrix1;
PIMathMatrixT<rows, cols, double> matrix2;
PIMathMatrixT<rows, cols, double> matrix3;
@@ -429,8 +395,7 @@ TEST(PIMathMatrixT_Test, invert)
ASSERT_TRUE((matrix1 == matrix3) && (d1 == 1/d2));
}
TEST(PIMathMatrixT_Test, inverted)
{
TEST(PIMathMatrixT_Test, inverted) {
PIMathMatrixT<rows, cols, double> matrix1;
PIMathMatrixT<rows, cols, double> matrix2;
PIMathMatrixT<rows, cols, double> matrix3;
@@ -453,8 +418,7 @@ TEST(PIMathMatrixT_Test, inverted)
ASSERT_TRUE((matrix1 == matrix3) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000));
}
TEST(PIMathMatrixT_Test, toUpperTriangular)
{
TEST(PIMathMatrixT_Test, toUpperTriangular) {
PIMathMatrixT<rows, cols, double> matrix;
double d1, d2 = 1;
PIMathMatrixT<rows, cols, double> matr;
@@ -476,8 +440,7 @@ TEST(PIMathMatrixT_Test, toUpperTriangular)
ASSERT_DOUBLE_EQ(d1, d2);
}
TEST(PIMathMatrixT_Test, transposed)
{
TEST(PIMathMatrixT_Test, transposed) {
PIMathMatrixT<rows, cols, double> matrix1;
PIMathMatrixT<rows, cols, double> matrix2;
PIMathMatrixT<rows, cols, double> matr;
@@ -498,22 +461,19 @@ TEST(PIMathMatrixT_Test, transposed)
ASSERT_TRUE((d1 == d2) && (matr == matrix2));
}
TEST(PIMathMatrixT_Test, scaleX_two)
{
TEST(PIMathMatrixT_Test, scaleX_two) {
double factor = 5.64;
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::scaleX(factor);
ASSERT_TRUE((1.0 == matrix.at(1u,1u)) && (factor == matrix.at(0u,0u)));
}
TEST(PIMathMatrixT_Test, scaleY_two)
{
TEST(PIMathMatrixT_Test, scaleY_two) {
double factor = 5.64;
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::scaleY(factor);
ASSERT_TRUE((factor == matrix.at(1u,1u)) && (1.0 == matrix.at(0u,0u)));
}
TEST(PIMathMatrixT_Test, rotation_2x2)
{
TEST(PIMathMatrixT_Test, rotation_2x2) {
double angle = 1.0;
PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::rotation(angle);
double c = cos(angle);
@@ -521,15 +481,13 @@ TEST(PIMathMatrixT_Test, rotation_2x2)
ASSERT_TRUE((c == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (-s == matrix.at(0u,1u)) && (s == matrix.at(1u,0u)));
}
TEST(PIMathMatrixT_Test, rotation_3x3)
{
TEST(PIMathMatrixT_Test, rotation_3x3) {
double angle = 1.0;
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::rotation(angle);
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix, 0.0, rows));
}
TEST(PIMathMatrixT_Test, rotationX)
{
TEST(PIMathMatrixT_Test, rotationX) {
double angle = 1.0;
double c = cos(angle);
double s = sin(angle);
@@ -537,8 +495,7 @@ TEST(PIMathMatrixT_Test, rotationX)
ASSERT_TRUE((1.0 == matrix.at(0u,0u)) && (c == matrix.at(1u,1u)) && (c == matrix.at(2u,2u)) && (s == matrix.at(2u,1u)) && (-s == matrix.at(1u,2u)));
}
TEST(PIMathMatrixT_Test, rotationY)
{
TEST(PIMathMatrixT_Test, rotationY) {
double angle = 1.0;
double c = cos(angle);
double s = sin(angle);
@@ -546,8 +503,7 @@ TEST(PIMathMatrixT_Test, rotationY)
ASSERT_TRUE((1.0 == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (c == matrix.at(2u,2u)) && (s == matrix.at(0u,2u)) && (-s == matrix.at(2u,0u)));
}
TEST(PIMathMatrixT_Test, rotationZ)
{
TEST(PIMathMatrixT_Test, rotationZ) {
double angle = 1.0;
double c = cos(angle);
double s = sin(angle);
@@ -555,22 +511,19 @@ TEST(PIMathMatrixT_Test, rotationZ)
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (c == matrix.at(0u,0u)) && (c == matrix.at(1u,1u)) && (s == matrix.at(1u,0u)) && (-s == matrix.at(0u,1u)));
}
TEST(PIMathMatrixT_Test, scaleX_three)
{
TEST(PIMathMatrixT_Test, scaleX_three) {
double factor = 23.65;
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleX(factor);
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (factor == matrix.at(0u,0u)) && (1.0 == matrix.at(1u,1u)));
}
TEST(PIMathMatrixT_Test, scaleY_three)
{
TEST(PIMathMatrixT_Test, scaleY_three) {
double factor = 23.65;
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleY(factor);
ASSERT_TRUE((1.0 == matrix.at(2u,2u)) && (1.0 == matrix.at(0u,0u)) && (factor == matrix.at(1u,1u)));
}
TEST(PIMathMatrixT_Test, scaleZ_three)
{
TEST(PIMathMatrixT_Test, scaleZ_three) {
double factor = 23.65;
PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleZ(factor);
ASSERT_TRUE((factor == matrix.at(2u,2u)) && (1.0 == matrix.at(0u,0u)) && (1.0 == matrix.at(1u,1u)));
@@ -583,8 +536,7 @@ TEST(PIMathMatrixT_Test, matrixMultiplication)
ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * matrix2, 11.25, 3));
}
TEST(PIMathMatrixT_Test, matrixAndVectorMultiplication)
{
TEST(PIMathMatrixT_Test, matrixAndVectorMultiplication) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
auto vector = PIMathVectorT<rows, double>::filled(2.5);
for(uint i = 0; i < 2; i++) {
@@ -595,8 +547,7 @@ TEST(PIMathMatrixT_Test, matrixAndVectorMultiplication)
ASSERT_TRUE(true);
}
TEST(PIMathMatrixT_Test, vectorAndMatrixMultiplication)
{
TEST(PIMathMatrixT_Test, vectorAndMatrixMultiplication) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
auto vector = PIMathVectorT<rows, double>::filled(2.5);
for(uint i = 0; i < 2; i++) {
@@ -606,8 +557,7 @@ TEST(PIMathMatrixT_Test, vectorAndMatrixMultiplication)
}
}
TEST(PIMathMatrixT_Test, valAndMatrixMultiplication)
{
TEST(PIMathMatrixT_Test, valAndMatrixMultiplication) {
auto matrix1 = PIMathMatrixT<rows, cols, double>::filled(1.5);
ASSERT_TRUE(cmpSquareMatrixWithValue(25.0*matrix1, 37.5, 3));
}