From 7c973896d782ae3a1a20dbb0199b7f287887c09e Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Sun, 29 Jul 2018 08:32:30 +0100 Subject: [PATCH] Delete dangerously incorrect to_string_view helpers. --- include/duckhandy/int_conv.hpp | 15 -------- test/unit/int_conv_test.cpp | 70 +++++++++++++++++----------------- 2 files changed, 35 insertions(+), 50 deletions(-) diff --git a/include/duckhandy/int_conv.hpp b/include/duckhandy/int_conv.hpp index c7970c2..84aefef 100644 --- a/include/duckhandy/int_conv.hpp +++ b/include/duckhandy/int_conv.hpp @@ -25,9 +25,6 @@ #include #include #include -#if !defined(INT_CONV_WITHOUT_HELPERS) -# include -#endif #include #if defined(__SSE4_1__) # include @@ -289,18 +286,6 @@ namespace dhandy { inline R ary_to_int (C* beg, C* end) { return implem::AryConversion::from_ary(beg, end); } - -#if !defined(INT_CONV_WITHOUT_HELPERS) - template - std::basic_string_view to_string_view (const ReversedSizedArray& ary) { - return std::basic_string_view(ary.data(), ary.size() - 1); - } - - template - std::basic_string_view to_string_view (I num) { - return std::basic_string_view(int_to_ary(num)); - } -#endif } //namespace dhandy #endif diff --git a/test/unit/int_conv_test.cpp b/test/unit/int_conv_test.cpp index 9874010..b284974 100644 --- a/test/unit/int_conv_test.cpp +++ b/test/unit/int_conv_test.cpp @@ -67,46 +67,46 @@ TEST_CASE ("Check int to char array conversions", "[s2i][int_conv]") { static_assert(int_info_10::is_signed == true, "Wrong sign detection"); static_assert(string(0xAB12).data()) + 1>(int_to_ary(0xAB12).data()) == make_string("-21742"), "Algorithm error"); - CHECK(to_string_view(int_to_ary(0x123456789A)) == "78187493530"); - CHECK(to_string_view(int_to_ary(-1)) == "-1"); - CHECK(to_string_view(int_to_ary(0x1000000000000000)) == "1152921504606846976"); - CHECK(to_string_view(int_to_ary(0xF000000000000000)) == "-1152921504606846976"); + //CHECK(to_string_view(int_to_ary(0x123456789A)) == "78187493530"); + //CHECK(to_string_view(int_to_ary(-1)) == "-1"); + //CHECK(to_string_view(int_to_ary(0x1000000000000000)) == "1152921504606846976"); + //CHECK(to_string_view(int_to_ary(0xF000000000000000)) == "-1152921504606846976"); - CHECK(to_string_view(int_to_ary(0xFFFF)) == "ffff"); - CHECK(to_string_view(int_to_ary(0xCACA)) == "caca"); - CHECK(to_string_view(int_to_ary(0x10)) == "10"); - CHECK(to_string_view(int_to_ary(0x10)) == "10"); - CHECK(to_string_view(int_to_ary(0xF000)) == "f000"); - CHECK(to_string_view(int_to_ary(0xFEFE)) == "fefe"); - CHECK(to_string_view(int_to_ary(0xFEFE)) == "fefe"); - CHECK(to_string_view(int_to_ary(0423)) == "423"); - CHECK(to_string_view(int_to_ary(0777)) == "777"); - CHECK(to_string_view(int_to_ary(0)) == "0"); - CHECK(to_string_view(int_to_ary(0)) == "0"); - CHECK(to_string_view(int_to_ary(0)) == "0"); - CHECK(to_string_view(int_to_ary(0)) == "0"); - CHECK(to_string_view(int_to_ary(0)) == "0"); - CHECK(to_string_view(int_to_ary(0)) == "0"); - CHECK(to_string_view(int_to_ary(0)) == "0"); - CHECK(to_string_view(int_to_ary(0)) == "0"); - CHECK(to_string_view(int_to_ary(false)) == "0"); - CHECK(to_string_view(int_to_ary(true)) == "1"); - CHECK(to_string_view(int_to_ary(false)) == "0"); - CHECK(to_string_view(int_to_ary(true)) == "1"); - CHECK(to_string_view(int_to_ary(0b10101010)) == "10101010"); - CHECK(to_string_view(int_to_ary(0b10101010)) == "10101010"); - CHECK(to_string_view(int_to_ary(0b11111111)) == "11111111"); - CHECK(to_string_view(int_to_ary(0b11111111)) == "11111111"); - CHECK(to_string_view(int_to_ary(0b111100001111)) == "111100001111"); - CHECK(to_string_view(int_to_ary(0b111100001111)) == "111100001111"); - CHECK(to_string_view(int_to_ary(9223372036854775807)) == "1y2p0ij32e8e7"); - CHECK(to_string_view(int_to_ary(0x8000000000000001)) == "1y2p0ij32e8e9"); + //CHECK(to_string_view(int_to_ary(0xFFFF)) == "ffff"); + //CHECK(to_string_view(int_to_ary(0xCACA)) == "caca"); + //CHECK(to_string_view(int_to_ary(0x10)) == "10"); + //CHECK(to_string_view(int_to_ary(0x10)) == "10"); + //CHECK(to_string_view(int_to_ary(0xF000)) == "f000"); + //CHECK(to_string_view(int_to_ary(0xFEFE)) == "fefe"); + //CHECK(to_string_view(int_to_ary(0xFEFE)) == "fefe"); + //CHECK(to_string_view(int_to_ary(0423)) == "423"); + //CHECK(to_string_view(int_to_ary(0777)) == "777"); + //CHECK(to_string_view(int_to_ary(0)) == "0"); + //CHECK(to_string_view(int_to_ary(0)) == "0"); + //CHECK(to_string_view(int_to_ary(0)) == "0"); + //CHECK(to_string_view(int_to_ary(0)) == "0"); + //CHECK(to_string_view(int_to_ary(0)) == "0"); + //CHECK(to_string_view(int_to_ary(0)) == "0"); + //CHECK(to_string_view(int_to_ary(0)) == "0"); + //CHECK(to_string_view(int_to_ary(0)) == "0"); + //CHECK(to_string_view(int_to_ary(false)) == "0"); + //CHECK(to_string_view(int_to_ary(true)) == "1"); + //CHECK(to_string_view(int_to_ary(false)) == "0"); + //CHECK(to_string_view(int_to_ary(true)) == "1"); + //CHECK(to_string_view(int_to_ary(0b10101010)) == "10101010"); + //CHECK(to_string_view(int_to_ary(0b10101010)) == "10101010"); + //CHECK(to_string_view(int_to_ary(0b11111111)) == "11111111"); + //CHECK(to_string_view(int_to_ary(0b11111111)) == "11111111"); + //CHECK(to_string_view(int_to_ary(0b111100001111)) == "111100001111"); + //CHECK(to_string_view(int_to_ary(0b111100001111)) == "111100001111"); + //CHECK(to_string_view(int_to_ary(9223372036854775807)) == "1y2p0ij32e8e7"); + //CHECK(to_string_view(int_to_ary(0x8000000000000001)) == "1y2p0ij32e8e9"); #if defined(__GNUC__) static_assert(std::is_integral<__int128_t>::value, "Warning, int128 won't pickup the optimized base 10 conversion path"); __int128_t num = 10000000000000000000U; - CHECK(to_string_view(int_to_ary<__int128_t, 10>(num * 100)) == "1000000000000000000000"); + //CHECK(to_string_view(int_to_ary<__int128_t, 10>(num * 100)) == "1000000000000000000000"); num = 0xFFFFFFFFFFFFFFFF; - CHECK(to_string_view(int_to_ary<__int128_t, 16>(num * 0x10000 + 0xffff)) == "ffffffffffffffffffff"); + //CHECK(to_string_view(int_to_ary<__int128_t, 16>(num * 0x10000 + 0xffff)) == "ffffffffffffffffffff"); #endif }