From c516a6f826c31ebaf8969501296ae6a2ac423176 Mon Sep 17 00:00:00 2001 From: ado Date: Mon, 26 Feb 2024 02:37:30 +0100 Subject: [PATCH] Fix extraction tests --- test/test_extractions.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/test/test_extractions.cpp b/test/test_extractions.cpp index 1765809..88ec317 100644 --- a/test/test_extractions.cpp +++ b/test/test_extractions.cpp @@ -2,15 +2,31 @@ #include #include -template -struct std::numeric_limits> - : public std::numeric_limits {}; +namespace { template -struct std::is_signed> : public std::is_signed {}; +struct numeric_limits : public std::numeric_limits {}; template -struct std::is_unsigned> : public std::is_unsigned {}; +struct numeric_limits> : public std::numeric_limits { +}; + +template +struct is_signed : public std::is_signed {}; + +template <> +struct is_signed : public std::true_type {}; + +template +struct is_unsigned : public std::is_unsigned {}; + +template <> +struct is_unsigned : public std::true_type {}; + +} /* namespace */ + +static_assert(is_signed::value); +static_assert(is_unsigned::value); TEST_CASE("testing extract functions for floating point values") { CHECK_FLOATING_CONVERSION(123.456, float); @@ -38,7 +54,7 @@ TEST_CASE("testing extract functions for floating point values") { CHECK_EQ(value, type(input)); \ } \ /* check negative too */ \ - if (std::is_signed_v) { \ + if (is_signed::value) { \ std::string s = std::string("-") + #input; \ type value; \ bool valid = ss::extract(s.c_str(), s.c_str() + s.size(), value); \ @@ -89,7 +105,7 @@ TEST_CASE_TEMPLATE( "extract test functions for numbers with out of range inputs", T, short, us, int, ui, long, ul, ll, ull, ss::uint8) { { - std::string s = std::to_string(std::numeric_limits::max()); + std::string s = std::to_string(numeric_limits::max()); auto t = ss::to_num(s.c_str(), s.c_str() + s.size()); CHECK(t.has_value()); for (auto& i : s) { @@ -102,14 +118,14 @@ TEST_CASE_TEMPLATE( CHECK_FALSE(t.has_value()); } { - std::string s = std::to_string(std::numeric_limits::min()); + std::string s = std::to_string(numeric_limits::min()); auto t = ss::to_num(s.c_str(), s.c_str() + s.size()); CHECK(t.has_value()); for (auto& i : s) { - if (std::is_signed_v && i != '9' && i != '.') { + if (is_signed::value && i != '9' && i != '.') { i = '9'; break; - } else if (std::is_unsigned_v) { + } else if (is_unsigned::value) { s = "-1"; break; }