SFML/test/src/TestUtilities/System.hpp
Lukas Dürrenberger d402ce5a5d 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
2019-02-19 10:16:38 +01:00

46 lines
1.1 KiB
C++

// 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