diff options
Diffstat (limited to 'test/platform')
-rw-r--r-- | test/platform/CMakeLists.txt | 7 | ||||
-rw-r--r-- | test/platform/graphics/direct2d/CMakeLists.txt | 6 | ||||
-rw-r--r-- | test/platform/graphics/direct2d/ConvertTest.cpp | 31 |
3 files changed, 39 insertions, 5 deletions
diff --git a/test/platform/CMakeLists.txt b/test/platform/CMakeLists.txt index 37bd7e4a..5116d54d 100644 --- a/test/platform/CMakeLists.txt +++ b/test/platform/CMakeLists.txt @@ -2,13 +2,10 @@ add_executable(CruPlatformBaseTest ColorTest.cpp MatrixTest.cpp ) -target_link_libraries(CruPlatformBaseTest PRIVATE CruPlatformBase cru_test_base) +target_link_libraries(CruPlatformBaseTest PRIVATE CruPlatformBase CruTestBase) if (WIN32) - add_custom_command(TARGET CruPlatformBaseTest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:CruPlatformBaseTest> $<TARGET_FILE_DIR:CruPlatformBaseTest> - COMMAND_EXPAND_LISTS - ) + add_subdirectory(graphics/direct2d) endif() catch_discover_tests(CruPlatformBaseTest) diff --git a/test/platform/graphics/direct2d/CMakeLists.txt b/test/platform/graphics/direct2d/CMakeLists.txt new file mode 100644 index 00000000..66a07d15 --- /dev/null +++ b/test/platform/graphics/direct2d/CMakeLists.txt @@ -0,0 +1,6 @@ +add_executable(CruPlatformGraphicsDirect2dTest + ConvertTest.cpp +) +target_link_libraries(CruPlatformGraphicsDirect2dTest PRIVATE CruPlatformGraphicsDirect2d CruTestBase) + +catch_discover_tests(CruPlatformGraphicsDirect2dTest) diff --git a/test/platform/graphics/direct2d/ConvertTest.cpp b/test/platform/graphics/direct2d/ConvertTest.cpp new file mode 100644 index 00000000..c30bb6a5 --- /dev/null +++ b/test/platform/graphics/direct2d/ConvertTest.cpp @@ -0,0 +1,31 @@ +#include "cru/platform/Matrix.h" +#include "cru/platform/graphics/direct2d/ConvertUtil.h" + +#include <catch2/catch_test_macros.hpp> +#include "catch2/catch_approx.hpp" + +using Catch::Approx; +using cru::platform::Matrix; +using cru::platform::graphics::direct2d::Convert; + +TEST_CASE("MatrixConvert Rotation", "[matrix]") { + auto matrix = Convert(Matrix::Rotation(90)); + + auto m = *D2D1::Matrix3x2F::ReinterpretBaseType(&matrix); + + auto p = m.TransformPoint({1, 1}); + + REQUIRE(p.x == Approx(-1)); + REQUIRE(p.y == Approx(1)); +} + +TEST_CASE("MatrixConvert RotationAndTranslation", "[matrix]") { + auto matrix = Convert(Matrix::Rotation(90) * Matrix::Translation(1, 1)); + + auto m = *D2D1::Matrix3x2F::ReinterpretBaseType(&matrix); + + auto p = m.TransformPoint({1, 1}); + + REQUIRE(p.x == Approx(0)); + REQUIRE(p.y == Approx(2)); +} |