diff options
Diffstat (limited to 'test/platform/MatrixTest.cpp')
-rw-r--r-- | test/platform/MatrixTest.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/test/platform/MatrixTest.cpp b/test/platform/MatrixTest.cpp index 62492b4e..b19b25fe 100644 --- a/test/platform/MatrixTest.cpp +++ b/test/platform/MatrixTest.cpp @@ -1,37 +1,39 @@ #include "cru/platform/GraphicsBase.h" #include "cru/platform/Matrix.h" -#include <gtest/gtest.h> +#include <catch2/catch_test_macros.hpp> +#include "catch2/catch_approx.hpp" +using Catch::Approx; using cru::platform::Matrix; using cru::platform::Point; -TEST(Matrix, Rotation) { +TEST_CASE("Matrix Rotation", "[matrix]") { Point p(1, 1); Point p90 = Matrix::Rotation(90).TransformPoint(p); - ASSERT_FLOAT_EQ(p90.x, -1); - ASSERT_FLOAT_EQ(p90.y, 1); + REQUIRE(p90.x == Approx(-1)); + REQUIRE(p90.y == Approx(1)); Point p180 = Matrix::Rotation(180).TransformPoint(p); - ASSERT_FLOAT_EQ(p180.x, -1); - ASSERT_FLOAT_EQ(p180.y, -1); + REQUIRE(p180.x == Approx(-1)); + REQUIRE(p180.y == Approx(-1)); Point p270 = Matrix::Rotation(270).TransformPoint(p); - ASSERT_FLOAT_EQ(p270.x, 1); - ASSERT_FLOAT_EQ(p270.y, -1); + REQUIRE(p270.x == Approx(1)); + REQUIRE(p270.y == Approx(-1)); } -TEST(Matrix, TranslationAndRotation) { +TEST_CASE("Matrix TranslationAndRotation", "[matrix]") { Point p = (Matrix::Translation(1, 1) * Matrix::Rotation(90)).TransformPoint({1, 1}); - ASSERT_FLOAT_EQ(p.x, -2); - ASSERT_FLOAT_EQ(p.y, 2); + REQUIRE(p.x == Approx(-2)); + REQUIRE(p.y == Approx(2)); } -TEST(Matrix, RotationAndTranslation) { +TEST_CASE("Matrix RotationAndTranslation", "[matrix]") { Point p = (Matrix::Rotation(90) * Matrix::Translation(1, 1)).TransformPoint({1, 1}); - ASSERT_FLOAT_EQ(p.x, 0); - ASSERT_FLOAT_EQ(p.y, 2); + REQUIRE(p.x == Approx(0)); + REQUIRE(p.y == Approx(2)); } |