Tests: Update Catch2 to 3.x
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <Nazara/Physics2D/Collider2D.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Collider2D", "[PHYSICS2D][COLLIDER2D]")
|
||||
{
|
||||
@@ -40,7 +41,7 @@ SCENARIO("Collider2D", "[PHYSICS2D][COLLIDER2D]")
|
||||
|
||||
THEN("We expect those to be true")
|
||||
{
|
||||
CHECK(circle.GetRadius() == Approx(radius));
|
||||
CHECK(circle.GetRadius() == Catch::Approx(radius));
|
||||
CHECK(circle.GetType() == Nz::ColliderType2D::Circle);
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@ SCENARIO("Collider2D", "[PHYSICS2D][COLLIDER2D]")
|
||||
THEN("We expect those to be true")
|
||||
{
|
||||
CHECK(segment.GetFirstPoint() == firstPoint);
|
||||
CHECK(segment.GetLength() == Approx(firstPoint.Distance(secondPoint)));
|
||||
CHECK(segment.GetLength() == Catch::Approx(firstPoint.Distance(secondPoint)));
|
||||
CHECK(segment.GetSecondPoint() == secondPoint);
|
||||
CHECK(segment.GetType() == Nz::ColliderType2D::Segment);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
Nz::RigidBody2D CreateBody(Nz::PhysWorld2D& world, const Nz::Vector2f& position, bool isMoving = true, const Nz::Vector2f& lengths = Nz::Vector2f::Unit());
|
||||
|
||||
@@ -35,7 +36,7 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]")
|
||||
CHECK(result.nearestBody == &bodies[0]);
|
||||
CHECK(result.closestPoint == Nz::Vector2f::Zero());
|
||||
CHECK(result.fraction == -Nz::Vector2f::UnitY());
|
||||
CHECK(result.distance == Approx(1.f));
|
||||
CHECK(result.distance == Catch::Approx(1.f));
|
||||
}
|
||||
|
||||
REQUIRE(world.NearestBodyQuery(Nz::Vector2f::UnitY() * 2.f, 2.f, collisionGroup, categoryMask, collisionMask, &result));
|
||||
@@ -45,7 +46,7 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]")
|
||||
CHECK(result.nearestBody == &bodies[0]);
|
||||
CHECK(result.closestPoint == Nz::Vector2f::UnitY());
|
||||
CHECK(result.fraction == Nz::Vector2f::UnitY());
|
||||
CHECK(result.distance == Approx(1.f));
|
||||
CHECK(result.distance == Catch::Approx(1.f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]")
|
||||
THEN("It should be the one on the origin")
|
||||
{
|
||||
CHECK(result.nearestBody == &bodies[0]);
|
||||
CHECK(result.fraction == Approx(1.f / 42.f));
|
||||
CHECK(result.fraction == Catch::Approx(1.f / 42.f));
|
||||
CHECK(result.hitPos == Nz::Vector2f::Zero());
|
||||
CHECK(result.hitNormal == -Nz::Vector2f::UnitY());
|
||||
}
|
||||
@@ -80,7 +81,7 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]")
|
||||
{
|
||||
const Nz::PhysWorld2D::RaycastHit& result = results[i];
|
||||
CHECK(result.nearestBody == &bodies[i]);
|
||||
CHECK(result.fraction == Approx(i / 4.f).margin(0.1f));
|
||||
CHECK(result.fraction == Catch::Approx(i / 4.f).margin(0.1f));
|
||||
CHECK(result.hitPos == Nz::Vector2f(0.f, i * 10.f));
|
||||
CHECK(result.hitNormal == -Nz::Vector2f::UnitY());
|
||||
}
|
||||
@@ -172,13 +173,13 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]")
|
||||
world.Step(0.1f);
|
||||
CHECK(statusTriggerCollision == 11);
|
||||
|
||||
CHECK(character.GetPosition().x == Approx(3.1f).margin(0.01f));
|
||||
CHECK(character.GetPosition().x == Catch::Approx(3.1f).margin(0.01f));
|
||||
|
||||
for (int i = 0; i != 9; ++i)
|
||||
world.Step(0.1f);
|
||||
CHECK(character.GetPosition().x == Approx(4.f).margin(0.01f));
|
||||
CHECK(character.GetPosition().x == Catch::Approx(4.f).margin(0.01f));
|
||||
world.Step(0.1f);
|
||||
CHECK(character.GetPosition().x == Approx(4.f).margin(0.01f));
|
||||
CHECK(character.GetPosition().x == Catch::Approx(4.f).margin(0.01f));
|
||||
CHECK(statusWallCollision == 1); // It should be close to the wall
|
||||
|
||||
character.SetVelocity(Nz::Vector2f(-2.f, 0.f));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
||||
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
@@ -133,9 +134,9 @@ SCENARIO("RigidBody2D", "[PHYSICS2D][RIGIDBODY2D]")
|
||||
CHECK(body.GetAngularVelocity() == 0.f);
|
||||
CHECK(body.GetMassCenter(Nz::CoordSys::Global) == position);
|
||||
CHECK(body.GetGeom() == box);
|
||||
CHECK(body.GetMass() == Approx(mass));
|
||||
CHECK(body.GetMass() == Catch::Approx(mass));
|
||||
CHECK(body.GetPosition() == position);
|
||||
CHECK(body.GetRotation().value == Approx(0.f));
|
||||
CHECK(body.GetRotation().value == Catch::Approx(0.f));
|
||||
CHECK(body.GetUserdata() == &userData);
|
||||
CHECK(body.GetVelocity() == Nz::Vector2f::Zero());
|
||||
|
||||
@@ -336,17 +337,17 @@ void EQUALITY(const Nz::RigidBody2D& left, const Nz::RigidBody2D& right)
|
||||
CHECK(left.GetMassCenter() == right.GetMassCenter());
|
||||
CHECK(left.GetGeom() == right.GetGeom());
|
||||
CHECK(left.GetHandle() != right.GetHandle());
|
||||
CHECK(left.GetMass() == Approx(right.GetMass()));
|
||||
CHECK(left.GetMass() == Catch::Approx(right.GetMass()));
|
||||
CHECK(left.GetPosition() == right.GetPosition());
|
||||
CHECK(left.GetRotation().value == Approx(right.GetRotation().value));
|
||||
CHECK(left.GetRotation().value == Catch::Approx(right.GetRotation().value));
|
||||
CHECK(left.GetUserdata() == right.GetUserdata());
|
||||
CHECK(left.GetVelocity() == right.GetVelocity());
|
||||
}
|
||||
|
||||
void EQUALITY(const Nz::Rectf& left, const Nz::Rectf& right)
|
||||
{
|
||||
CHECK(left.x == Approx(right.x));
|
||||
CHECK(left.y == Approx(right.y));
|
||||
CHECK(left.width == Approx(right.width));
|
||||
CHECK(left.height == Approx(right.height));
|
||||
CHECK(left.x == Catch::Approx(right.x));
|
||||
CHECK(left.y == Catch::Approx(right.y));
|
||||
CHECK(left.width == Catch::Approx(right.width));
|
||||
CHECK(left.height == Catch::Approx(right.height));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user