mirror of
https://github.com/thunderbrewhq/typhoon.git
synced 2025-12-12 02:22:30 +00:00
chore(vector): add additional tests for C3Vector
This commit is contained in:
parent
9bebffa8a1
commit
6c1bd11811
1 changed files with 66 additions and 0 deletions
66
test/Vector.cpp
Normal file
66
test/Vector.cpp
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#include "tempest/Vector.hpp"
|
||||
#include "test/Test.hpp"
|
||||
|
||||
TEST_CASE("C3Vector", "[vector]") {
|
||||
SECTION("constructs with default constructor") {
|
||||
C3Vector vector;
|
||||
REQUIRE(vector.x == 0.0f);
|
||||
REQUIRE(vector.y == 0.0f);
|
||||
REQUIRE(vector.z == 0.0f);
|
||||
}
|
||||
|
||||
SECTION("constructs with xyz constructor") {
|
||||
auto vector = C3Vector(1.0f, 2.0f, 3.0f);
|
||||
REQUIRE(vector.x == 1.0f);
|
||||
REQUIRE(vector.y == 2.0f);
|
||||
REQUIRE(vector.z == 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("C3Vector::operator*=", "[vector]") {
|
||||
SECTION("multiplies by 2.0f") {
|
||||
auto vector = C3Vector(1.0f, 2.0f, 3.0f);
|
||||
vector *= 2.0f;
|
||||
REQUIRE(vector.x == 2.0f);
|
||||
REQUIRE(vector.y == 4.0f);
|
||||
REQUIRE(vector.z == 6.0f);
|
||||
}
|
||||
|
||||
SECTION("multiplies by -2.0f") {
|
||||
auto vector = C3Vector(1.0f, 2.0f, 3.0f);
|
||||
vector *= -2.0f;
|
||||
REQUIRE(vector.x == -2.0f);
|
||||
REQUIRE(vector.y == -4.0f);
|
||||
REQUIRE(vector.z == -6.0f);
|
||||
}
|
||||
|
||||
SECTION("multiplies by 0.0f") {
|
||||
auto vector = C3Vector(1.0f, 2.0f, 3.0f);
|
||||
vector *= 0.0f;
|
||||
REQUIRE(vector.x == 0.0f);
|
||||
REQUIRE(vector.y == 0.0f);
|
||||
REQUIRE(vector.z == 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("C3Vector::SquaredMag", "[vector]") {
|
||||
SECTION("calculates squared mag") {
|
||||
auto vector = C3Vector(1.0f, 2.0f, 3.0f);
|
||||
REQUIRE(vector.SquaredMag() == 14.0f);
|
||||
}
|
||||
|
||||
SECTION("calculates squared mag of C3Vector(0.0f, 0.0f, 0.0f)") {
|
||||
auto vector = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
REQUIRE(vector.SquaredMag() == 0.0f);
|
||||
}
|
||||
|
||||
SECTION("calculates squared mag of C3Vector(1.0f, 1.0f, 1.0f)") {
|
||||
auto vector = C3Vector(1.0f, 1.0f, 1.0f);
|
||||
REQUIRE(vector.SquaredMag() == 3.0f);
|
||||
}
|
||||
|
||||
SECTION("calculates squared mag of C3Vector(-1.0f, -1.0f, -1.0f)") {
|
||||
auto vector = C3Vector(-1.0f, -1.0f, -1.0f);
|
||||
REQUIRE(vector.SquaredMag() == 3.0f);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue