Vec3DUnitTest.cpp File Reference
#include <Math/Vector.h>
#include <Math/Helpers.h>
#include "Logger.h"

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
31 {
32  logger(INFO,"Checks several Vec3D unit operations");
33  Vec3D a = {1,2,3};
34  Vec3D b = {4,5,6};
35  Vec3D c;
36 
37  c = b - a; //same as c = b.operator-(a);
38  helpers::check(c,{3,3,3},0,"Vector subtraction");
39 
40  c = - a; //same as c = operator-(a);
41  helpers::check(c,{-1,-2,-3},0,"Negation of a vector");
42 
43  c -= a; //same as c.operator-=(a);
44  helpers::check(c,{-2,-4,-6},0,"Vector self-subtraction");
45 
46  c = b + a; //same as c = b.operator-(a);
47  helpers::check(c,{5,7,9},0,"Vector addition");
48 
49  c = a; //same as c = operator+(a); //missing operator
50  //helpers::check(c,{1,2,3},0,"Plus-operation of a vector");
51 
52  c += a; //same as c.operator-=(a);
53  helpers::check(c,{2,4,6},0,"Vector self-addition");
54 
55  helpers::check(Vec3D::dot(a,b),32,0,"Dot product");
56 
57  helpers::check(Vec3D::cross(a,b),{-3,6,-3},0,"Cross product");
58 
59  return 0;
60 }
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
Definition: Vector.h:51
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
void check(double real, double ideal, double error, std::string errorMessage)
Definition: TestHelpers.cc:37

References helpers::check(), Vec3D::cross(), Vec3D::dot(), INFO, and logger.