From 6a59ab00511364af2f04c869f0158d4bff121ccc Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Wed, 1 Jun 2022 23:12:48 -0600 Subject: [PATCH] Add tests for `sf::ConvexShape` --- test/CMakeLists.txt | 1 + test/Graphics/ConvexShape.cpp | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/Graphics/ConvexShape.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9aa0c8cde..2a5e3f9ec 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -33,6 +33,7 @@ SET(GRAPHICS_SRC Graphics/BlendMode.cpp Graphics/CircleShape.cpp Graphics/Color.cpp + Graphics/ConvexShape.cpp Graphics/Glyph.cpp Graphics/Rect.cpp Graphics/RectangleShape.cpp diff --git a/test/Graphics/ConvexShape.cpp b/test/Graphics/ConvexShape.cpp new file mode 100644 index 000000000..7b5632ae2 --- /dev/null +++ b/test/Graphics/ConvexShape.cpp @@ -0,0 +1,38 @@ +#include +#include "SystemUtil.hpp" + +#include + +TEST_CASE("sf::ConvexShape class - [graphics]") +{ + SUBCASE("Default constructor") + { + const sf::ConvexShape convex; + CHECK(convex.getPointCount() == 0); + } + + SUBCASE("Point count constructor") + { + const sf::ConvexShape convex(15); + CHECK(convex.getPointCount() == 15); + for (std::size_t i = 0; i < convex.getPointCount(); ++i) + CHECK(convex.getPoint(i) == sf::Vector2f(0, 0)); + } + + SUBCASE("Set point count") + { + sf::ConvexShape convex; + convex.setPointCount(42); + CHECK(convex.getPointCount() == 42); + for (std::size_t i = 0; i < convex.getPointCount(); ++i) + CHECK(convex.getPoint(i) == sf::Vector2f(0, 0)); + } + + SUBCASE("Set point") + { + sf::ConvexShape convex; + convex.setPointCount(1); + convex.setPoint(0, {3, 4}); + CHECK(convex.getPoint(0) == sf::Vector2f(3, 4)); + } +}