Add tests for sf::ConvexShape

This commit is contained in:
Chris Thrasher 2022-06-01 23:12:48 -06:00 committed by Lukas Dürrenberger
parent fd1435d1c0
commit 6a59ab0051
2 changed files with 39 additions and 0 deletions

View File

@ -33,6 +33,7 @@ SET(GRAPHICS_SRC
Graphics/BlendMode.cpp Graphics/BlendMode.cpp
Graphics/CircleShape.cpp Graphics/CircleShape.cpp
Graphics/Color.cpp Graphics/Color.cpp
Graphics/ConvexShape.cpp
Graphics/Glyph.cpp Graphics/Glyph.cpp
Graphics/Rect.cpp Graphics/Rect.cpp
Graphics/RectangleShape.cpp Graphics/RectangleShape.cpp

View File

@ -0,0 +1,38 @@
#include <SFML/Graphics/ConvexShape.hpp>
#include "SystemUtil.hpp"
#include <doctest.h>
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));
}
}