Added Vector3.Normalize and .Magnitude tests
This commit is contained in:
parent
daa51607c4
commit
a16a695054
@ -2,7 +2,6 @@
|
|||||||
// License, v. 2.0.If a copy of the MPL was not distributed with this
|
// License, v. 2.0.If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//#include "pch.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include "Quaternion.h"
|
#include "Quaternion.h"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// License, v. 2.0.If a copy of the MPL was not distributed with this
|
// License, v. 2.0.If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//#include "pch.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "Vector3.h"
|
#include "Vector3.h"
|
||||||
|
|
||||||
|
@ -2,18 +2,37 @@
|
|||||||
#include "Vector3.h"
|
#include "Vector3.h"
|
||||||
|
|
||||||
// Demonstrate some basic assertions
|
// Demonstrate some basic assertions
|
||||||
TEST(HelloTest, BasicAssertions) {
|
TEST(DummyTest, BasicAssertions) {
|
||||||
// Expect two strings not to be equal.
|
// Expect two strings not to be equal.
|
||||||
EXPECT_STRNE("hello", "world");
|
EXPECT_STRNE("hello", "world");
|
||||||
// Expect equality.
|
// Expect equality.
|
||||||
EXPECT_EQ(7 * 6, 42);
|
EXPECT_EQ(7 * 6, 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VectorNormalize, BasicAssertions) {
|
TEST(Vector, Normalize) {
|
||||||
|
bool r;
|
||||||
|
|
||||||
Vector3 v = Vector3(0, 2, 0);
|
Vector3 v = Vector3(0, 2, 0);
|
||||||
Vector3 normalizedV = v.normalized();
|
Vector3 normalized_v = Vector3::zero;
|
||||||
bool r = normalizedV == Vector3(0, 1, 0);
|
|
||||||
ASSERT_EQ(r, true);
|
normalized_v = v.normalized();
|
||||||
|
r = normalized_v == Vector3(0, 1, 0);
|
||||||
|
EXPECT_EQ(r, true);
|
||||||
|
|
||||||
|
normalized_v = Vector3::Normalize(v);
|
||||||
|
r = normalized_v == Vector3(0, 1, 0);
|
||||||
|
EXPECT_EQ(r, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Vector, Magnitude) {
|
||||||
|
Vector3 v = Vector3(1, 2, 3);
|
||||||
|
float m = 0;
|
||||||
|
|
||||||
|
m = v.magnitude();
|
||||||
|
EXPECT_FLOAT_EQ(m, 3.74165738677F);
|
||||||
|
|
||||||
|
m = Vector3::Magnitude(v);
|
||||||
|
EXPECT_FLOAT_EQ(m, 3.74165738677F);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user