new tests fo PIMathVector.h and tab correction

This commit is contained in:
2020-10-06 17:07:34 +03:00
parent 49905a3de0
commit d6637047b2
4 changed files with 1654 additions and 1480 deletions

View File

@@ -2,446 +2,622 @@
#include "pimathvector.h"
const uint SIZE = 3u;
const double angle45DegInRad = 0.78539816339744830961566084581988;
bool cmpVectorWithValue(PIMathVector<double> vector, double val, int num) {
bool b = true;
for(int i = 0; i < num; i++) {
if(vector[i] - val >= double(1E-200)) {
b = false;
}
}
return b;
bool b = true;
for(int i = 0; i < num; i++) {
if(vector[i] - val >= double(1E-200)) {
b = false;
}
}
return b;
}
TEST(PIMathVector_Test, size) {
auto vector = PIMathVector<double>(SIZE);
ASSERT_TRUE(vector.size() == SIZE);
auto vector = PIMathVector<double>(SIZE);
ASSERT_TRUE(vector.size() == SIZE);
}
TEST(PIMathVector_Test, resize) {
uint newSize = 4u;
double a = 5.0;
PIMathVector<double> vector;
vector.resize(newSize, a);
ASSERT_TRUE(cmpVectorWithValue(vector, a, vector.size()));
ASSERT_TRUE(vector.size() == newSize);
uint newSize = 4u;
double a = 5.0;
PIMathVector<double> vector;
vector.resize(newSize, a);
ASSERT_TRUE(cmpVectorWithValue(vector, a, vector.size()));
ASSERT_TRUE(vector.size() == newSize);
}
TEST(PIMathVector_Test, resized) {
uint newSize = 4u;
double a = 5.0;
PIMathVector<double> vector;
auto vect = vector.resized(newSize, a);
ASSERT_TRUE(cmpVectorWithValue(vect, a, vect.size()) && vect.size() == newSize);
ASSERT_TRUE(vect.size() == newSize);
uint newSize = 4u;
double a = 5.0;
PIMathVector<double> vector;
auto vect = vector.resized(newSize, a);
ASSERT_TRUE(cmpVectorWithValue(vect, a, vect.size()));
ASSERT_TRUE(vect.size() == newSize);
}
TEST(PIMathVector_Test, fill) {
double a = 5.0;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_TRUE(cmpVectorWithValue(vector, a, SIZE));
double a = 5.0;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_TRUE(cmpVectorWithValue(vector, a, SIZE));
}
TEST(PIMathVector_Test, moveVal) {
double a = 5.0;
PIMathVector<double> vector(SIZE);
vector.fill(a);
vector.move(a);
ASSERT_TRUE(cmpVectorWithValue(vector, 2 * a, SIZE));
double a = 5.0;
PIMathVector<double> vector(SIZE);
vector.fill(a);
vector.move(a);
ASSERT_TRUE(cmpVectorWithValue(vector, 2 * a, SIZE));
}
TEST(PIMathVector_Test, moveVec) {
double a = 5.0;
double b = 7.0;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector.fill(a);
vec.fill(b);
vector.move(vec);
ASSERT_TRUE(cmpVectorWithValue(vector, a + b, SIZE));
double a = 5.0;
double b = 7.0;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector.fill(a);
vec.fill(b);
vector.move(vec);
ASSERT_TRUE(cmpVectorWithValue(vector, a + b, SIZE));
}
TEST(PIMathVector_Test, moveVecSizeNotEq) {
double a = 5.0;
double b = 7.0;
uint bias = 2u;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE + bias);
vector.fill(a);
vec.fill(b);
vector.move(vec);
ASSERT_TRUE(cmpVectorWithValue(vector, a, SIZE));
ASSERT_TRUE(vector.size() == SIZE);
}
TEST(PIMathVector_Test, swap) {
double b = 5.12;
double c = 3.32;
double d = 7.12;
PIMathVector<double> vector(SIZE);
double a[3];
vector[0] = b;
vector[1] = c;
vector[2] = d;
a[0] = vector[0];
a[1] = vector[1];
a[2] = vector[2];
vector.swap(0u, 1u);
ASSERT_DOUBLE_EQ(a[0], vector[1]);
ASSERT_DOUBLE_EQ(a[1], vector[0]);
ASSERT_DOUBLE_EQ(a[2], vector[2]);
double b = 5.12;
double c = 3.32;
double d = 7.12;
PIMathVector<double> vector(SIZE);
double a[3];
vector[0] = b;
vector[1] = c;
vector[2] = d;
a[0] = vector[0];
a[1] = vector[1];
a[2] = vector[2];
vector.swap(0u, 1u);
ASSERT_DOUBLE_EQ(a[0], vector[1]);
ASSERT_DOUBLE_EQ(a[1], vector[0]);
ASSERT_DOUBLE_EQ(a[2], vector[2]);
}
TEST(PIMathVector_Test, lengthSqr) {
double a = 3.0;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_DOUBLE_EQ(SIZE * a * a, vector.lengthSqr());
double a = 3.0;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_DOUBLE_EQ(SIZE * a * a, vector.lengthSqr());
}
TEST(PIMathVector_Test, length) {
double a = 3.32;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_DOUBLE_EQ(sqrt(SIZE * a * a), vector.length());
double a = 3.32;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_DOUBLE_EQ(sqrt(SIZE * a * a), vector.length());
}
TEST(PIMathVector_Test, manhattanLength) {
double a = 3.32;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_DOUBLE_EQ(SIZE * a, vector.manhattanLength());
double a = 3.32;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_DOUBLE_EQ(SIZE * a, vector.manhattanLength());
}
TEST(PIMathVector_Test, angleCos) {
double a = 3.32;
double angle = 0.78539816339744830961566084581988;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_DOUBLE_EQ(cos(angle), vector.angleCos(vec));
double a = 3.32;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_DOUBLE_EQ(cos(angle45DegInRad), vector.angleCos(vec));
}
TEST(PIMathVector_Test, angleCosSizeNotEq) {
double a = 3.32;
uint bias = 2u;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE + bias);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_FALSE(vector.angleCos(vec));
}
TEST(PIMathVector_Test, angleSin) {
double a = 3.32;
double angle = 0.78539816339744830961566084581988;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_DOUBLE_EQ(sin(angle), vector.angleSin(vec));
double a = 3.32;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_DOUBLE_EQ(sin(angle45DegInRad), vector.angleSin(vec));
}
TEST(PIMathVector_Test, angleSinSizeNotEq) {
double a = 3.32;
uint bias = 2u;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE + bias);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_FALSE(vector.angleSin(vec));
}
TEST(PIMathVector_Test, angleRad) {
double a = 3.32;
double angle = 0.78539816339744830961566084581988;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_DOUBLE_EQ(angle, vector.angleRad(vec));
double a = 3.32;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_DOUBLE_EQ(angle45DegInRad, vector.angleRad(vec));
}
TEST(PIMathVector_Test, angleRadSizeNotEq) {
double a = 3.32;
uint bias = 2u;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE + bias);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_FALSE(vector.angleRad(vec));
}
TEST(PIMathVector_Test, angleDeg) {
double a = 3.32;
double angle = 45.0;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_DOUBLE_EQ(angle, vector.angleDeg(vec));
double a = 3.32;
double angle45Deg = 45.0;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_DOUBLE_EQ(angle45Deg, vector.angleDeg(vec));
}
TEST(PIMathVector_Test, angleDegSizeNotEq) {
double a = 3.32;
uint bias = 2u;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE + bias);
vector[0] = a;
vector[1] = a;
vec[1] = a;
ASSERT_FALSE(vector.angleDeg(vec));
}
TEST(PIMathVector_Test, projection) {
double a = 2.0;
double b = 2.0;
double res = sqrt(32.0);
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vec[0] = a;
vec[2] = b;
vector[0] = a;
vector[1] = b;
vector[2] = a;
auto vecProj = vector.projection(vec);
ASSERT_DOUBLE_EQ(res, vecProj[0]);
ASSERT_DOUBLE_EQ(0.0, vecProj[1]);
ASSERT_DOUBLE_EQ(res, vecProj[2]);
double a = 2.0;
double b = 2.0;
double res = sqrt(32.0);
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vec[0] = a;
vec[2] = b;
vector[0] = a;
vector[1] = b;
vector[2] = a;
auto vecProj = vector.projection(vec);
ASSERT_DOUBLE_EQ(res, vecProj[0]);
ASSERT_DOUBLE_EQ(0.0, vecProj[1]);
ASSERT_DOUBLE_EQ(res, vecProj[2]);
}
TEST(PIMathVector_Test, projectionSizeNotEq) {
double a = 2.0;
double b = 2.0;
uint bias = 2u;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE + bias);
vec[0] = a;
vec[2] = b;
vector[0] = a;
vector[1] = b;
vector[2] = a;
auto vecProj = vector.projection(vec);
ASSERT_DOUBLE_EQ(a, vecProj[0]);
ASSERT_DOUBLE_EQ(b, vecProj[1]);
ASSERT_DOUBLE_EQ(a, vecProj[2]);
}
TEST(PIMathVector_Test, normalize) {
double a = 5.0;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_TRUE(cmpVectorWithValue(vector.normalize(), a / sqrt(SIZE * a * a), SIZE));
double a = 5.0;
PIMathVector<double> vector(SIZE);
vector.fill(a);
ASSERT_TRUE(cmpVectorWithValue(vector.normalize(), a / sqrt(SIZE * a * a), SIZE));
}
TEST(PIMathVector_Test, normalized) {
double a = 5.0;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vectorNew(SIZE);
vector.fill(a);
vectorNew = vector.normalized();
ASSERT_TRUE(cmpVectorWithValue(vectorNew, a / sqrt(SIZE * a * a), SIZE));
double a = 5.0;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vectorNew(SIZE);
vector.fill(a);
vectorNew = vector.normalized();
ASSERT_TRUE(cmpVectorWithValue(vectorNew, a / sqrt(SIZE * a * a), SIZE));
}
TEST(PIMathVector_Test, isNullTrue) {
PIMathVector<double> vector(SIZE);
ASSERT_TRUE(vector.isNull());
PIMathVector<double> vector(SIZE);
ASSERT_TRUE(vector.isNull());
}
TEST(PIMathVector_Test, isNullFalse) {
PIMathVector<double> vector(SIZE);
vector[0] = 6.273;
ASSERT_FALSE(vector.isNull());
PIMathVector<double> vector(SIZE);
vector[0] = 6.273;
ASSERT_FALSE(vector.isNull());
}
TEST(PIMathVector_Test, isValidTrue) {
PIMathVector<double> vector(SIZE);
ASSERT_TRUE(vector.isValid());
PIMathVector<double> vector(SIZE);
ASSERT_TRUE(vector.isValid());
}
TEST(PIMathVector_Test, isValidFalse) {
PIMathVector<double> vector;
ASSERT_FALSE(vector.isValid());
PIMathVector<double> vector;
ASSERT_FALSE(vector.isValid());
}
TEST(PIMathVector_Test, isOrthoTrue) {
uint sizeNew = 2u;
double a = 2.0;
double b = 1.0;
PIMathVector<double> vector(sizeNew);
PIMathVector<double> vect(sizeNew);
vector[0] = a;
vect[1] = b;
ASSERT_TRUE(vector.isOrtho(vect));
uint sizeNew = 2u;
double a = 2.0;
double b = 1.0;
PIMathVector<double> vector(sizeNew);
PIMathVector<double> vect(sizeNew);
vector[0] = a;
vect[1] = b;
ASSERT_TRUE(vector.isOrtho(vect));
}
TEST(PIMathVector_Test, isOrthoFalse) {
uint sizeNew = 2u;
double a = 2.0;
double b = 1.0;
double c = 5.0;
PIMathVector<double> vector(sizeNew);
PIMathVector<double> vect(sizeNew);
vector[0] = a;
vect[0] = c;
vect[1] = b;
ASSERT_FALSE(vector.isOrtho(vect));
uint sizeNew = 2u;
double a = 2.0;
double b = 1.0;
double c = 5.0;
PIMathVector<double> vector(sizeNew);
PIMathVector<double> vect(sizeNew);
vector[0] = a;
vect[0] = c;
vect[1] = b;
ASSERT_FALSE(vector.isOrtho(vect));
}
TEST(PIMathVector_Test, at) {
double a = 5.5;
PIMathVector<double> vector(SIZE);
vector.fill(a);
for(uint i = 0; i < SIZE; i++){
if(vector.at(i) - a >= double(1E-200)){
ASSERT_TRUE(false);
}
}
ASSERT_TRUE(true);
double a = 5.5;
PIMathVector<double> vector(SIZE);
vector.fill(a);
for(uint i = 0; i < SIZE; i++){
if(vector.at(i) - a >= double(1E-200)){
ASSERT_TRUE(false);
}
}
ASSERT_TRUE(true);
}
TEST(PIMathVector_Test, operator_AssignmentValue) {
double a = 5.5;
PIMathVector<double> vector(SIZE);
vector = a;
ASSERT_TRUE(cmpVectorWithValue(vector, a, SIZE));
double a = 5.5;
PIMathVector<double> vector(SIZE);
vector = a;
ASSERT_TRUE(cmpVectorWithValue(vector, a, SIZE));
}
TEST(PIMathVector_Test, operator_AssignmentVector) {
double a = 5.5;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vec = a;
vector = vec;
ASSERT_TRUE(cmpVectorWithValue(vector, a, SIZE));
double a = 5.5;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE);
vec = a;
vector = vec;
ASSERT_TRUE(cmpVectorWithValue(vector, a, SIZE));
}
TEST(PIMathVector_Test, operator_AssignmentVectorSizeNotEq) {
double a = 5.5;
double b = 1.43;
uint bias = 2u;
PIMathVector<double> vector(SIZE);
PIMathVector<double> vec(SIZE + bias);
vector = b;
vec = a;
vector = vec;
ASSERT_TRUE(cmpVectorWithValue(vector, b, SIZE));
}
TEST(PIMathVector_Test, operator_EqualTrue) {
double a = 5.12;
double b = 7.34;
uint newSize = 2u;
PIMathVector<double> vector(newSize);
PIMathVector<double> vec(newSize);
vector[0] = a;
vector[1] = b;
vec[0] = a;
vec[1] = b;
ASSERT_TRUE(vec == vector);
double a = 5.12;
double b = 7.34;
uint newSize = 2u;
PIMathVector<double> vector(newSize);
PIMathVector<double> vec(newSize);
vector[0] = a;
vector[1] = b;
vec[0] = a;
vec[1] = b;
ASSERT_TRUE(vec == vector);
}
TEST(PIMathVector_Test, operator_EqualFalse) {
double a = 5.12;
double b = 7.34;
double c = 7.332;
uint newSize = 2u;
PIMathVector<double> vector(newSize);
PIMathVector<double> vec(newSize);
vector[0] = a;
vector[1] = b;
vec[0] = a;
vec[1] = c;
ASSERT_FALSE(vec == vector);
double a = 5.12;
double b = 7.34;
double c = 7.332;
uint newSize = 2u;
PIMathVector<double> vector(newSize);
PIMathVector<double> vec(newSize);
vector[0] = a;
vector[1] = b;
vec[0] = a;
vec[1] = c;
ASSERT_FALSE(vec == vector);
}
TEST(PIMathVector_Test, operator_Not_EqualTrue) {
double a = 5.12;
double b = 7.34;
double c = 7.332;
uint newSize = 2u;
PIMathVector<double> vector(newSize);
PIMathVector<double> vec(newSize);
vector[0] = a;
vector[1] = b;
vec[0] = a;
vec[1] = c;
ASSERT_TRUE(vec != vector);
double a = 5.12;
double b = 7.34;
double c = 7.332;
uint newSize = 2u;
PIMathVector<double> vector(newSize);
PIMathVector<double> vec(newSize);
vector[0] = a;
vector[1] = b;
vec[0] = a;
vec[1] = c;
ASSERT_TRUE(vec != vector);
}
TEST(PIMathVector_Test, operator_Not_EqualFalse) {
double a = 5.12;
double b = 7.34;
uint newSize = 2u;
PIMathVector<double> vector(newSize);
PIMathVector<double> vec(newSize);
vector[0] = a;
vector[1] = b;
vec[0] = a;
vec[1] = b;
ASSERT_FALSE(vec != vector);
double a = 5.12;
double b = 7.34;
uint newSize = 2u;
PIMathVector<double> vector(newSize);
PIMathVector<double> vec(newSize);
vector[0] = a;
vector[1] = b;
vec[0] = a;
vec[1] = b;
ASSERT_FALSE(vec != vector);
}
TEST(PIMathVector_Test, operator_Addition_Aassignment) {
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
vector1 += vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a + b, SIZE));
TEST(PIMathVector_Test, operator_Addition_Assignment) {
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
vector1 += vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a + b, SIZE));
}
TEST(PIMathVector_Test, operator_Addition_Assignment_sizeNotEq) {
double a = 6.0;
double b = 1.72;
uint bias = 2u;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE + bias);
vector1.fill(a);
vector2.fill(b);
vector1 += vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a, SIZE));
}
TEST(PIMathVector_Test, operator_Subtraction_Assignment) {
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
vector1 -= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a - b, SIZE));
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
vector1 -= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a - b, SIZE));
}
TEST(PIMathVector_Test, operator_Subtraction_Assignment_sizeNotEq) {
double a = 6.0;
double b = 1.72;
uint bias = 2u;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE + bias);
vector1.fill(a);
vector2.fill(b);
vector1 -= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a, SIZE));
}
TEST(PIMathVector_Test, operator_Multiplication_AssignmentValue) {
double a = 6.0;
double b = 4.0;
PIMathVector<double> vector1(SIZE);
vector1.fill(a);
vector1 *= b;
ASSERT_TRUE(cmpVectorWithValue(vector1, a * b, SIZE));
double a = 6.0;
double b = 4.0;
PIMathVector<double> vector1(SIZE);
vector1.fill(a);
vector1 *= b;
ASSERT_TRUE(cmpVectorWithValue(vector1, a * b, SIZE));
}
TEST(PIMathVector_Test, operator_Multiplication_AssignmentVector) {
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
vector1 *= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a * b, SIZE));
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
vector1 *= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a * b, SIZE));
}
TEST(PIMathVector_Test, operator_Multiplication_AssignmentVector_sizeNotEq) {
double a = 6.0;
double b = 1.72;
uint bias = 2u;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE + bias);
vector1.fill(a);
vector2.fill(b);
vector1 *= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a, SIZE));
}
TEST(PIMathVector_Test, operator_Division_AssignmentValue) {
double a = 6.0;
double b = 4.0;
PIMathVector<double> vector1(SIZE);
vector1.fill(a);
vector1 /= b;
ASSERT_TRUE(cmpVectorWithValue(vector1, a / b, SIZE));
double a = 6.0;
double b = 4.0;
PIMathVector<double> vector1(SIZE);
vector1.fill(a);
vector1 /= b;
ASSERT_TRUE(cmpVectorWithValue(vector1, a / b, SIZE));
}
TEST(PIMathVector_Test, operator_Division_AssignmentVector) {
double a = 6.0;
double b = 1.5;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
vector1 /= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a / b, SIZE));
double a = 6.0;
double b = 1.5;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
vector1 /= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a / b, SIZE));
}
TEST(PIMathVector_Test, operator_Division_AssignmentVector_sizeNotEq) {
double a = 6.0;
double b = 1.72;
uint bias = 2u;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE + bias);
vector1.fill(a);
vector2.fill(b);
vector1 /= vector2;
ASSERT_TRUE(cmpVectorWithValue(vector1, a, SIZE));
}
TEST(PIMathVector_Test, operator_Addition) {
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 + vector2, a + b, SIZE));
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 + vector2, a + b, SIZE));
}
TEST(PIMathVector_Test, operator_AdditionSizeNotEq) {
double a = 6.0;
double b = 1.72;
uint bias = 2u;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE + bias);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 + vector2, a, SIZE));
}
TEST(PIMathVector_Test, operator_Subtraction) {
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 - vector2, a - b, SIZE));
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 - vector2, a - b, SIZE));
}
TEST(PIMathVector_Test, operator_SubtractionSizeNotEq) {
double a = 6.0;
double b = 1.72;
uint bias = 2u;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE + bias);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 - vector2, a, SIZE));
}
TEST(PIMathVector_Test, operator_MultiplicationValue) {
double a = 6.0;
double b = 4.0;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
ASSERT_TRUE(cmpVectorWithValue(vector1 * b, a * b, SIZE));
double a = 6.0;
double b = 4.0;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
ASSERT_TRUE(cmpVectorWithValue(vector1 * b, a * b, SIZE));
}
TEST(PIMathVector_Test, operator_MultiplicationVector1) {
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue((vector1 * vector2), 0.0, SIZE));
double a = 6.0;
double b = 1.72;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue((vector1 * vector2), 0.0, SIZE));
}
TEST(PIMathVector_Test, operator_MultiplicationVector2) {
double a = 1.0;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1[0] = a;
vector2[1] = a;
auto crossVec = vector1 * vector2;
ASSERT_DOUBLE_EQ(crossVec[0], 0.0);
ASSERT_DOUBLE_EQ(crossVec[1], 0.0);
ASSERT_DOUBLE_EQ(crossVec[2], a);
double a = 1.0;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1[0] = a;
vector2[1] = a;
auto crossVec = vector1 * vector2;
ASSERT_DOUBLE_EQ(crossVec[0], 0.0);
ASSERT_DOUBLE_EQ(crossVec[1], 0.0);
ASSERT_DOUBLE_EQ(crossVec[2], a);
}
TEST(PIMathVector_Test, operator_DivisionValue) {
double a = 6.0;
double b = 4.0;
PIMathVector<double> vector1(SIZE);
vector1.fill(a);
ASSERT_TRUE(cmpVectorWithValue(vector1 / b, a / b, SIZE));
double a = 6.0;
double b = 4.0;
PIMathVector<double> vector1(SIZE);
vector1.fill(a);
ASSERT_TRUE(cmpVectorWithValue(vector1 / b, a / b, SIZE));
}
TEST(PIMathVector_Test, operator_MultiplVect) {
double a = 6.0;
double b = 5.0;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 & vector2, a * b, SIZE));
double a = 6.0;
double b = 5.0;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 & vector2, a * b, SIZE));
}
TEST(PIMathVector_Test, operator_MultiplVectSizeNotEq) {
double a = 6.0;
double b = 5.0;
uint bias = 2u;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE + bias);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(cmpVectorWithValue(vector1 & vector2, a , SIZE));
}
TEST(PIMathVector_Test, operator_DotProduct) {
double a = 6.0;
double b = 5.0;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(SIZE * a * b == (vector1 ^ vector2));
double a = 6.0;
double b = 5.0;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE);
vector1.fill(a);
vector2.fill(b);
ASSERT_TRUE(SIZE * a * b == (vector1 ^ vector2));
}
TEST(PIMathVector_Test, operator_DotProductSizeNotEq) {
double a = 6.0;
double b = 5.0;
uint bias = 2u;
PIMathVector<double> vector1(SIZE);
PIMathVector<double> vector2(SIZE + bias);
vector1.fill(a);
vector2.fill(b);
ASSERT_FALSE(vector1 ^ vector2);
}