#include "../Test.h"
template<class T>
class Mat2TestCase : public Test
{
bool TestInitialization() {
assert(foo[0][0] == (T)0);
assert(foo[0][1] == (T)0);
assert(foo[1][0] == (T)0);
assert(foo[1][1] == (T)0);
return true;
}
bool TestUtils() {
assert(foo[0][0] == (T)1);
assert(foo[0][1] == (T)0);
assert(foo[1][0] == (T)0);
assert(foo[1][1] == (T)1);
foo =
mat2<T>((T)1, (T)2, (T)2, (T)1);
assert(foo[0][0] == (T)1);
assert(foo[0][1] == (T)2);
assert(foo[1][0] == (T)2);
assert(foo[1][1] == (T)1);
assert(fooCopy[0][0] == foo[0][0]);
assert(fooCopy[0][1] == foo[0][1]);
assert(fooCopy[1][0] == foo[1][0]);
assert(fooCopy[1][1] == foo[1][1]);
assert(fooCopy[0][0] == foo[0][0]);
assert(fooCopy[0][1] == foo[0][1]);
assert(fooCopy[1][0] == foo[1][0]);
assert(fooCopy[1][1] == foo[1][1]);
fooCopy =
mat2<T>((T)0, (T)-1, (T)1, (T)0);
assert(fooCopy[0][0] == (T)0);
assert(fooCopy[0][1] == (T)1);
assert(fooCopy[1][0] == (T)-1);
assert(fooCopy[1][1] == (T)0);
return true;
}
bool TestMath() {
float delta = 2.0f;
fooBar = foo + bar;
assert(fooBar[0][0] == (T)6.0f);
assert(fooBar[0][1] == (T)8.0f);
assert(fooBar[1][0] == (T)10.0f);
assert(fooBar[1][1] == (T)12.0f);
fooBar = foo;
fooBar += bar;
assert(fooBar[0][0] == (T)6.0f);
assert(fooBar[0][1] == (T)8.0f);
assert(fooBar[1][0] == (T)10.0f);
assert(fooBar[1][1] == (T)12.0f);
fooBar = foo - bar;
assert(fooBar[0][0] == (T)-4.0f);
assert(fooBar[0][1] == (T)-4.0f);
assert(fooBar[1][0] == (T)-4.0f);
assert(fooBar[1][1] == (T)-4.0f);
fooBar = foo;
fooBar -= bar;
assert(fooBar[0][0] == (T)-4.0f);
assert(fooBar[0][1] == (T)-4.0f);
assert(fooBar[1][0] == (T)-4.0f);
assert(fooBar[1][1] == (T)-4.0f);
fooBar = foo / delta;
assert(fooBar[0][0] == (T)0.5f);
assert(fooBar[0][1] == (T)1.0f);
assert(fooBar[1][0] == (T)1.5f);
assert(fooBar[1][1] == (T)2.0f);
fooBar = foo;
fooBar /= delta;
assert(fooBar[0][0] == (T)0.5f);
assert(fooBar[0][1] == (T)1.0f);
assert(fooBar[1][0] == (T)1.5f);
assert(fooBar[1][1] == (T)2.0f);
fooBar = foo * bar;
assert(fooBar[0][0] == (T)19.0f);
assert(fooBar[0][1] == (T)22.0f);
assert(fooBar[1][0] == (T)43.0f);
assert(fooBar[1][1] == (T)50.0f);
fooBar = foo;
fooBar *= bar;
assert(fooBar[0][0] == (T)19.0f);
assert(fooBar[0][1] == (T)22.0f);
assert(fooBar[1][0] == (T)43.0f);
assert(fooBar[1][1] == (T)50.0f);
assert(fooVec.
x == (T)5.0f);
assert(fooVec.
y == (T)11.0f);
fooBar = foo * delta;
assert(fooBar[0][0] == (T)2.0f);
assert(fooBar[0][1] == (T)4.0f);
assert(fooBar[1][0] == (T)6.0f);
assert(fooBar[1][1] == (T)8.0f);
fooBar = foo;
fooBar *= delta;
assert(fooBar[0][0] == (T)2.0f);
assert(fooBar[0][1] == (T)4.0f);
assert(fooBar[1][0] == (T)6.0f);
assert(fooBar[1][1] == (T)8.0f);
return true;
}
bool TestInverse() {
if(extended) {
}
return true;
}
public:
void run() override {
TestInitialization();
TestUtils();
TestMath();
TestInverse();
}
};
int main() {
Mat2TestCase<int>().run();
auto testCase = Mat2TestCase<float>();
testCase.extended = true;
testCase.run();
auto testCase2 = Mat2TestCase<double>();
testCase2.extended = true;
testCase2.run();
return 0;
}
static mat2< T > Unit()
Definition: mat2.h:57
mat2< T > Inverse() const
Definition: mat2.h:78
mat2< T > Transpose()
Definition: mat2.h:65
bool IsSymmetric()
Definition: mat2.h:71