From 45986c6400d11c29c47511e5962465ed8a12c3a8 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Tue, 28 Jun 2022 12:13:32 -0600 Subject: [PATCH] Avoid opening namespace std --- test/Graphics/Transform.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/test/Graphics/Transform.cpp b/test/Graphics/Transform.cpp index baf5fd63..33c4d129 100644 --- a/test/Graphics/Transform.cpp +++ b/test/Graphics/Transform.cpp @@ -4,19 +4,26 @@ #include #include +#include #include -namespace std +// Use StringMaker to avoid opening namespace std +namespace doctest { -std::ostream& operator<<(std::ostream& out, const std::vector& vector) +template <> +struct StringMaker> { - out << "{ "; - for (size_t i = 0; i + 1 < vector.size(); ++i) - out << vector[i] << ", "; - out << vector.back() << " }"; - return out; -} -} // namespace std + static String convert(const std::vector& vector) + { + assert(!vector.empty()); + doctest::String out = "{ "; + for (size_t i = 0; i + 1 < vector.size(); ++i) + out += toString(vector[i]) + ", "; + out += toString(vector.back()) + " }"; + return out; + } +}; +} // namespace doctest TEST_CASE("sf::Transform class - [graphics]") {