Tests: Update Catch2 to 3.x
This commit is contained in:
parent
c6851d93c2
commit
481702c109
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Audio/Algorithm.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <Nazara/Audio/Audio.hpp>
|
||||
#include <Nazara/Audio/Music.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
std::filesystem::path GetAssetDir();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Audio/Sound.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
std::filesystem::path GetAssetDir();
|
||||
|
||||
|
|
@ -31,10 +32,10 @@ SCENARIO("SoundEmitter", "[AUDIO][SOUNDEMITTER]")
|
|||
sound.SetPitch(0.8f);
|
||||
sound.SetVolume(50.f);
|
||||
|
||||
REQUIRE(Approx(sound.GetAttenuation()) == 0.4f);
|
||||
REQUIRE(Approx(sound.GetMinDistance()) == 40.f);
|
||||
REQUIRE(Approx(sound.GetPitch()) == 0.8f);
|
||||
REQUIRE(Approx(sound.GetVolume()) == 50.f);
|
||||
REQUIRE(Catch::Approx(sound.GetAttenuation()) == 0.4f);
|
||||
REQUIRE(Catch::Approx(sound.GetMinDistance()) == 40.f);
|
||||
REQUIRE(Catch::Approx(sound.GetPitch()) == 0.8f);
|
||||
REQUIRE(Catch::Approx(sound.GetVolume()) == 50.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Audio/SoundStream.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
std::filesystem::path GetAssetDir();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <Nazara/Audio/Audio.hpp>
|
||||
#include <Nazara/Audio/Sound.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <variant>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <cstring>
|
||||
|
||||
SCENARIO("Buffering", "[CORE][BUFFERING]")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/ByteStream.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
#include <Nazara/Core/Color.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
void CompareColor(const Nz::Color& lhs, const Nz::Color& rhs)
|
||||
{
|
||||
constexpr float epsilon = 0.1f;
|
||||
|
||||
REQUIRE(lhs.r == Approx(rhs.r).margin(epsilon));
|
||||
REQUIRE(lhs.g == Approx(rhs.g).margin(epsilon));
|
||||
REQUIRE(lhs.b == Approx(rhs.b).margin(epsilon));
|
||||
REQUIRE(lhs.a == Approx(rhs.a).margin(epsilon));
|
||||
REQUIRE(lhs.r == Catch::Approx(rhs.r).margin(epsilon));
|
||||
REQUIRE(lhs.g == Catch::Approx(rhs.g).margin(epsilon));
|
||||
REQUIRE(lhs.b == Catch::Approx(rhs.b).margin(epsilon));
|
||||
REQUIRE(lhs.a == Catch::Approx(rhs.a).margin(epsilon));
|
||||
}
|
||||
|
||||
constexpr float epsilon = 1.f;
|
||||
|
|
@ -17,46 +18,46 @@ void CompareCMY(const Nz::Color& color, float cyan, float magenta, float yellow)
|
|||
{
|
||||
float retrievedCyan = 0.f, retrievedMagenta = 0.f, retrievedYellow = 0.f;
|
||||
Nz::Color::ToCMY(color, &retrievedCyan, &retrievedMagenta, &retrievedYellow);
|
||||
CHECK(retrievedCyan == Approx(cyan).margin(epsilon));
|
||||
CHECK(retrievedMagenta == Approx(magenta).margin(epsilon));
|
||||
CHECK(retrievedYellow == Approx(yellow).margin(epsilon));
|
||||
CHECK(retrievedCyan == Catch::Approx(cyan).margin(epsilon));
|
||||
CHECK(retrievedMagenta == Catch::Approx(magenta).margin(epsilon));
|
||||
CHECK(retrievedYellow == Catch::Approx(yellow).margin(epsilon));
|
||||
}
|
||||
|
||||
void CompareCMYK(const Nz::Color& color, float cyan, float magenta, float yellow, float black)
|
||||
{
|
||||
float retrievedCyan = 0.f, retrievedMagenta = 0.f, retrievedYellow = 0.f, retrievedBlack = 0.f;
|
||||
Nz::Color::ToCMYK(color, &retrievedCyan, &retrievedMagenta, &retrievedYellow, &retrievedBlack);
|
||||
CHECK(retrievedCyan == Approx(cyan).margin(epsilon));
|
||||
CHECK(retrievedMagenta == Approx(magenta).margin(epsilon));
|
||||
CHECK(retrievedYellow == Approx(yellow).margin(epsilon));
|
||||
CHECK(retrievedBlack == Approx(black).margin(epsilon));
|
||||
CHECK(retrievedCyan == Catch::Approx(cyan).margin(epsilon));
|
||||
CHECK(retrievedMagenta == Catch::Approx(magenta).margin(epsilon));
|
||||
CHECK(retrievedYellow == Catch::Approx(yellow).margin(epsilon));
|
||||
CHECK(retrievedBlack == Catch::Approx(black).margin(epsilon));
|
||||
}
|
||||
|
||||
void CompareHSL(const Nz::Color& color, float hue, float saturation, float luminosity)
|
||||
{
|
||||
float retrievedHue = 0.f, retrievedSaturation = 0.f, retrievedLuminosity = 0.f;
|
||||
Nz::Color::ToHSL(color, &retrievedHue, &retrievedSaturation, &retrievedLuminosity);
|
||||
CHECK(retrievedHue == Approx(hue).margin(epsilon));
|
||||
CHECK(retrievedSaturation == Approx(saturation).margin(epsilon));
|
||||
CHECK(retrievedLuminosity == Approx(luminosity).margin(epsilon));
|
||||
CHECK(retrievedHue == Catch::Approx(hue).margin(epsilon));
|
||||
CHECK(retrievedSaturation == Catch::Approx(saturation).margin(epsilon));
|
||||
CHECK(retrievedLuminosity == Catch::Approx(luminosity).margin(epsilon));
|
||||
}
|
||||
|
||||
void CompareHSV(const Nz::Color& color, float hue, float saturation, float value)
|
||||
{
|
||||
float retrievedHue = 0.f, retrievedSaturation = 0.f, retrievedValue = 0.f;
|
||||
Nz::Color::ToHSV(color, &retrievedHue, &retrievedSaturation, &retrievedValue);
|
||||
CHECK(retrievedHue == Approx(hue).margin(epsilon));
|
||||
CHECK(retrievedSaturation == Approx(saturation).margin(epsilon));
|
||||
CHECK(retrievedValue == Approx(value).margin(epsilon));
|
||||
CHECK(retrievedHue == Catch::Approx(hue).margin(epsilon));
|
||||
CHECK(retrievedSaturation == Catch::Approx(saturation).margin(epsilon));
|
||||
CHECK(retrievedValue == Catch::Approx(value).margin(epsilon));
|
||||
}
|
||||
|
||||
void CompareXYZ(const Nz::Color& color, float x, float y, float z)
|
||||
{
|
||||
Nz::Vector3f retrievedValues = Nz::Vector3f::Zero();
|
||||
Nz::Color::ToXYZ(color, &retrievedValues);
|
||||
CHECK(retrievedValues.x == Approx(x).margin(epsilon));
|
||||
CHECK(retrievedValues.y == Approx(y).margin(epsilon));
|
||||
CHECK(retrievedValues.z == Approx(z).margin(epsilon));
|
||||
CHECK(retrievedValues.x == Catch::Approx(x).margin(epsilon));
|
||||
CHECK(retrievedValues.y == Catch::Approx(y).margin(epsilon));
|
||||
CHECK(retrievedValues.z == Catch::Approx(z).margin(epsilon));
|
||||
}
|
||||
|
||||
SCENARIO("Color", "[CORE][COLOR]")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Error", "[CORE][ERROR]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/File.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
std::filesystem::path GetAssetDir();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <Nazara/Core/HandledObject.hpp>
|
||||
#include <Nazara/Core/ObjectHandle.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
struct ObjectHandle_Test : public Nz::HandledObject<ObjectHandle_Test>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
class Test : public Nz::RefCounted
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/ParameterList.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
void nullAction(void*)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/PrimitiveList.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("PrimitiveList", "[CORE][PRIMITIVELIST]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("RefCounted", "[CORE][REFCOUNTED]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
#include <Nazara/Math/Ray.hpp>
|
||||
#include <array>
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Serialization", "[CORE][SERIALIZATION]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("String", "[CORE][STRING]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Core/Uuid.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <Nazara/Core/VirtualDirectory.hpp>
|
||||
#include <Nazara/Core/Hash/SHA256.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <random>
|
||||
|
||||
std::filesystem::path GetAssetDir();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <Nazara/Math/Algorithm.hpp>
|
||||
#include <Nazara/Math/Angle.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <limits>
|
||||
|
||||
TEST_CASE("Approach", "[MATH][ALGORITHM]")
|
||||
|
|
@ -61,7 +62,7 @@ TEST_CASE("DegreeToRadian", "[MATH][ALGORITHM]")
|
|||
{
|
||||
SECTION("Convert 45.f degree to radian")
|
||||
{
|
||||
REQUIRE(Nz::DegreeToRadian(45.f) == Approx(Nz::Pi<float> / 4.f));
|
||||
REQUIRE(Nz::DegreeToRadian(45.f) == Catch::Approx(Nz::Pi<float> / 4.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -323,7 +324,7 @@ TEST_CASE("RadianToDegree", "[MATH][ALGORITHM]")
|
|||
{
|
||||
SECTION("PI / 4 to degree")
|
||||
{
|
||||
REQUIRE(Nz::RadianToDegree(Nz::Pi<float> / 4.f) == Approx(45.f));
|
||||
REQUIRE(Nz::RadianToDegree(Nz::Pi<float> / 4.f) == Catch::Approx(45.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <Nazara/Math/Angle.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Angle", "[MATH][ANGLE]")
|
||||
{
|
||||
|
|
@ -36,8 +37,8 @@ SCENARIO("Angle", "[MATH][ANGLE]")
|
|||
{
|
||||
THEN("It should be equal to 1 and 0")
|
||||
{
|
||||
CHECK(angle.GetSin() == Approx(1.f).margin(0.0001f));
|
||||
CHECK(angle.GetCos() == Approx(0.f).margin(0.0001f));
|
||||
CHECK(angle.GetSin() == Catch::Approx(1.f).margin(0.0001f));
|
||||
CHECK(angle.GetCos() == Catch::Approx(0.f).margin(0.0001f));
|
||||
}
|
||||
AND_WHEN("We compute sin/cos at the same time")
|
||||
{
|
||||
|
|
@ -45,8 +46,8 @@ SCENARIO("Angle", "[MATH][ANGLE]")
|
|||
|
||||
THEN("It should also be equal to 1 and 0")
|
||||
{
|
||||
CHECK(sincos.first == Approx(1.f).margin(0.0001f));
|
||||
CHECK(sincos.second == Approx(0.f).margin(0.0001f));
|
||||
CHECK(sincos.first == Catch::Approx(1.f).margin(0.0001f));
|
||||
CHECK(sincos.second == Catch::Approx(0.f).margin(0.0001f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -135,8 +136,8 @@ SCENARIO("Angle", "[MATH][ANGLE]")
|
|||
{
|
||||
THEN("It should be equal to 0 and -1")
|
||||
{
|
||||
CHECK(angle.GetSin() == Approx(0.f).margin(0.0001f));
|
||||
CHECK(angle.GetCos() == Approx(-1.f).margin(0.0001f));
|
||||
CHECK(angle.GetSin() == Catch::Approx(0.f).margin(0.0001f));
|
||||
CHECK(angle.GetCos() == Catch::Approx(-1.f).margin(0.0001f));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -146,8 +147,8 @@ SCENARIO("Angle", "[MATH][ANGLE]")
|
|||
|
||||
THEN("It should also be equal to 0 and -1")
|
||||
{
|
||||
CHECK(sincos.first == Approx(0.f).margin(0.0001f));
|
||||
CHECK(sincos.second == Approx(-1.f).margin(0.0001f));
|
||||
CHECK(sincos.first == Catch::Approx(0.f).margin(0.0001f));
|
||||
CHECK(sincos.second == Catch::Approx(-1.f).margin(0.0001f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("BoundingVolume", "[MATH][BOUNDINGVOLUME]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Box.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Box", "[MATH][BOX]")
|
||||
{
|
||||
|
|
@ -40,9 +41,9 @@ SCENARIO("Box", "[MATH][BOX]")
|
|||
REQUIRE(firstCenterAndUnit.GetNegativeVertex(Nz::Vector3f::Unit()) == Nz::Vector3f::Zero());
|
||||
REQUIRE(firstCenterAndUnit.GetPosition() == Nz::Vector3f::Zero());
|
||||
REQUIRE(firstCenterAndUnit.GetPositiveVertex(Nz::Vector3f::Unit()) == Nz::Vector3f::Unit());
|
||||
REQUIRE(firstCenterAndUnit.GetRadius() == Approx(std::sqrt(3.f * 0.5f * 0.5f)));
|
||||
REQUIRE(firstCenterAndUnit.GetRadius() == Catch::Approx(std::sqrt(3.f * 0.5f * 0.5f)));
|
||||
REQUIRE(firstCenterAndUnit.GetSquaredBoundingSphere() == Nz::Spheref(Nz::Vector3f::Unit() * 0.5f, 3.f * 0.5f * 0.5f));
|
||||
REQUIRE(firstCenterAndUnit.GetSquaredRadius() == Approx(3.f * 0.5f * 0.5f));
|
||||
REQUIRE(firstCenterAndUnit.GetSquaredRadius() == Catch::Approx(3.f * 0.5f * 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <Nazara/Math/Angle.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("EulerAngles", "[MATH][EULERANGLES]")
|
||||
{
|
||||
|
|
@ -88,19 +89,19 @@ SCENARIO("EulerAngles", "[MATH][EULERANGLES]")
|
|||
THEN("And then convert to euler angles, we have identity")
|
||||
{
|
||||
Nz::EulerAnglesf tmp = Nz::Quaternionf(euler45.ToQuaternion()).ToEulerAngles();
|
||||
CHECK(tmp.pitch.ToDegrees() == Approx(0.f));
|
||||
CHECK(tmp.yaw.ToDegrees() == Approx(22.5f));
|
||||
CHECK(tmp.roll.ToDegrees() == Approx(22.5f));
|
||||
CHECK(tmp.pitch.ToDegrees() == Catch::Approx(0.f));
|
||||
CHECK(tmp.yaw.ToDegrees() == Catch::Approx(22.5f));
|
||||
CHECK(tmp.roll.ToDegrees() == Catch::Approx(22.5f));
|
||||
|
||||
tmp = Nz::Quaternionf(euler90.ToQuaternion()).ToEulerAngles();
|
||||
CHECK(tmp.pitch.ToDegrees() == Approx(90.f));
|
||||
CHECK(tmp.yaw.ToDegrees() == Approx(90.f));
|
||||
CHECK(tmp.roll.ToDegrees() == Approx(0.f));
|
||||
CHECK(tmp.pitch.ToDegrees() == Catch::Approx(90.f));
|
||||
CHECK(tmp.yaw.ToDegrees() == Catch::Approx(90.f));
|
||||
CHECK(tmp.roll.ToDegrees() == Catch::Approx(0.f));
|
||||
|
||||
tmp = Nz::Quaternionf(euler30.ToQuaternion()).ToEulerAngles();
|
||||
CHECK(tmp.pitch.ToDegrees() == Approx(30.f));
|
||||
CHECK(tmp.yaw.ToDegrees() == Approx(0.f).margin(0.0001f));
|
||||
CHECK(tmp.roll.ToDegrees() == Approx(30.f));
|
||||
CHECK(tmp.pitch.ToDegrees() == Catch::Approx(30.f));
|
||||
CHECK(tmp.yaw.ToDegrees() == Catch::Approx(0.f).margin(0.0001f));
|
||||
CHECK(tmp.roll.ToDegrees() == Catch::Approx(30.f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Frustum.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Frustum", "[MATH][FRUSTUM]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
|
|
@ -67,8 +68,8 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]")
|
|||
{
|
||||
THEN("These results are expected")
|
||||
{
|
||||
CHECK(matrix1.GetDeterminant() == Approx(24.f));
|
||||
CHECK(matrix2.GetDeterminant() == Approx(-1.f));
|
||||
CHECK(matrix1.GetDeterminant() == Catch::Approx(24.f));
|
||||
CHECK(matrix2.GetDeterminant() == Catch::Approx(-1.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,8 +84,8 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]")
|
|||
THEN("We get the identity")
|
||||
{
|
||||
Nz::Matrix4f tmp = matrix1 * invMatrix1;
|
||||
CHECK(tmp.m32 == Approx(0.f).margin(0.0001f));
|
||||
CHECK(tmp.m42 == Approx(0.f).margin(0.0001f));
|
||||
CHECK(tmp.m32 == Catch::Approx(0.f).margin(0.0001f));
|
||||
CHECK(tmp.m42 == Catch::Approx(0.f).margin(0.0001f));
|
||||
tmp.m32 = 0.f;
|
||||
tmp.m42 = 0.f;
|
||||
CHECK(tmp == Nz::Matrix4f::Identity());
|
||||
|
|
@ -215,9 +216,9 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]")
|
|||
{
|
||||
identity.ApplyRotation(Nz::EulerAnglesf(Nz::DegreeAnglef(10.f), Nz::DegreeAnglef(20.f), Nz::DegreeAnglef(30.f)));
|
||||
Nz::Vector3f retrievedScale = identity.GetScale();
|
||||
CHECK(retrievedScale.x == Approx(scale.x));
|
||||
CHECK(retrievedScale.y == Approx(scale.y));
|
||||
CHECK(retrievedScale.z == Approx(scale.z));
|
||||
CHECK(retrievedScale.x == Catch::Approx(scale.x));
|
||||
CHECK(retrievedScale.y == Catch::Approx(scale.y));
|
||||
CHECK(retrievedScale.z == Catch::Approx(scale.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -233,7 +234,7 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]")
|
|||
{
|
||||
THEN("We expect those to be true")
|
||||
{
|
||||
CHECK(negativeDeterminant.GetDeterminant() == Approx(-1.f));
|
||||
CHECK(negativeDeterminant.GetDeterminant() == Catch::Approx(-1.f));
|
||||
CHECK(!negativeDeterminant.HasScale());
|
||||
CHECK(negativeDeterminant.HasNegativeScale());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/OrientedBox.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("OrientedBox", "[MATH][ORIENTEDBOX]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Plane.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Plane", "[MATH][PLANE]")
|
||||
{
|
||||
|
|
@ -23,30 +24,30 @@ SCENARIO("Plane", "[MATH][PLANE]")
|
|||
AND_THEN("They have the same distance from the same point")
|
||||
{
|
||||
Nz::Vector3f point(-2.f, 3.f, 1.f);
|
||||
REQUIRE(firstPlane.Distance(point) == Approx(secondPlane.Distance(point)));
|
||||
REQUIRE(firstPlane.Distance(-2.f, 3.f, 1.f) == Approx(0.1547f));
|
||||
REQUIRE(firstPlane.Distance(point) == Catch::Approx(secondPlane.Distance(point)));
|
||||
REQUIRE(firstPlane.Distance(-2.f, 3.f, 1.f) == Catch::Approx(0.1547f));
|
||||
}
|
||||
|
||||
AND_THEN("Distance between Plane (0, 1, 0), distance 1 and point (0, 2, 0) should be 1")
|
||||
{
|
||||
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1.f).Distance(Nz::Vector3f::UnitY() * 2.f) == Approx(1.f));
|
||||
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1.f).Distance(Nz::Vector3f::UnitY() * 2.f) == Catch::Approx(1.f));
|
||||
}
|
||||
|
||||
AND_THEN("Distance between Plane (0, 1, 0), distance 5 and point (0, 2, 0) should be -3")
|
||||
{
|
||||
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 5.f).Distance(Nz::Vector3f::UnitY() * 2.f) == Approx(-3.f));
|
||||
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 5.f).Distance(Nz::Vector3f::UnitY() * 2.f) == Catch::Approx(-3.f));
|
||||
}
|
||||
|
||||
AND_THEN("Distance between Plane (0, 1, 0), distance 1000 and point (0, 500, 0) and (0, 1500, 0)")
|
||||
{
|
||||
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1000.f).Distance(Nz::Vector3f::UnitY() * 500.f) == Approx(-500.f));
|
||||
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1000.f).Distance(Nz::Vector3f::UnitY() * 1500.f) == Approx(500.f));
|
||||
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1000.f).Distance(Nz::Vector3f::UnitY() * 500.f) == Catch::Approx(-500.f));
|
||||
REQUIRE(Nz::Planef(Nz::Vector3f::UnitY(), 1000.f).Distance(Nz::Vector3f::UnitY() * 1500.f) == Catch::Approx(500.f));
|
||||
}
|
||||
|
||||
AND_THEN("Distance between Plane (0, -1, 0), distance -1000 and point (0, 500, 0) and (0, 1500, 0)")
|
||||
{
|
||||
REQUIRE(Nz::Planef(-Nz::Vector3f::UnitY(), -1000.f).Distance(Nz::Vector3f::UnitY() * 500.f) == Approx(500.f));
|
||||
REQUIRE(Nz::Planef(-Nz::Vector3f::UnitY(), -1000.f).Distance(Nz::Vector3f::UnitY() * 1500.f) == Approx(-500.f));
|
||||
REQUIRE(Nz::Planef(-Nz::Vector3f::UnitY(), -1000.f).Distance(Nz::Vector3f::UnitY() * 500.f) == Catch::Approx(500.f));
|
||||
REQUIRE(Nz::Planef(-Nz::Vector3f::UnitY(), -1000.f).Distance(Nz::Vector3f::UnitY() * 1500.f) == Catch::Approx(-500.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Quaternion", "[MATH][QUATERNION]")
|
||||
{
|
||||
|
|
@ -15,7 +16,7 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]")
|
|||
REQUIRE(firstQuaternion == secondQuaternion);
|
||||
REQUIRE(firstQuaternion.ComputeW() == secondQuaternion.Normalize());
|
||||
REQUIRE(firstQuaternion.Conjugate() == secondQuaternion.Inverse());
|
||||
REQUIRE(firstQuaternion.DotProduct(secondQuaternion) == Approx(1.f));
|
||||
REQUIRE(firstQuaternion.DotProduct(secondQuaternion) == Catch::Approx(1.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]")
|
|||
|
||||
REQUIRE(inverted == zero);
|
||||
REQUIRE(normalized == zero);
|
||||
REQUIRE(tmp == Approx(0.f));
|
||||
REQUIRE(tmp == Catch::Approx(0.f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,11 +64,11 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]")
|
|||
{
|
||||
THEN("They are all equal to 1")
|
||||
{
|
||||
REQUIRE(w.Magnitude() == Approx(1.f));
|
||||
REQUIRE(x.Magnitude() == Approx(1.f));
|
||||
REQUIRE(y.Magnitude() == Approx(1.f));
|
||||
REQUIRE(z.Magnitude() == Approx(1.f));
|
||||
REQUIRE(xyzw.Magnitude() == Approx(1.f));
|
||||
REQUIRE(w.Magnitude() == Catch::Approx(1.f));
|
||||
REQUIRE(x.Magnitude() == Catch::Approx(1.f));
|
||||
REQUIRE(y.Magnitude() == Catch::Approx(1.f));
|
||||
REQUIRE(z.Magnitude() == Catch::Approx(1.f));
|
||||
REQUIRE(xyzw.Magnitude() == Catch::Approx(1.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,15 +145,15 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]")
|
|||
THEN("The half of 10 and 30 is 20")
|
||||
{
|
||||
Nz::Quaternionf slerpx10x30a = Nz::Quaternionf::Slerp(x10, x30a, 0.5f);
|
||||
REQUIRE(slerpx10x30a.w == Approx(x20.w));
|
||||
REQUIRE(slerpx10x30a.x == Approx(x20.x));
|
||||
REQUIRE(slerpx10x30a.y == Approx(x20.y));
|
||||
REQUIRE(slerpx10x30a.z == Approx(x20.z));
|
||||
REQUIRE(slerpx10x30a.w == Catch::Approx(x20.w));
|
||||
REQUIRE(slerpx10x30a.x == Catch::Approx(x20.x));
|
||||
REQUIRE(slerpx10x30a.y == Catch::Approx(x20.y));
|
||||
REQUIRE(slerpx10x30a.z == Catch::Approx(x20.z));
|
||||
Nz::Quaternionf slerpx10x30b = Nz::Quaternionf::Slerp(x10, x30b, 0.5f);
|
||||
REQUIRE(slerpx10x30b.w == Approx(x20.w));
|
||||
REQUIRE(slerpx10x30b.x == Approx(x20.x));
|
||||
REQUIRE(slerpx10x30b.y == Approx(x20.y));
|
||||
REQUIRE(slerpx10x30b.z == Approx(x20.z));
|
||||
REQUIRE(slerpx10x30b.w == Catch::Approx(x20.w));
|
||||
REQUIRE(slerpx10x30b.x == Catch::Approx(x20.x));
|
||||
REQUIRE(slerpx10x30b.y == Catch::Approx(x20.y));
|
||||
REQUIRE(slerpx10x30b.z == Catch::Approx(x20.z));
|
||||
REQUIRE(Nz::Quaternionf::Slerp(x10, x30a, 0.f) == x10);
|
||||
REQUIRE(Nz::Quaternionf::Slerp(x10, x30a, 1.f) == x30a);
|
||||
}
|
||||
|
|
@ -164,10 +165,10 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]")
|
|||
Nz::Quaternionf quaternionC = Nz::Quaternionf::Slerp(quaterionA, quaterionB, 0.5f);
|
||||
|
||||
Nz::Quaternionf unitZ225(Nz::DegreeAnglef(22.5f), Nz::Vector3f::UnitZ());
|
||||
REQUIRE(quaternionC.w == Approx(unitZ225.w));
|
||||
REQUIRE(quaternionC.x == Approx(unitZ225.x));
|
||||
REQUIRE(quaternionC.y == Approx(unitZ225.y));
|
||||
REQUIRE(quaternionC.z == Approx(unitZ225.z));
|
||||
REQUIRE(quaternionC.w == Catch::Approx(unitZ225.w));
|
||||
REQUIRE(quaternionC.x == Catch::Approx(unitZ225.x));
|
||||
REQUIRE(quaternionC.y == Catch::Approx(unitZ225.y));
|
||||
REQUIRE(quaternionC.z == Catch::Approx(unitZ225.z));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Ray.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Ray", "[MATH][RAY]")
|
||||
{
|
||||
|
|
@ -21,7 +22,7 @@ SCENARIO("Ray", "[MATH][RAY]")
|
|||
{
|
||||
THEN("The point that is multiple on the Nz::Ray, is at multiple")
|
||||
{
|
||||
REQUIRE(ray.ClosestPoint(secondRay.GetPoint(1.f)) == Approx(1.f));
|
||||
REQUIRE(ray.ClosestPoint(secondRay.GetPoint(1.f)) == Catch::Approx(1.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ SCENARIO("Ray", "[MATH][RAY]")
|
|||
float tmpFurthest = -1.f;
|
||||
Nz::BoundingVolumef infiniteVolume(Nz::Extend::Infinite);
|
||||
CHECK(ray.Intersect(infiniteVolume, &tmpClosest, &tmpFurthest));
|
||||
CHECK(tmpClosest == Approx(0.f));
|
||||
CHECK(tmpClosest == Catch::Approx(0.f));
|
||||
CHECK(tmpFurthest == std::numeric_limits<float>::infinity());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Rect", "[MATH][RECT]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Sphere.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("Sphere", "[MATH][SPHERE]")
|
||||
{
|
||||
|
|
@ -41,10 +42,10 @@ SCENARIO("Sphere", "[MATH][SPHERE]")
|
|||
{
|
||||
THEN("These results are expected because we don't take into account the border")
|
||||
{
|
||||
CHECK(firstCenterAndUnit.Distance(Nz::Vector3f::UnitX() * 2.f) == Approx(1.f));
|
||||
CHECK(firstCenterAndUnit.Distance(Nz::Vector3f::UnitX() * 2.f) == Catch::Approx(1.f));
|
||||
|
||||
Nz::Spheref tmp(Nz::Vector3f::UnitX(), 1.f);
|
||||
CHECK(tmp.Distance(Nz::Vector3f::UnitX() * 4.f) == Approx(2.f));
|
||||
CHECK(tmp.Distance(Nz::Vector3f::UnitX() * 4.f) == Catch::Approx(2.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,12 +80,12 @@ SCENARIO("Sphere", "[MATH][SPHERE]")
|
|||
|
||||
firstCenterAndUnit.ExtendTo(point);
|
||||
|
||||
REQUIRE(firstCenterAndUnit.radius == Approx(2.f));
|
||||
REQUIRE(firstCenterAndUnit.radius == Catch::Approx(2.f));
|
||||
|
||||
THEN("Sphere must contain it and distance should be good")
|
||||
{
|
||||
CHECK(firstCenterAndUnit.Contains(point));
|
||||
CHECK(firstCenterAndUnit.Distance(point) == Approx(0.f));
|
||||
CHECK(firstCenterAndUnit.Distance(point) == Catch::Approx(0.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
|
|
@ -25,8 +26,8 @@ SCENARIO("Vector2", "[MATH][VECTOR2]")
|
|||
|
||||
THEN("These are perpendicular")
|
||||
{
|
||||
REQUIRE(firstUnit.AbsDotProduct(tmp) == Approx(2.f));
|
||||
REQUIRE(firstUnit.DotProduct(tmp) == Approx(0.f));
|
||||
REQUIRE(firstUnit.AbsDotProduct(tmp) == Catch::Approx(2.f));
|
||||
REQUIRE(firstUnit.DotProduct(tmp) == Catch::Approx(0.f));
|
||||
REQUIRE(firstUnit.AngleBetween(tmp) == Nz::DegreeAnglef(90.f));
|
||||
Nz::Vector2f negativeUnitX = -Nz::Vector2f::UnitX();
|
||||
REQUIRE(negativeUnitX.AngleBetween(negativeUnitX + Nz::Vector2f(0, 0.0000001f)) == Nz::DegreeAnglef(360.f));
|
||||
|
|
@ -40,12 +41,12 @@ SCENARIO("Vector2", "[MATH][VECTOR2]")
|
|||
|
||||
THEN("These are expected")
|
||||
{
|
||||
REQUIRE(firstUnit.Distance(tmp2) == Approx(2.f * std::sqrt(2.f)));
|
||||
REQUIRE(firstUnit.Distance(tmp) == Approx(5.f));
|
||||
REQUIRE(firstUnit.SquaredDistance(tmp) == Approx(25.f));
|
||||
REQUIRE(firstUnit.Distance(tmp2) == Catch::Approx(2.f * std::sqrt(2.f)));
|
||||
REQUIRE(firstUnit.Distance(tmp) == Catch::Approx(5.f));
|
||||
REQUIRE(firstUnit.SquaredDistance(tmp) == Catch::Approx(25.f));
|
||||
|
||||
REQUIRE(firstUnit.GetSquaredLength() == Approx(2.f));
|
||||
REQUIRE(firstUnit.GetLength() == Approx(std::sqrt(2.f)));
|
||||
REQUIRE(firstUnit.GetSquaredLength() == Catch::Approx(2.f));
|
||||
REQUIRE(firstUnit.GetLength() == Catch::Approx(std::sqrt(2.f)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,14 +57,14 @@ SCENARIO("Vector2", "[MATH][VECTOR2]")
|
|||
{
|
||||
Nz::Vector2f normalized = firstUnit.GetNormal(&ratio);
|
||||
REQUIRE(normalized == (Nz::Vector2f::Unit() / std::sqrt(2.f)));
|
||||
REQUIRE(ratio == Approx(std::sqrt(2.f)));
|
||||
REQUIRE(ratio == Catch::Approx(std::sqrt(2.f)));
|
||||
}
|
||||
|
||||
THEN("For null vector")
|
||||
{
|
||||
Nz::Vector2f zero = Nz::Vector2f::Zero();
|
||||
REQUIRE(zero.GetNormal(&ratio) == Nz::Vector2f::Zero());
|
||||
REQUIRE(ratio == Approx(0.f));
|
||||
REQUIRE(ratio == Catch::Approx(0.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
|
|
@ -24,8 +25,8 @@ SCENARIO("Vector3", "[MATH][VECTOR3]")
|
|||
|
||||
THEN("These results are expected")
|
||||
{
|
||||
REQUIRE(firstUnit.AbsDotProduct(tmp) == Approx(2.f));
|
||||
REQUIRE(firstUnit.DotProduct(tmp) == Approx(0.f));
|
||||
REQUIRE(firstUnit.AbsDotProduct(tmp) == Catch::Approx(2.f));
|
||||
REQUIRE(firstUnit.DotProduct(tmp) == Catch::Approx(0.f));
|
||||
REQUIRE(firstUnit.AngleBetween(tmp) == Nz::DegreeAnglef(90.f));
|
||||
REQUIRE(firstUnit.AngleBetween(-firstUnit) == Nz::DegreeAnglef(180.f));
|
||||
}
|
||||
|
|
@ -46,11 +47,11 @@ SCENARIO("Vector3", "[MATH][VECTOR3]")
|
|||
|
||||
THEN("These are expected")
|
||||
{
|
||||
REQUIRE(firstUnit.Distance(tmp) == Approx(11.f));
|
||||
REQUIRE(firstUnit.SquaredDistance(tmp) == Approx(121.f));
|
||||
REQUIRE(firstUnit.Distance(tmp) == Catch::Approx(11.f));
|
||||
REQUIRE(firstUnit.SquaredDistance(tmp) == Catch::Approx(121.f));
|
||||
|
||||
REQUIRE(firstUnit.GetSquaredLength() == Approx(3.f));
|
||||
REQUIRE(firstUnit.GetLength() == Approx(std::sqrt(3.f)));
|
||||
REQUIRE(firstUnit.GetSquaredLength() == Catch::Approx(3.f));
|
||||
REQUIRE(firstUnit.GetLength() == Catch::Approx(std::sqrt(3.f)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,14 +62,14 @@ SCENARIO("Vector3", "[MATH][VECTOR3]")
|
|||
{
|
||||
Nz::Vector3f normalized = firstUnit.GetNormal(&ratio);
|
||||
REQUIRE(normalized == (Nz::Vector3f::Unit() / std::sqrt(3.f)));
|
||||
REQUIRE(ratio == Approx(std::sqrt(3.f)));
|
||||
REQUIRE(ratio == Catch::Approx(std::sqrt(3.f)));
|
||||
}
|
||||
|
||||
THEN("For null vector")
|
||||
{
|
||||
Nz::Vector3f zero = Nz::Vector3f::Zero();
|
||||
REQUIRE(zero.GetNormal(&ratio) == Nz::Vector3f::Zero());
|
||||
REQUIRE(ratio == Approx(0.f));
|
||||
REQUIRE(ratio == Catch::Approx(0.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Math/Vector4.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
|
|
@ -24,8 +25,8 @@ SCENARIO("Vector4", "[MATH][VECTOR4]")
|
|||
|
||||
THEN("These results are expected")
|
||||
{
|
||||
REQUIRE(firstUnit.AbsDotProduct(tmp) == Approx(2.f));
|
||||
REQUIRE(firstUnit.DotProduct(tmp) == Approx(0.f));
|
||||
REQUIRE(firstUnit.AbsDotProduct(tmp) == Catch::Approx(2.f));
|
||||
REQUIRE(firstUnit.DotProduct(tmp) == Catch::Approx(0.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <Nazara/Network/Algorithm.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("IpAddress", "[NETWORK][IPADDRESS]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
#include <Nazara/Network/SocketPoller.hpp>
|
||||
#include <Nazara/Network/TcpClient.hpp>
|
||||
#include <Nazara/Network/TcpServer.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <random>
|
||||
|
||||
SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
#include <Nazara/Network/NetPacket.hpp>
|
||||
#include <Nazara/Network/TcpClient.hpp>
|
||||
#include <Nazara/Network/TcpServer.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Network/UdpSocket.hpp>
|
||||
#include <Nazara/Network/NetPacket.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Utility/GuillotineImageAtlas.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
|
||||
|
|
@ -28,14 +29,14 @@ SCENARIO("Fonts", "[Utility][Font]")
|
|||
const auto& sizeInfo24 = font->GetSizeInfo(24);
|
||||
CHECK(sizeInfo24.lineHeight == 33);
|
||||
CHECK(sizeInfo24.spaceAdvance == 6);
|
||||
CHECK(sizeInfo24.underlinePosition == Approx(-2.40625f));
|
||||
CHECK(sizeInfo24.underlineThickness == Approx(1.20312f));
|
||||
CHECK(sizeInfo24.underlinePosition == Catch::Approx(-2.40625f));
|
||||
CHECK(sizeInfo24.underlineThickness == Catch::Approx(1.20312f));
|
||||
|
||||
const auto& sizeInfo72 = font->GetSizeInfo(72);
|
||||
CHECK(sizeInfo72.lineHeight == 98);
|
||||
CHECK(sizeInfo72.spaceAdvance == 19);
|
||||
CHECK(sizeInfo72.underlinePosition == Approx(-7.20312f));
|
||||
CHECK(sizeInfo72.underlineThickness == Approx(3.59375f));
|
||||
CHECK(sizeInfo72.underlinePosition == Catch::Approx(-7.20312f));
|
||||
CHECK(sizeInfo72.underlineThickness == Catch::Approx(3.59375f));
|
||||
}
|
||||
|
||||
WHEN("Retrieving kerning")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
std::filesystem::path GetAssetDir();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/ImageStream.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
std::filesystem::path GetAssetDir();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
std::filesystem::path GetAssetDir();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#define CATCH_CONFIG_RUNNER
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_session.hpp>
|
||||
|
||||
#include <Nazara/Audio/Audio.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ if has_config("tests") then
|
|||
add_defines("CATCH_CONFIG_NO_POSIX_SIGNALS")
|
||||
end
|
||||
|
||||
add_requires("catch2")
|
||||
add_requires("catch2 3")
|
||||
|
||||
-- Common config
|
||||
set_group("Tests")
|
||||
|
|
|
|||
Loading…
Reference in New Issue