2015-04-28 21:37:01 +02:00
|
|
|
// Header for SFML unit tests.
|
|
|
|
//
|
2021-12-28 22:03:15 -07:00
|
|
|
// For a new system module test case, include this header.
|
2023-01-17 21:51:08 -07:00
|
|
|
// This ensures that string conversions are visible and can be used by Catch2 for debug output.
|
2015-04-28 21:37:01 +02:00
|
|
|
|
2022-12-20 20:17:38 -08:00
|
|
|
#pragma once
|
2018-08-19 01:30:53 +02:00
|
|
|
|
2023-04-13 15:50:19 +02:00
|
|
|
#include <iosfwd>
|
2015-04-28 21:37:01 +02:00
|
|
|
|
2023-01-17 21:51:08 -07:00
|
|
|
// String conversions for Catch2
|
2015-04-28 21:37:01 +02:00
|
|
|
namespace sf
|
|
|
|
{
|
2022-07-04 11:20:58 -05:00
|
|
|
class Angle;
|
|
|
|
class String;
|
|
|
|
class Time;
|
2015-04-28 21:37:01 +02:00
|
|
|
|
2023-04-13 15:50:19 +02:00
|
|
|
template <typename>
|
|
|
|
class Vector2;
|
|
|
|
|
|
|
|
template <typename>
|
|
|
|
class Vector3;
|
|
|
|
|
|
|
|
void setStreamPrecision(std::ostream& os, int maxDigits10);
|
|
|
|
|
2022-07-04 23:46:34 -06:00
|
|
|
std::ostream& operator<<(std::ostream& os, const Angle& angle);
|
|
|
|
std::ostream& operator<<(std::ostream& os, const String& string);
|
|
|
|
std::ostream& operator<<(std::ostream& os, Time time);
|
2015-04-28 21:37:01 +02:00
|
|
|
|
2022-07-04 11:20:58 -05:00
|
|
|
template <typename T>
|
2023-04-13 15:50:19 +02:00
|
|
|
std::ostream& operator<<(std::ostream& os, const Vector2<T>& vector);
|
2015-04-28 21:37:01 +02:00
|
|
|
|
2022-07-04 11:20:58 -05:00
|
|
|
template <typename T>
|
2023-04-13 15:50:19 +02:00
|
|
|
std::ostream& operator<<(std::ostream& os, const Vector3<T>& vector);
|
2022-07-04 11:20:58 -05:00
|
|
|
} // namespace sf
|
2015-04-28 21:37:01 +02:00
|
|
|
|
2022-05-02 16:38:33 -06:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Class template for creating custom approximate comparisons.
|
|
|
|
/// To register a new type, simply implement a custom operator==
|
|
|
|
/// overload for that type.
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
template <typename T>
|
|
|
|
struct Approx
|
2022-02-17 17:22:00 +01:00
|
|
|
{
|
2022-07-04 11:20:58 -05:00
|
|
|
explicit Approx(const T& t) : value(t)
|
|
|
|
{
|
|
|
|
}
|
2023-04-13 15:50:19 +02:00
|
|
|
|
2022-05-02 16:38:33 -06:00
|
|
|
const T& value;
|
2022-02-17 17:22:00 +01:00
|
|
|
};
|
|
|
|
|
2022-05-02 16:38:33 -06:00
|
|
|
bool operator==(const float& lhs, const Approx<float>& rhs);
|
2023-04-13 15:50:19 +02:00
|
|
|
bool operator==(const sf::Vector2<float>& lhs, const Approx<sf::Vector2<float>>& rhs);
|
|
|
|
bool operator==(const sf::Vector3<float>& lhs, const Approx<sf::Vector3<float>>& rhs);
|
2022-05-02 16:38:33 -06:00
|
|
|
bool operator==(const sf::Angle& lhs, const Approx<sf::Angle>& rhs);
|
2022-05-04 18:03:26 +01:00
|
|
|
|
2022-05-02 16:38:33 -06:00
|
|
|
template <typename T>
|
2023-09-27 22:27:20 -06:00
|
|
|
std::ostream& operator<<(std::ostream& os, const Approx<T>& approx)
|
|
|
|
{
|
|
|
|
return os << approx.value;
|
|
|
|
}
|