Separated test suites into their individual modules
- Building per module only requires to have split test utility sections - System module tests are always added, as the system module is always built
This commit is contained in:
parent
7d496095a5
commit
d402ce5a5d
11 changed files with 154 additions and 73 deletions
19
test/src/TestUtilities/Graphics.cpp
Normal file
19
test/src/TestUtilities/Graphics.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Note: No need to increase compile time by including TestUtilities/Graphics.hpp
|
||||
#include <SFML/Graphics/Color.hpp>
|
||||
#include <sstream>
|
||||
|
||||
// String conversions for Catch framework
|
||||
namespace Catch
|
||||
{
|
||||
std::string toString(const sf::Color& color)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "0x" << std::hex << color.toInteger() << std::dec
|
||||
<< " (r=" << static_cast<int>(color.r)
|
||||
<< ", g=" << static_cast<int>(color.g)
|
||||
<< ", b=" << static_cast<int>(color.b)
|
||||
<< ", a=" << static_cast<int>(color.a) << ")";
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
}
|
23
test/src/TestUtilities/Graphics.hpp
Normal file
23
test/src/TestUtilities/Graphics.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Header for SFML unit tests.
|
||||
//
|
||||
// For a new graphics module test case, include this header and not <catch.hpp> directly.
|
||||
// This ensures that string conversions are visible and can be used by Catch for debug output.
|
||||
|
||||
#ifndef SFML_TESTUTILITIES_GRAPHICS_HPP
|
||||
#define SFML_TESTUTILITIES_GRAPHICS_HPP
|
||||
|
||||
#include "Window.hpp"
|
||||
|
||||
// Forward declarations for non-template types
|
||||
namespace sf
|
||||
{
|
||||
class Color;
|
||||
}
|
||||
|
||||
// String conversions for Catch framework
|
||||
namespace Catch
|
||||
{
|
||||
std::string toString(const sf::Color& color);
|
||||
}
|
||||
|
||||
#endif // SFML_TESTUTILITIES_GRAPHICS_HPP
|
20
test/src/TestUtilities/System.cpp
Normal file
20
test/src/TestUtilities/System.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Note: No need to increase compile time by including TestUtilities/System.hpp
|
||||
#include <SFML/System/String.hpp>
|
||||
#include <SFML/System/Time.hpp>
|
||||
#include <sstream>
|
||||
|
||||
// String conversions for Catch framework
|
||||
namespace Catch
|
||||
{
|
||||
std::string toString(const sf::String& string)
|
||||
{
|
||||
return string.toAnsiString();
|
||||
}
|
||||
|
||||
std::string toString(sf::Time time)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << time.asMicroseconds() << "us";
|
||||
return stream.str();
|
||||
}
|
||||
}
|
45
test/src/TestUtilities/System.hpp
Normal file
45
test/src/TestUtilities/System.hpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Header for SFML unit tests.
|
||||
//
|
||||
// For a new system module test case, include this header and not <catch.hpp> directly.
|
||||
// This ensures that string conversions are visible and can be used by Catch for debug output.
|
||||
|
||||
#ifndef SFML_TESTUTILITIES_SYSTEM_HPP
|
||||
#define SFML_TESTUTILITIES_SYSTEM_HPP
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/System/Vector3.hpp>
|
||||
#include <sstream>
|
||||
|
||||
// Forward declarations for non-template types
|
||||
namespace sf
|
||||
{
|
||||
class String;
|
||||
class Time;
|
||||
}
|
||||
|
||||
// String conversions for Catch framework
|
||||
namespace Catch
|
||||
{
|
||||
std::string toString(const sf::String& string);
|
||||
std::string toString(sf::Time time);
|
||||
|
||||
template <typename T>
|
||||
std::string toString(const sf::Vector2<T>& vector)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "(" << vector.x << ", " << vector.y << ")";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string toString(const sf::Vector3<T>& vector)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "(" << vector.x << ", " << vector.y << ", " << vector.z << ")";
|
||||
return stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SFML_TESTUTILITIES_SYSTEM_HPP
|
14
test/src/TestUtilities/Window.cpp
Normal file
14
test/src/TestUtilities/Window.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Note: No need to increase compile time by including TestUtilities/Window.hpp
|
||||
#include <SFML/Window/VideoMode.hpp>
|
||||
#include <sstream>
|
||||
|
||||
// String conversions for Catch framework
|
||||
namespace Catch
|
||||
{
|
||||
std::string toString(const sf::VideoMode& videoMode)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << videoMode.width << "x" << videoMode.height << "x" << videoMode.bitsPerPixel;
|
||||
return stream.str();
|
||||
}
|
||||
}
|
33
test/src/TestUtilities/Window.hpp
Normal file
33
test/src/TestUtilities/Window.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Header for SFML unit tests.
|
||||
//
|
||||
// For a new window module test case, include this header and not <catch.hpp> directly.
|
||||
// This ensures that string conversions are visible and can be used by Catch for debug output.
|
||||
|
||||
#ifndef SFML_TESTUTILITIES_WINDOW_HPP
|
||||
#define SFML_TESTUTILITIES_WINDOW_HPP
|
||||
|
||||
#include "System.hpp"
|
||||
|
||||
#include <SFML/Graphics/Rect.hpp>
|
||||
|
||||
// Forward declarations for non-template types
|
||||
namespace sf
|
||||
{
|
||||
class VideoMode;
|
||||
}
|
||||
|
||||
// String conversions for Catch framework
|
||||
namespace Catch
|
||||
{
|
||||
std::string toString(const sf::VideoMode& videoMode);
|
||||
|
||||
template <typename T>
|
||||
std::string toString(const sf::Rect<T>& rect)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "(left=" << rect.left << ", top=" << rect.top << ", width=" << rect.width << ", height=" << rect.height << ")";
|
||||
return stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SFML_TESTUTILITIES_WINDOW_HPP
|
Loading…
Add table
Add a link
Reference in a new issue