SFML/test/Graphics/ConvexShape.test.cpp

49 lines
1.3 KiB
C++
Raw Normal View History

2022-06-02 13:12:48 +08:00
#include <SFML/Graphics/ConvexShape.hpp>
2023-01-18 12:51:08 +08:00
#include <catch2/catch_test_macros.hpp>
2022-06-02 13:12:48 +08:00
2022-07-05 00:20:58 +08:00
#include <SystemUtil.hpp>
#include <type_traits>
TEST_CASE("[Graphics] sf::ConvexShape")
2022-06-02 13:12:48 +08:00
{
2023-01-18 12:51:08 +08:00
SECTION("Type traits")
{
STATIC_CHECK(std::is_copy_constructible_v<sf::ConvexShape>);
STATIC_CHECK(std::is_copy_assignable_v<sf::ConvexShape>);
STATIC_CHECK(std::is_nothrow_move_constructible_v<sf::ConvexShape>);
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::ConvexShape>);
}
SECTION("Default constructor")
2022-06-02 13:12:48 +08:00
{
const sf::ConvexShape convex;
CHECK(convex.getPointCount() == 0);
}
2023-01-18 12:51:08 +08:00
SECTION("Point count constructor")
2022-06-02 13:12:48 +08:00
{
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));
}
2023-01-18 12:51:08 +08:00
SECTION("Set point count")
2022-06-02 13:12:48 +08:00
{
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));
}
2023-01-18 12:51:08 +08:00
SECTION("Set point")
2022-06-02 13:12:48 +08:00
{
sf::ConvexShape convex;
convex.setPointCount(1);
convex.setPoint(0, {3, 4});
CHECK(convex.getPoint(0) == sf::Vector2f(3, 4));
}
}