#include #include #include #include #include #include #include #include #include #include #include namespace sf { void setStreamPrecision(std::ostream& os, int maxDigits10) { os << std::fixed << std::setprecision(maxDigits10); } std::ostream& operator<<(std::ostream& os, const Angle& angle) { setStreamPrecision(os, std::numeric_limits::max_digits10); return os << angle.asDegrees() << " deg"; } std::ostream& operator<<(std::ostream& os, const String& string) { return os << string.toAnsiString(); } std::ostream& operator<<(std::ostream& os, Time time) { return os << time.asMicroseconds() << "us"; } template std::ostream& operator<<(std::ostream& os, const Vector2& vector) { setStreamPrecision(os, std::numeric_limits::max_digits10); return os << "(" << vector.x << ", " << vector.y << ")"; } template std::ostream& operator<<(std::ostream& os, const Vector3& vector) { setStreamPrecision(os, std::numeric_limits::max_digits10); return os << "(" << vector.x << ", " << vector.y << ", " << vector.z << ")"; } template std::ostream& operator<<(std::ostream&, const Vector2&); template std::ostream& operator<<(std::ostream&, const Vector2&); template std::ostream& operator<<(std::ostream&, const Vector2&); template std::ostream& operator<<(std::ostream&, const Vector3&); template std::ostream& operator<<(std::ostream&, const Vector3&); template std::ostream& operator<<(std::ostream&, const Vector3&); } // namespace sf bool operator==(const float& lhs, const Approx& rhs) { return lhs == Catch::Approx(rhs.value).margin(1e-5); } bool operator==(const sf::Vector2f& lhs, const Approx& rhs) { return (lhs - rhs.value).length() == Approx(0.f); } bool operator==(const sf::Vector3f& lhs, const Approx& rhs) { return (lhs - rhs.value).length() == Approx(0.f); } bool operator==(const sf::Angle& lhs, const Approx& rhs) { return lhs.asRadians() == Approx(rhs.value.asRadians()); } std::vector loadIntoMemory(const std::filesystem::path& path) { std::ifstream file(path, std::ios::binary | std::ios::ate); assert(file); const auto size = file.tellg(); file.seekg(0, std::ios::beg); std::vector buffer(static_cast(size)); [[maybe_unused]] const auto& result = file.read(reinterpret_cast(buffer.data()), static_cast(size)); assert(result); return buffer; }