diff --git a/test/from_chars_float.cpp b/test/from_chars_float.cpp index 5dd36c7cc..e481f02f8 100644 --- a/test/from_chars_float.cpp +++ b/test/from_chars_float.cpp @@ -17,7 +17,7 @@ template void spot_value(const std::string& buffer, T expected_value, boost::charconv::chars_format fmt = boost::charconv::chars_format::general) { - T v = 0; + T v; auto r = boost::charconv::from_chars(buffer.c_str(), buffer.c_str() + std::strlen(buffer.c_str()), v, fmt); BOOST_TEST(r.ec == std::errc()); if (!BOOST_TEST_EQ(v, expected_value)) @@ -55,13 +55,13 @@ template void simple_integer_test() { const char* buffer1 = "12"; - T v1 = 0; + T v1; auto r1 = boost::charconv::from_chars(buffer1, buffer1 + std::strlen(buffer1), v1); BOOST_TEST(r1.ec == std::errc()); BOOST_TEST_EQ(v1, static_cast(12)); const char* buffer2 = "1200"; - T v2 = 0; + T v2; auto r2 = boost::charconv::from_chars(buffer2, buffer2 + std::strlen(buffer2), v2); BOOST_TEST(r2.ec == std::errc()); BOOST_TEST_EQ(v2, static_cast(1200)); @@ -71,7 +71,7 @@ template void simple_hex_integer_test() { const char* buffer1 = "-2a"; - T v1 = 0; + T v1; auto r1 = boost::charconv::from_chars(buffer1, buffer1 + std::strlen(buffer1), v1, boost::charconv::chars_format::hex); BOOST_TEST(r1.ec == std::errc()); BOOST_TEST_EQ(v1, static_cast(-42)); @@ -81,25 +81,25 @@ template void simple_scientific_test() { const char* buffer1 = "1e1"; - T v1 = 0; + T v1; auto r1 = boost::charconv::from_chars(buffer1, buffer1 + std::strlen(buffer1), v1); BOOST_TEST(r1.ec == std::errc()); BOOST_TEST_EQ(v1, static_cast(1e1L)); const char* buffer2 = "123456789e10"; - T v2 = 0; + T v2; auto r2 = boost::charconv::from_chars(buffer2, buffer2 + std::strlen(buffer2), v2); BOOST_TEST(r2.ec == std::errc()); BOOST_TEST_EQ(v2, static_cast(123456789e10L)); const char* buffer3 = "1.23456789e+10"; - T v3 = 0; + T v3; auto r3 = boost::charconv::from_chars(buffer3, buffer3 + std::strlen(buffer3), v3); BOOST_TEST(r3.ec == std::errc()); BOOST_TEST_EQ(v3, static_cast(1.23456789e+10L)); const char* buffer4 = "1234.56789e+10"; - T v4 = 0; + T v4; auto r4 = boost::charconv::from_chars(buffer4, buffer4 + std::strlen(buffer4), v4); BOOST_TEST(r4.ec == std::errc()); BOOST_TEST_EQ(v4, static_cast(1234.56789e+10L)); @@ -115,13 +115,13 @@ template void simple_hex_scientific_test() { const char* buffer1 = "1.3a2bp-10"; - T v1 = 0; + T v1; auto r1 = boost::charconv::from_chars(buffer1, buffer1 + std::strlen(buffer1), v1, boost::charconv::chars_format::hex); BOOST_TEST(r1.ec == std::errc()); BOOST_TEST_EQ(v1, static_cast(80427e-14L)); const char* buffer2 = "1.234p-10"; - T v2 = 0; + T v2; auto r2 = boost::charconv::from_chars(buffer2, buffer2 + std::strlen(buffer2), v2, boost::charconv::chars_format::hex); BOOST_TEST(r2.ec == std::errc()); BOOST_TEST_EQ(v2, static_cast(4660e-13L)); @@ -131,25 +131,25 @@ template void dot_position_test() { const char* buffer1 = "11.11111111"; - T v1 = 0; + T v1; auto r1 = boost::charconv::from_chars(buffer1, buffer1 + std::strlen(buffer1), v1); BOOST_TEST(r1.ec == std::errc()); BOOST_TEST_EQ(v1, static_cast(11.11111111L)); const char* buffer2 = "1111.111111"; - T v2 = 0; + T v2; auto r2 = boost::charconv::from_chars(buffer2, buffer2 + std::strlen(buffer2), v2); BOOST_TEST(r2.ec == std::errc()); BOOST_TEST_EQ(v2, static_cast(1111.111111L)); const char* buffer3 = "111111.1111"; - T v3 = 0; + T v3; auto r3 = boost::charconv::from_chars(buffer3, buffer3 + std::strlen(buffer3), v3); BOOST_TEST(r3.ec == std::errc()); BOOST_TEST_EQ(v3, static_cast(111111.1111L)); const char* buffer4 = "1111111111."; - T v4 = 0; + T v4; auto r4 = boost::charconv::from_chars(buffer4, buffer4 + std::strlen(buffer4), v4); BOOST_TEST(r4.ec == std::errc()); BOOST_TEST_EQ(v4, static_cast(1111111111.L)); @@ -159,37 +159,37 @@ template void odd_strings_test() { const char* buffer1 = "00000000000000000000000000000000000000000005"; - T v1 = 0; + T v1; auto r1 = boost::charconv::from_chars(buffer1, buffer1 + std::strlen(buffer1), v1); BOOST_TEST(r1.ec == std::errc()); BOOST_TEST_EQ(v1, static_cast(5)); const char* buffer2 = "123456789123456789123456789"; - T v2 = 0; + T v2; auto r2 = boost::charconv::from_chars(buffer2, buffer2 + std::strlen(buffer2), v2); BOOST_TEST(r2.ec == std::errc()); BOOST_TEST_EQ(v2, static_cast(1.23456789123456789123456789e26L)); const char* buffer3 = "100000000000000000000000e5"; - T v3 = 0; + T v3; auto r3 = boost::charconv::from_chars(buffer3, buffer3 + std::strlen(buffer3), v3); BOOST_TEST(r3.ec == std::errc()); BOOST_TEST_EQ(v3, static_cast(100000000000000000000000e5L)); const char* buffer4 = "1.23456789123456789123456789123456789123456789e-5"; - T v4 = 0; + T v4; auto r4 = boost::charconv::from_chars(buffer4, buffer4 + std::strlen(buffer4), v4); BOOST_TEST(r4.ec == std::errc()); BOOST_TEST_EQ(v4, static_cast(1.23456789123456789123456789123456789123456789e-5L)); const char* buffer5 = "1.23456789123456789123456789123456789123456789e-00000000000000000005"; - T v5 = 0; + T v5; auto r5 = boost::charconv::from_chars(buffer5, buffer5 + std::strlen(buffer5), v5); BOOST_TEST(r5.ec == std::errc()); BOOST_TEST_EQ(v5, static_cast(1.23456789123456789123456789123456789123456789e-5L)); const char* buffer6 = "E01"; - T v6 = 0; + T v6; auto r6 = boost::charconv::from_chars(buffer6, buffer6 + std::strlen(buffer6), v6); BOOST_TEST(r6.ec == std::errc::invalid_argument); } @@ -198,42 +198,42 @@ template void zero_test() { const char* buffer1 = "0e0"; - T v1 = 0; + T v1; auto r1 = boost::charconv::from_chars(buffer1, buffer1 + std::strlen(buffer1), v1); BOOST_TEST(r1.ec == std::errc()); BOOST_TEST_EQ(v1, static_cast(0)); BOOST_TEST(!std::signbit(v1)); const char* buffer2 = "-0e0"; - T v2 = 0; + T v2; auto r2 = boost::charconv::from_chars(buffer2, buffer2 + std::strlen(buffer2), v2); BOOST_TEST(r2.ec == std::errc()); BOOST_TEST_EQ(v2, static_cast(-0)); BOOST_TEST(std::signbit(v2)); const char* buffer3 = "0.0"; - T v3 = 0; + T v3; auto r3 = boost::charconv::from_chars(buffer3, buffer3 + std::strlen(buffer3), v3); BOOST_TEST(r3.ec == std::errc()); BOOST_TEST_EQ(v3, static_cast(0.0)); BOOST_TEST(!std::signbit(v3)); const char* buffer4 = "-0.0"; - T v4 = 0; + T v4; auto r4 = boost::charconv::from_chars(buffer4, buffer4 + std::strlen(buffer4), v4); BOOST_TEST(r4.ec == std::errc()); BOOST_TEST_EQ(v4, static_cast(-0)); BOOST_TEST(std::signbit(v4)); const char* buffer5 = "0"; - T v5 = 0; + T v5; auto r5 = boost::charconv::from_chars(buffer5, buffer5 + std::strlen(buffer5), v5); BOOST_TEST(r5.ec == std::errc()); BOOST_TEST_EQ(v5, static_cast(0)); BOOST_TEST(!std::signbit(v5)); const char* buffer6 = "-0"; - T v6 = 0; + T v6; auto r6 = boost::charconv::from_chars(buffer6, buffer6 + std::strlen(buffer6), v6); BOOST_TEST(r6.ec == std::errc()); BOOST_TEST_EQ(v6, static_cast(-0));