Included first Quaternion tests
This commit is contained in:
parent
adb9b6e235
commit
3e85537bf6
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
23
test/Quaternion_test.cc
Normal file
23
test/Quaternion_test.cc
Normal file
@ -0,0 +1,23 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <math.h>
|
||||
#include <limits>
|
||||
|
||||
#include "Quaternion.h"
|
||||
|
||||
#define FLOAT_INFINITY std::numeric_limits<float>::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";
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <math.h>
|
||||
#include <limits>
|
||||
|
||||
#include "Vector3.h"
|
||||
|
||||
#define FLOAT_INFINITY std::numeric_limits<float>::infinity()
|
||||
|
Loading…
x
Reference in New Issue
Block a user