UnitTests: Add build script and move current tests to "tests/Engine" directory (from "tests/Nazara")
Former-commit-id: 5639305bbdbb69ad6f6f282df6c6de930220b57f
This commit is contained in:
43
tests/Engine/Math/Vector4.cpp
Normal file
43
tests/Engine/Math/Vector4.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
#include <Catch/catch.hpp>
|
||||
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
SCENARIO("Vector4", "[MATH][VECTOR4]")
|
||||
{
|
||||
GIVEN("Two same unit vector")
|
||||
{
|
||||
NzVector4f firstUnit(1.f, 1.f, 1.f);
|
||||
NzVector4f secondUnit(NzVector4i(1, 1, 1, 1));
|
||||
|
||||
WHEN("We compare them")
|
||||
{
|
||||
THEN("They are the same")
|
||||
{
|
||||
REQUIRE(firstUnit == secondUnit);
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("We test the dot product")
|
||||
{
|
||||
NzVector4f tmp(-1.f, 0.f, 1.f, 0.f);
|
||||
|
||||
THEN("These results are expected")
|
||||
{
|
||||
REQUIRE(firstUnit.AbsDotProduct(tmp) == Approx(2.f));
|
||||
REQUIRE(firstUnit.DotProduct(tmp) == Approx(0.f));
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("We normalize")
|
||||
{
|
||||
NzVector4f tmp(1.f, 1.f, 1.f, 3.f);
|
||||
|
||||
THEN("These results are expected")
|
||||
{
|
||||
REQUIRE(firstUnit.Normalize() == NzVector4f(1.f, NzVector3f::Unit()));
|
||||
REQUIRE(tmp.Normalize() == NzVector4f(NzVector3f::Unit() * (1.f / 3.f), 1.f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user