diff options
Diffstat (limited to 'test/platform')
-rw-r--r-- | test/platform/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test/platform/ColorTest.cpp | 16 | ||||
-rw-r--r-- | test/platform/MatrixTest.cpp | 30 |
3 files changed, 25 insertions, 23 deletions
diff --git a/test/platform/CMakeLists.txt b/test/platform/CMakeLists.txt index 5feec2d1..014e88fe 100644 --- a/test/platform/CMakeLists.txt +++ b/test/platform/CMakeLists.txt @@ -11,4 +11,4 @@ if (WIN32) ) endif() -gtest_discover_tests(cru_platform_base_test) +catch_discover_tests(cru_platform_base_test) diff --git a/test/platform/ColorTest.cpp b/test/platform/ColorTest.cpp index 451fb069..0c7c18ba 100644 --- a/test/platform/ColorTest.cpp +++ b/test/platform/ColorTest.cpp @@ -1,14 +1,14 @@ #include "cru/platform/Color.h" -#include <gtest/gtest.h> +#include <catch2/catch_test_macros.hpp> using cru::platform::Color; -TEST(Color, Parse) { - ASSERT_EQ(Color::Parse(u"blue"), Color::Parse(u"#0000ff")); - ASSERT_EQ(Color::Parse(u"#12abAB"), Color::FromHex(0x12abAB)); - ASSERT_EQ(Color::Parse(u"#8812abAB"), Color::FromHexAlpha(0x8812abAB)); - ASSERT_EQ(Color::Parse(u"averystrangestring"), std::nullopt); - ASSERT_EQ(Color::Parse(u"112233"), std::nullopt); - ASSERT_EQ(Color::Parse(u"#7777777"), std::nullopt); +TEST_CASE("Color Parse", "[color]") { + REQUIRE(Color::Parse(u"blue") == Color::Parse(u"#0000ff")); + REQUIRE(Color::Parse(u"#12abAB") == Color::FromHex(0x12abAB)); + REQUIRE(Color::Parse(u"#8812abAB") == Color::FromHexAlpha(0x8812abAB)); + REQUIRE(Color::Parse(u"averystrangestring") == std::nullopt); + REQUIRE(Color::Parse(u"112233") == std::nullopt); + REQUIRE(Color::Parse(u"#7777777") == std::nullopt); } 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)); } |