-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector3d_unittests.cpp
More file actions
41 lines (34 loc) · 1.37 KB
/
Copy pathvector3d_unittests.cpp
File metadata and controls
41 lines (34 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "gtest/gtest.h"
#include "vector3d.hpp"
TEST(Vector3DConstructor,GivenAVector3DInitializedWithNonZeroValues_WhenCheckingComponents_ExpectCorrectValues)
{
Vector3D testingVector{1.0, 2.0, 3.0};
EXPECT_EQ(1.0, testingVector.get_x());
EXPECT_EQ(2.0, testingVector.get_y());
EXPECT_EQ(3.0, testingVector.get_z());
}
TEST(Vector3DLengthSquared,GivenAVector3DWithAnXValue_WhenCheckingLengthSquared_ExpectCorrectValue)
{
Vector3D testingVector{2.0, 0.0, 0.0};
EXPECT_NEAR(testingVector.magnitude_squared(), 4.0, 1e-3);
}
TEST(Vector3DLengthSquared,GivenAVector3DWithAYValue_WhenCheckingLengthSquared_ExpectCorrectValue)
{
Vector3D testingVector{0.0, 3.0, 0.0};
EXPECT_NEAR(testingVector.magnitude_squared(), 9.0, 1e-3);
}
TEST(Vector3DLengthSquared,GivenAVector3DWithAZValue_WhenCheckingLengthSquared_ExpectCorrectValue)
{
Vector3D testingVector{0.0, 0.0, 4.0};
EXPECT_NEAR(testingVector.magnitude_squared(), 16.0, 1e-3);
}
TEST(Vector3DLengthSquared,GivenAVector3DInitialzedToNonZeros_WhenCheckingLengthSquared_ExpectCorrectValue)
{
Vector3D testingVector{2.0, 3.0, 4.0};
EXPECT_NEAR(testingVector.magnitude_squared(), 29, 1e-3);
}
TEST(Vector3DLength,GivenAVector3DInitialzedToNonZeros_WhenCheckingLength_ExpectCorrectValue)
{
Vector3D testingVector{1.0, 2.0, 3.0};
EXPECT_NEAR(testingVector.get_magnitude(), 3.741, 1e-3);
}