From 12aaa4d08a4741971786d3237bbf73289cefc361 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sat, 3 Sep 2022 17:47:52 -0600 Subject: [PATCH] Use macros for test abstractions to preserve line number information --- test/Network/Packet.cpp | 50 ++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/test/Network/Packet.cpp b/test/Network/Packet.cpp index c726a1e54..19bd0fb1d 100644 --- a/test/Network/Packet.cpp +++ b/test/Network/Packet.cpp @@ -4,15 +4,15 @@ #include -template -static void testPacketStreamOperators(IntegerType expected) -{ - sf::Packet packet; - packet << expected; - IntegerType received; - packet >> received; - CHECK(expected == received); -} +#define CHECK_PACKET_STREAM_OPERATORS(expected) \ + do \ + { \ + sf::Packet packet; \ + packet << expected; \ + decltype(expected) received; \ + packet >> received; \ + CHECK(expected == received); \ + } while (false) TEST_CASE("sf::Packet class - [network]") { @@ -20,34 +20,34 @@ TEST_CASE("sf::Packet class - [network]") { SUBCASE("std::int8_t") { - testPacketStreamOperators(std::int8_t(0)); - testPacketStreamOperators(std::int8_t(1)); - testPacketStreamOperators(std::numeric_limits::min()); - testPacketStreamOperators(std::numeric_limits::max()); + CHECK_PACKET_STREAM_OPERATORS(std::int8_t(0)); + CHECK_PACKET_STREAM_OPERATORS(std::int8_t(1)); + CHECK_PACKET_STREAM_OPERATORS(std::numeric_limits::min()); + CHECK_PACKET_STREAM_OPERATORS(std::numeric_limits::max()); } SUBCASE("std::int16_t") { - testPacketStreamOperators(std::int16_t(0)); - testPacketStreamOperators(std::int16_t(1)); - testPacketStreamOperators(std::numeric_limits::min()); - testPacketStreamOperators(std::numeric_limits::max()); + CHECK_PACKET_STREAM_OPERATORS(std::int16_t(0)); + CHECK_PACKET_STREAM_OPERATORS(std::int16_t(1)); + CHECK_PACKET_STREAM_OPERATORS(std::numeric_limits::min()); + CHECK_PACKET_STREAM_OPERATORS(std::numeric_limits::max()); } SUBCASE("std::int32_t") { - testPacketStreamOperators(std::int32_t(0)); - testPacketStreamOperators(std::int32_t(1)); - testPacketStreamOperators(std::numeric_limits::min()); - testPacketStreamOperators(std::numeric_limits::max()); + CHECK_PACKET_STREAM_OPERATORS(std::int32_t(0)); + CHECK_PACKET_STREAM_OPERATORS(std::int32_t(1)); + CHECK_PACKET_STREAM_OPERATORS(std::numeric_limits::min()); + CHECK_PACKET_STREAM_OPERATORS(std::numeric_limits::max()); } SUBCASE("std::int64_t") { - testPacketStreamOperators(std::int64_t(0)); - testPacketStreamOperators(std::int64_t(1)); - testPacketStreamOperators(std::numeric_limits::min()); - testPacketStreamOperators(std::numeric_limits::max()); + CHECK_PACKET_STREAM_OPERATORS(std::int64_t(0)); + CHECK_PACKET_STREAM_OPERATORS(std::int64_t(1)); + CHECK_PACKET_STREAM_OPERATORS(std::numeric_limits::min()); + CHECK_PACKET_STREAM_OPERATORS(std::numeric_limits::max()); } } }