Fixes unit tests
This commit is contained in:
@@ -17,15 +17,17 @@ SCENARIO("Box", "[MATH][BOX]")
|
||||
THEN("They should stay the same")
|
||||
{
|
||||
REQUIRE(firstZero == secondZero);
|
||||
CHECK(!firstZero.IsValid());
|
||||
CHECK(!secondZero.IsValid());
|
||||
CHECK(firstZero.IsValid());
|
||||
CHECK(firstZero.IsNull());
|
||||
CHECK(secondZero.IsValid());
|
||||
CHECK(secondZero.IsNull());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("Two unit and center boxes")
|
||||
{
|
||||
Nz::Boxf firstCenterAndUnit(Nz::Rectf(Nz::Vector2f::Zero(), Nz::Vector2f::Unit()));
|
||||
Nz::Boxf firstCenterAndUnit(Nz::Vector3f::Zero(), Nz::Vector3f::Unit());
|
||||
Nz::Boxf secondCenterAndUnit(1.f, 1.f, 1.f);
|
||||
|
||||
WHEN("We ask for some informations")
|
||||
@@ -91,8 +93,8 @@ SCENARIO("Box", "[MATH][BOX]")
|
||||
|
||||
GIVEN("Two wrong box (negative width, height and depth")
|
||||
{
|
||||
Nz::Boxf firstWrongBox = Nz::Boxf::Invalid();
|
||||
Nz::Boxf secondWrongBox = Nz::Boxf::Invalid();
|
||||
Nz::Boxf firstWrongBox(-Nz::Vector3f::Unit());
|
||||
Nz::Boxf secondWrongBox(-Nz::Vector3f::Unit());
|
||||
|
||||
WHEN("We check if valid")
|
||||
{
|
||||
@@ -121,8 +123,8 @@ SCENARIO("Box", "[MATH][BOX]")
|
||||
CHECK(firstWrongBox.Contains(0.f, 0.f, 0.f));
|
||||
CHECK(secondWrongBox.Contains(0.f, 0.f, 0.f));
|
||||
|
||||
secondWrongBox = secondWrongBox.Lerp(Nz::Boxf::Zero(), secondWrongBox, 0.f); // Zeroed
|
||||
secondWrongBox.ExtendTo(Nz::Boxf(Nz::Vector3f(0.1f, 0.1f, 0.1f), Nz::Vector3f(0.9f, 0.9f, 0.9f)));
|
||||
secondWrongBox = Nz::Boxf::Lerp(Nz::Boxf::Zero(), secondWrongBox, 0.f); // Zeroed
|
||||
secondWrongBox.ExtendTo(Nz::Boxf::FromExtends(Nz::Vector3f(0.1f, 0.1f, 0.1f), Nz::Vector3f(0.9f, 0.9f, 0.9f)));
|
||||
secondWrongBox.Translate(Nz::Vector3f(0.05f, 0.05f, 0.05f)); // Box 0.15 to 0.95
|
||||
CHECK(firstWrongBox.Contains(secondWrongBox));
|
||||
|
||||
|
||||
@@ -65,23 +65,6 @@ SCENARIO("Ray", "[MATH][RAY]")
|
||||
CHECK(!ray.Intersect(Nz::Spheref(Nz::Vector3f::UnitX(), 0.9f)));
|
||||
}
|
||||
|
||||
THEN("For the OBB collision's")
|
||||
{
|
||||
float tmpClosest;
|
||||
float tmpFurthest;
|
||||
|
||||
Nz::OrientedBoxf obb(Nz::Boxf(-0.5f, 1.f, -0.5f, 1.f, 1.f, 1.f));
|
||||
obb.Update(Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 0.f).ToQuaternion()));
|
||||
|
||||
CHECK(ray.Intersect(obb, &tmpClosest, &tmpFurthest));
|
||||
REQUIRE(ray.GetPoint(tmpClosest) == Nz::Vector3f::UnitY());
|
||||
REQUIRE(ray.GetPoint(tmpFurthest) == (Nz::Vector3f::UnitY() * 2.f));
|
||||
|
||||
obb = Nz::OrientedBoxf(Nz::Boxf(-10.f, 1.f, -10.f, 1.f, 1.f, 1.f));
|
||||
obb.Update(Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 0.f, 90.f).ToQuaternion()));
|
||||
CHECK(!ray.Intersect(obb, &tmpClosest, &tmpFurthest));
|
||||
}
|
||||
|
||||
THEN("For the bounding volume collision's")
|
||||
{
|
||||
Nz::BoundingVolumef nullVolume(Nz::Extend::Null);
|
||||
|
||||
@@ -7,7 +7,7 @@ SCENARIO("Rect", "[MATH][RECT]")
|
||||
GIVEN("Two same Nz::Rectangles center and unit lengths")
|
||||
{
|
||||
Nz::Rectf firstCenterAndUnit(0.f, 0.f, 1.f, 1.f);
|
||||
Nz::Rectf secondCenterAndUnit(Nz::Recti(Nz::Vector2i::Unit(), Nz::Vector2i::Zero()));
|
||||
Nz::Rectf secondCenterAndUnit(Nz::Recti::FromExtends(Nz::Vector2i::Unit(), Nz::Vector2i::Zero()));
|
||||
|
||||
WHEN("We ask if they are the same")
|
||||
{
|
||||
@@ -32,11 +32,11 @@ SCENARIO("Rect", "[MATH][RECT]")
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("We make an empty")
|
||||
WHEN("We make it empty")
|
||||
{
|
||||
THEN("It's not valid")
|
||||
{
|
||||
CHECK(!(firstCenterAndUnit.Scale(0.f)).IsValid());
|
||||
CHECK(firstCenterAndUnit.Scale(0.f).IsNull());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ SCENARIO("Sphere", "[MATH][SPHERE]")
|
||||
|
||||
WHEN("We get sphere from box unit and center")
|
||||
{
|
||||
Nz::Boxf centerUnitBox(Nz::Vector3f::Unit() * -0.5f, Nz::Vector3f::Unit() * 0.5f);
|
||||
Nz::Boxf centerUnitBox = Nz::Boxf::FromExtends(Nz::Vector3f::Unit() * -0.5f, Nz::Vector3f::Unit() * 0.5f);
|
||||
|
||||
THEN("This is equal to sphere center and radius 0.75")
|
||||
{
|
||||
|
||||
@@ -310,7 +310,7 @@ SCENARIO("RigidBody2D", "[PHYSICS2D][RIGIDBODY2D]")
|
||||
{
|
||||
THEN("We expect this to be true")
|
||||
{
|
||||
Nz::Rectf segmentAABB(positionA, positionB);
|
||||
Nz::Rectf segmentAABB = Nz::Rectf::FromExtends(positionA, positionB);
|
||||
REQUIRE(body.GetAABB() == segmentAABB);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user