mirror of
https://github.com/SFML/SFML.git
synced 2025-01-19 15:55:13 +08:00
Add tests for sf::Vertex
This commit is contained in:
parent
7d47e740bb
commit
6c816aba44
@ -33,6 +33,7 @@ if(SFML_BUILD_GRAPHICS)
|
|||||||
SET(GRAPHICS_SRC
|
SET(GRAPHICS_SRC
|
||||||
"${SRCROOT}/Graphics/Color.cpp"
|
"${SRCROOT}/Graphics/Color.cpp"
|
||||||
"${SRCROOT}/Graphics/Rect.cpp"
|
"${SRCROOT}/Graphics/Rect.cpp"
|
||||||
|
"${SRCROOT}/Graphics/Vertex.cpp"
|
||||||
"${SRCROOT}/TestUtilities/GraphicsUtil.hpp"
|
"${SRCROOT}/TestUtilities/GraphicsUtil.hpp"
|
||||||
"${SRCROOT}/TestUtilities/GraphicsUtil.cpp"
|
"${SRCROOT}/TestUtilities/GraphicsUtil.cpp"
|
||||||
)
|
)
|
||||||
|
56
test/Graphics/Vertex.cpp
Normal file
56
test/Graphics/Vertex.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include <SFML/Graphics/Vertex.hpp>
|
||||||
|
#include "GraphicsUtil.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("sf::Vertex class - [graphics]")
|
||||||
|
{
|
||||||
|
SUBCASE("Construction")
|
||||||
|
{
|
||||||
|
SUBCASE("Default constructor")
|
||||||
|
{
|
||||||
|
const sf::Vertex vertex;
|
||||||
|
CHECK(vertex.position == sf::Vector2f(0.0f, 0.0f));
|
||||||
|
CHECK(vertex.color == sf::Color(255, 255, 255));
|
||||||
|
CHECK(vertex.texCoords == sf::Vector2f(0.0f, 0.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("Position constructor")
|
||||||
|
{
|
||||||
|
const sf::Vertex vertex({1, 2});
|
||||||
|
CHECK(vertex.position == sf::Vector2f(1.0f, 2.0f));
|
||||||
|
CHECK(vertex.color == sf::Color(255, 255, 255));
|
||||||
|
CHECK(vertex.texCoords == sf::Vector2f(0.0f, 0.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("Position and color constructor")
|
||||||
|
{
|
||||||
|
const sf::Vertex vertex({1, 2}, {3, 4, 5, 6});
|
||||||
|
CHECK(vertex.position == sf::Vector2f(1.0f, 2.0f));
|
||||||
|
CHECK(vertex.color == sf::Color(3, 4, 5, 6));
|
||||||
|
CHECK(vertex.texCoords == sf::Vector2f(0.0f, 0.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("Position and coords constructor")
|
||||||
|
{
|
||||||
|
const sf::Vertex vertex({1, 2}, {3, 4});
|
||||||
|
CHECK(vertex.position == sf::Vector2f(1.0f, 2.0f));
|
||||||
|
CHECK(vertex.color == sf::Color(255, 255, 255));
|
||||||
|
CHECK(vertex.texCoords == sf::Vector2f(3.0f, 4.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("Position, color, and coords constructor")
|
||||||
|
{
|
||||||
|
const sf::Vertex vertex({1, 2}, {3, 4, 5, 6}, {7, 8});
|
||||||
|
CHECK(vertex.position == sf::Vector2f(1.0f, 2.0f));
|
||||||
|
CHECK(vertex.color == sf::Color(3, 4, 5, 6));
|
||||||
|
CHECK(vertex.texCoords == sf::Vector2f(7.0f, 8.0f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("Constexpr support")
|
||||||
|
{
|
||||||
|
constexpr sf::Vertex vertex({1, 2}, {3, 4, 5, 6}, {7, 8});
|
||||||
|
static_assert(vertex.position == sf::Vector2f(1.0f, 2.0f));
|
||||||
|
static_assert(vertex.color == sf::Color(3, 4, 5, 6));
|
||||||
|
static_assert(vertex.texCoords == sf::Vector2f(7.0f, 8.0f));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user