From e44a4b305dca82a36eb10db7994a58eea6efd810 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 4 Jul 2022 23:57:04 -0600 Subject: [PATCH] Simplify `operator<<` implementations --- test/TestUtilities/GraphicsUtil.cpp | 16 ++++++---------- test/TestUtilities/SystemUtil.cpp | 9 +++------ test/TestUtilities/SystemUtil.hpp | 6 ++---- test/TestUtilities/WindowUtil.cpp | 3 +-- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/test/TestUtilities/GraphicsUtil.cpp b/test/TestUtilities/GraphicsUtil.cpp index 3a2d55b71..7f36dcfb3 100644 --- a/test/TestUtilities/GraphicsUtil.cpp +++ b/test/TestUtilities/GraphicsUtil.cpp @@ -9,19 +9,16 @@ namespace sf { std::ostream& operator<<(std::ostream& os, const BlendMode& blendMode) { - os << "( " << blendMode.colorSrcFactor << ", " << blendMode.colorDstFactor << ", " << blendMode.colorEquation << ", " - << blendMode.alphaSrcFactor << ", " << blendMode.alphaDstFactor << ", " << blendMode.alphaEquation << " )"; - - return os; + return os << "( " << blendMode.colorSrcFactor << ", " << blendMode.colorDstFactor << ", " << blendMode.colorEquation + << ", " << blendMode.alphaSrcFactor << ", " << blendMode.alphaDstFactor << ", " << blendMode.alphaEquation + << " )"; } std::ostream& operator<<(std::ostream& os, const Color& color) { - os << "0x" << std::hex << color.toInteger() << std::dec << " (r=" << static_cast(color.r) - << ", g=" << static_cast(color.g) << ", b=" << static_cast(color.b) - << ", a=" << static_cast(color.a) << ")"; - - return os; + return os << "0x" << std::hex << color.toInteger() << std::dec << " (r=" << static_cast(color.r) + << ", g=" << static_cast(color.g) << ", b=" << static_cast(color.b) + << ", a=" << static_cast(color.a) << ")"; } std::ostream& operator<<(std::ostream& os, const Transform& transform) @@ -30,7 +27,6 @@ std::ostream& operator<<(std::ostream& os, const Transform& transform) os << matrix[0] << ", " << matrix[4] << ", " << matrix[12] << ", "; os << matrix[1] << ", " << matrix[5] << ", " << matrix[13] << ", "; os << matrix[3] << ", " << matrix[7] << ", " << matrix[15]; - return os; } } // namespace sf diff --git a/test/TestUtilities/SystemUtil.cpp b/test/TestUtilities/SystemUtil.cpp index 63b00b8cb..2c7a349e7 100644 --- a/test/TestUtilities/SystemUtil.cpp +++ b/test/TestUtilities/SystemUtil.cpp @@ -11,20 +11,17 @@ namespace sf std::ostream& operator<<(std::ostream& os, const Angle& angle) { os << std::fixed << std::setprecision(std::numeric_limits::max_digits10); - os << angle.asDegrees() << " deg"; - return os; + return os << angle.asDegrees() << " deg"; } std::ostream& operator<<(std::ostream& os, const String& string) { - os << string.toAnsiString(); - return os; + return os << string.toAnsiString(); } std::ostream& operator<<(std::ostream& os, Time time) { - os << time.asMicroseconds() << "us"; - return os; + return os << time.asMicroseconds() << "us"; } } // namespace sf diff --git a/test/TestUtilities/SystemUtil.hpp b/test/TestUtilities/SystemUtil.hpp index d66c1f433..764b42c16 100644 --- a/test/TestUtilities/SystemUtil.hpp +++ b/test/TestUtilities/SystemUtil.hpp @@ -28,15 +28,13 @@ template std::ostream& operator<<(std::ostream& os, const Vector2& vector) { os << std::fixed << std::setprecision(std::numeric_limits::max_digits10); - os << "(" << vector.x << ", " << vector.y << ")"; - return os; + return os << "(" << vector.x << ", " << vector.y << ")"; } template std::ostream& operator<<(std::ostream& os, const Vector3& vector) { - os << "(" << vector.x << ", " << vector.y << ", " << vector.z << ")"; - return os; + return os << "(" << vector.x << ", " << vector.y << ", " << vector.z << ")"; } } // namespace sf diff --git a/test/TestUtilities/WindowUtil.cpp b/test/TestUtilities/WindowUtil.cpp index 9ff003476..13053e1f6 100644 --- a/test/TestUtilities/WindowUtil.cpp +++ b/test/TestUtilities/WindowUtil.cpp @@ -7,7 +7,6 @@ namespace sf { std::ostream& operator<<(std::ostream& os, const VideoMode& videoMode) { - os << videoMode.size.x << "x" << videoMode.size.y << "x" << videoMode.bitsPerPixel; - return os; + return os << videoMode.size.x << "x" << videoMode.size.y << "x" << videoMode.bitsPerPixel; } } // namespace sf