diff --git a/CMakeLists.txt b/CMakeLists.txt index 4643c66..8998504 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,10 @@ enable_testing() add_executable( VectorAlgebraTest - "test/hello_test.cc" - "test/Vector3_test.cc") + #"test/hello_test.cc" + "test/Vector3_test.cc" + "test/Quaternion_test.cc" + ) target_link_libraries( VectorAlgebraTest gtest_main diff --git a/src/Vector3.cpp b/src/Vector3.cpp index 304266c..b0a177d 100644 --- a/src/Vector3.cpp +++ b/src/Vector3.cpp @@ -60,7 +60,6 @@ Vector3 Vector3::Normalize(Vector3 v) { } return result; } - Vector3 Vector3::normalized() const { float num = this->magnitude(); Vector3 result = Vector3::zero; @@ -81,6 +80,7 @@ Vector3 Vector3::operator -() { Vector3 Vector3::operator +(const Vector3& v2) const { return Vector3(this->x + v2.x, this->y + v2.y, this->z + v2.z); } + Vector3 Vector3::Scale(const Vector3& p1, const Vector3& p2) { return Vector3(p1.x * p2.x, p1.y * p2.y, p1.z * p2.z); } diff --git a/test/Quaternion_test.cc b/test/Quaternion_test.cc new file mode 100644 index 0000000..a1e301f --- /dev/null +++ b/test/Quaternion_test.cc @@ -0,0 +1,23 @@ +#include +#include +#include + +#include "Quaternion.h" + +#define FLOAT_INFINITY std::numeric_limits::infinity() + +TEST(Quaternion, Normalze) { + bool r = false; + + Quaternion q1 = Quaternion(0, 0, 0, 1); + Quaternion q = Quaternion::identity; + + q = q1; + q.Normalize(); + r = q == q1; + EXPECT_TRUE(r) << "q.Normalzed 0 0 0 1"; + + q = Quaternion::Normalize(q1); + r = q == q1; + EXPECT_TRUE(r) << "Quaternion::Normalize 0 0 0 1"; +} \ No newline at end of file diff --git a/test/Vector3_test.cc b/test/Vector3_test.cc index 7d5ee81..3545a32 100644 --- a/test/Vector3_test.cc +++ b/test/Vector3_test.cc @@ -1,6 +1,7 @@ #include #include #include + #include "Vector3.h" #define FLOAT_INFINITY std::numeric_limits::infinity()