2015-04-29 03:37:01 +08:00
|
|
|
// Header for SFML unit tests.
|
|
|
|
//
|
2021-12-24 21:31:27 +08:00
|
|
|
// For a new system module test case, include this header and not <doctest.h> directly.
|
|
|
|
// This ensures that string conversions are visible and can be used by doctest for debug output.
|
2015-04-29 03:37:01 +08:00
|
|
|
|
2018-08-19 07:30:53 +08:00
|
|
|
#ifndef SFML_TESTUTILITIES_SYSTEM_HPP
|
|
|
|
#define SFML_TESTUTILITIES_SYSTEM_HPP
|
|
|
|
|
2021-12-24 21:31:27 +08:00
|
|
|
#include <doctest.h>
|
2015-04-29 03:37:01 +08:00
|
|
|
|
|
|
|
#include <SFML/System/Vector2.hpp>
|
|
|
|
#include <SFML/System/Vector3.hpp>
|
|
|
|
#include <sstream>
|
|
|
|
|
2021-12-24 21:31:27 +08:00
|
|
|
// String conversions for doctest framework
|
2015-04-29 03:37:01 +08:00
|
|
|
namespace sf
|
|
|
|
{
|
|
|
|
class String;
|
|
|
|
class Time;
|
|
|
|
|
2021-12-24 21:31:27 +08:00
|
|
|
doctest::String toString(const sf::String& string);
|
|
|
|
doctest::String toString(sf::Time time);
|
2015-04-29 03:37:01 +08:00
|
|
|
|
|
|
|
template <typename T>
|
2021-12-24 21:31:27 +08:00
|
|
|
doctest::String toString(const sf::Vector2<T>& vector)
|
2015-04-29 03:37:01 +08:00
|
|
|
{
|
|
|
|
std::ostringstream stream;
|
|
|
|
stream << "(" << vector.x << ", " << vector.y << ")";
|
2021-12-24 21:31:27 +08:00
|
|
|
return stream.str().c_str();
|
2015-04-29 03:37:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2021-12-24 21:31:27 +08:00
|
|
|
doctest::String toString(const sf::Vector3<T>& vector)
|
2015-04-29 03:37:01 +08:00
|
|
|
{
|
|
|
|
std::ostringstream stream;
|
|
|
|
stream << "(" << vector.x << ", " << vector.y << ", " << vector.z << ")";
|
2021-12-24 21:31:27 +08:00
|
|
|
return stream.str().c_str();
|
2015-04-29 03:37:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 07:30:53 +08:00
|
|
|
#endif // SFML_TESTUTILITIES_SYSTEM_HPP
|