diff --git a/include/etl/private/to_string_helper.h b/include/etl/private/to_string_helper.h index 189a92ab..f5cf637b 100644 --- a/include/etl/private/to_string_helper.h +++ b/include/etl/private/to_string_helper.h @@ -301,7 +301,7 @@ namespace etl // Find the integral part of the floating point T f_integral = (value < T(0.0) ? ceil(value) : floor(value)); - workspace_t integral = static_cast(f_integral); + workspace_t integral = etl::absolute(static_cast(f_integral)); // Find the fractional part of the floating point. workspace_t fractional = etl::absolute(static_cast(round((value - f_integral) * multiplier))); @@ -324,7 +324,7 @@ namespace etl //*************************************************************************** template void add_integral_denominated(T value, - typename etl::make_unsigned::type denominator, + workspace_t denominator, TIString& str, const etl::basic_format_spec& format, bool append = false) @@ -339,53 +339,73 @@ namespace etl iterator start = str.end(); + // Split to integral and fractional parts using the denominator + workspace_t integral = absolute(value) / denominator; + workspace_t fractional = absolute(value) % denominator; + + uint32_t denominator_digits = 0U; + uint32_t multiplier = 1U; + + while (multiplier < fractional) { - // split to integral and fractional parts using the denominator - T integral = value / static_cast(denominator); - T fractional = absolute(value) % denominator; + multiplier *= 10U; + ++denominator_digits; + } - // find the number of useful (non-0) digits - size_t digits = 0; - for (auto div = denominator; div >= 10; div /= 10) + etl::basic_format_spec integral_format = format; + integral_format.decimal().width(0U).precision(format.get_precision() > denominator_digits ? denominator_digits : format.get_precision()); + + etl::basic_format_spec fractional_format = integral_format; + fractional_format.width(integral_format.get_precision()).fill(type('0')).left(); + + if (fractional != 0U) + { + // Adjust the fractional with rounding. + uint32_t fractional_digits = 0U; + uint32_t multiplier = 1U; + + while (multiplier < fractional) { - // this resolution doesn't yield meaningful digits, abort here - if ((fractional % div) == 0) + multiplier *= 10U; + ++fractional_digits; + } + + // Do we need to round? + if (fractional_digits > fractional_format.get_width()) + { + uint32_t count = fractional_digits - fractional_format.get_width(); + + while (count > 0U) { - fractional /= div; - break; + // Check the last digit. + if (count == 1U) + { + // Round up? + if ((fractional % 10U) >= 5U) + { + fractional += 10U; + } + } + + fractional /= 10U; + multiplier /= 10U; + + --count; } - digits++; - } + } - etl::basic_format_spec integral_format = format; - integral_format.decimal().width(0); - etl::private_to_string::add_integral(integral, str, integral_format, true, etl::is_negative(integral)); - - // consider user-supplied minimum resolution - digits = max(digits, size_t(format.get_precision())); - if (digits) + // Check for a rounding carry to the integral. + if (fractional == multiplier) { - str.push_back(type('.')); - etl::basic_format_spec fractional_format = integral_format; - fractional_format.width(digits).fill(type('0')).right(); - etl::private_to_string::add_integral(fractional, str, fractional_format, true, false); + ++integral; + fractional = 0U; } } + etl::private_to_string::add_integral_fractional(integral, fractional, str, integral_format, fractional_format, etl::is_negative(value)); etl::private_to_string::add_alignment(str, start, format); } - template - void add_integral_denominated(T value, - typename etl::make_unsigned::type denominator, - TIString& str, - bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_integral_denominated(value, denominator, str, format, append); - } - //*************************************************************************** /// Helper function for pointers. //*************************************************************************** @@ -445,22 +465,7 @@ namespace etl //********************************************************************************************************* //*************************************************************************** - /// For booleans. Default format spec. - //*************************************************************************** - template - const TIString& to_string(const bool value, - TIString& str, - bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_boolean(value, str, format, append); - - return str; - } - - //*************************************************************************** - /// For booleans. Supplied format spec. + /// For booleans. //*************************************************************************** template const TIString& to_string(const bool value, @@ -474,22 +479,7 @@ namespace etl } //*************************************************************************** - /// For pointers. Default format spec. - //*************************************************************************** - template - const TIString& to_string(const volatile void* value, - TIString& str, - bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_pointer(value, str, format, append); - - return str; - } - - //*************************************************************************** - /// For pointers. Supplied format spec. + /// For pointers. //*************************************************************************** template const TIString& to_string(const volatile void* value, @@ -503,24 +493,9 @@ namespace etl } #if ETL_NOT_USING_64BIT_TYPES - //*************************************************************************** - /// For signed integrals less than 64 bits. Default format spec. - //*************************************************************************** - template - typename etl::enable_if::value && - etl::is_signed::value && - !etl::is_same::value>::value, const TIString& > ::type - to_string(const T value, TIString& str, bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_integral(int32_t(value), str, format, append, etl::is_negative(value)); - - return str; - } //*************************************************************************** - /// For signed integrals less than 64 bits. Supplied format spec. + /// For signed integrals less than 64 bits. //*************************************************************************** template typename etl::enable_if::value && @@ -534,23 +509,7 @@ namespace etl } //*************************************************************************** - /// For unsigned integrals less than 64 bits. Default format spec. - //*************************************************************************** - template - typename etl::enable_if::value && - etl::is_unsigned::value && - !etl::is_same::value>::value, const TIString& > ::type - to_string(const T value, TIString& str, bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_integral(uint32_t(value), str, format, append, false); - - return str; - } - - //*************************************************************************** - /// For unsigned integrals less than 64 bits. Supplied format spec. + /// For unsigned integrals less than 64 bits. //*************************************************************************** template typename etl::enable_if::value && @@ -562,26 +521,39 @@ namespace etl return str; } + + //*************************************************************************** + /// For signed integrals less than 64 bits. + //*************************************************************************** + template + typename etl::enable_if::value&& + etl::is_signed::value && + !etl::is_same::value>::value, const TIString& > ::type + to_string(const T value, typename etl::make_unsigned::type denominator, TIString& str, const etl::basic_format_spec& format, bool append = false) + { + etl::private_to_string::add_integral_denominated(int32_t(value), denominator, str, format, append, etl::is_negative(value)); + + return str; + } + + //*************************************************************************** + /// For unsigned integrals less than 64 bits. + //*************************************************************************** + template + typename etl::enable_if::value&& + etl::is_unsigned::value && + !etl::is_same::value>::value, const TIString& > ::type + to_string(const T value, typename etl::make_unsigned::type denominator, TIString& str, const etl::basic_format_spec& format, bool append = false) + { + etl::private_to_string::add_integral_denominated(uint32_t(value), denominator, str, format, append, false); + + return str; + } + #else - //*************************************************************************** - /// For signed integrals less than 64 bits. Default format spec. - //*************************************************************************** - template - typename etl::enable_if::value && - etl::is_signed::value && - !etl::is_same::value && - !etl::is_same::value, const TIString&>::type - to_string(const T value, TIString& str, bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_integral(int32_t(value), str, format, append, etl::is_negative(value)); - - return str; - } //*************************************************************************** - /// For signed integrals less than 64 bits. Supplied format spec. + /// For signed integrals less than 64 bits. //*************************************************************************** template typename etl::enable_if::value && @@ -596,24 +568,7 @@ namespace etl } //*************************************************************************** - /// For unsigned integrals less than 64 bits. Default format spec. - //*************************************************************************** - template - typename etl::enable_if::value && - etl::is_unsigned::value && - !etl::is_same::value && - !etl::is_same::value, const TIString&>::type - to_string(const T value, TIString& str, bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_integral(uint32_t(value), str, format, append, false); - - return str; - } - - //*************************************************************************** - /// For unsigned integrals less than 64 bits. Supplied format spec. + /// For unsigned integrals less than 64 bits. //*************************************************************************** template typename etl::enable_if::value && @@ -628,24 +583,7 @@ namespace etl } //*************************************************************************** - /// For signed 64 bit integrals. Default format spec. - //*************************************************************************** - template - typename etl::enable_if::value && - etl::is_signed::value && - !etl::is_same::value && - etl::is_same::value, const TIString&>::type - to_string(const T value, TIString& str, bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_integral(int64_t(value), str, format, append, etl::is_negative(value)); - - return str; - } - - //*************************************************************************** - /// For signed 64 bit integrals. Supplied format spec. + /// For signed 64 bit integrals. //*************************************************************************** template typename etl::enable_if::value && @@ -660,24 +598,7 @@ namespace etl } //*************************************************************************** - /// For unsigned 64 bit integrals. Default format spec. - //*************************************************************************** - template - typename etl::enable_if::value && - etl::is_unsigned::value && - !etl::is_same::value && - etl::is_same::value, const TIString&>::type - to_string(const T value, TIString& str, bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_integral(uint64_t(value), str, format, append, false); - - return str; - } - - //*************************************************************************** - /// For unsigned 64 bit integrals. Supplied format spec. + /// For unsigned 64 bit integrals. //*************************************************************************** template typename etl::enable_if::value && @@ -690,24 +611,71 @@ namespace etl return str; } + + //*************************************************************************** + /// For signed integrals less than 64 bits. + //*************************************************************************** + template + typename etl::enable_if::value&& + etl::is_signed::value && + !etl::is_same::value && + !etl::is_same::value, const TIString&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, TIString& str, const etl::basic_format_spec& format, bool append = false) + { + etl::private_to_string::add_integral_denominated(int32_t(value), denominator, str, format, append); + + return str; + } + + //*************************************************************************** + /// For unsigned integrals less than 64 bits. + //*************************************************************************** + template + typename etl::enable_if::value&& + etl::is_unsigned::value && + !etl::is_same::value && + !etl::is_same::value, const TIString&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, TIString& str, const etl::basic_format_spec& format, bool append = false) + { + etl::private_to_string::add_integral_denominated(uint32_t(value), denominator, str, format, append); + + return str; + } + + //*************************************************************************** + /// For signed 64 bit integrals. + //*************************************************************************** + template + typename etl::enable_if::value&& + etl::is_signed::value && + !etl::is_same::value&& + etl::is_same::value, const TIString&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, TIString& str, const etl::basic_format_spec& format, bool append = false) + { + etl::private_to_string::add_integral_denominated(int64_t(value), denominator, str, format, append, etl::is_negative(value)); + + return str; + } + + //*************************************************************************** + /// For unsigned 64 bit integrals. + //*************************************************************************** + template + typename etl::enable_if::value&& + etl::is_unsigned::value && + !etl::is_same::value&& + etl::is_same::value, const TIString&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, TIString& str, const etl::basic_format_spec& format, bool append = false) + { + etl::private_to_string::add_integral(uint64_t(value), denominator, str, format, append, false); + + return str; + } + #endif //*************************************************************************** - /// For floating point. Default format spec. - //*************************************************************************** - template - typename etl::enable_if::value, const TIString&>::type - to_string(const T value, TIString& str, bool append = false) - { - etl::basic_format_spec format; - - etl::private_to_string::add_floating_point(value, str, format, append); - - return str; - } - - //*************************************************************************** - /// For floating point. Supplied format spec. + /// For floating point. //*************************************************************************** template typename etl::enable_if::value, const TIString&>::type diff --git a/include/etl/to_string.h b/include/etl/to_string.h index 4535d2c9..de09aec2 100644 --- a/include/etl/to_string.h +++ b/include/etl/to_string.h @@ -65,6 +65,30 @@ namespace etl return private_to_string::to_string(value, str, format, append); } + //*************************************************************************** + /// Default format spec. + /// !etl::istring && !etl::string_view + //*************************************************************************** + template + typename etl::enable_if::value && !etl::is_same::value, const etl::istring&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, etl::istring& str, bool append = false) + { + etl::format_spec format; + + return private_to_string::to_string(value, denominator, str, format, append); + } + + //*************************************************************************** + /// Supplied format spec. + /// !etl::istring && !etl::string_view + //*************************************************************************** + template + typename etl::enable_if::value && !etl::is_same::value, const etl::istring&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, etl::istring& str, const etl::format_spec& format, bool append = false) + { + return private_to_string::to_string(value, denominator, str, format, append); + } + //*************************************************************************** /// Default format spec. /// etl::istring diff --git a/include/etl/to_u16string.h b/include/etl/to_u16string.h index cfb6ffe8..9d117aa2 100644 --- a/include/etl/to_u16string.h +++ b/include/etl/to_u16string.h @@ -65,6 +65,31 @@ namespace etl return private_to_string::to_string(value, str, format, append); } + //*************************************************************************** + /// Default format spec. + /// !etl::iu16string && !etl::u16string_view + //*************************************************************************** + template + typename etl::enable_if::value && !etl::is_same::value, const etl::iu16string&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, etl::iu16string& str, bool append = false) + { + etl::u16format_spec format; + + return private_to_string::to_string(value, denominator, str, format, append); + } + + //*************************************************************************** + /// Supplied format spec. + /// !etl::u16string_view && !etl::u16string_view + //*************************************************************************** + template + typename etl::enable_if::value && !etl::is_same::value, const etl::iu16string&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, etl::iu16string& str, const etl::u16format_spec& format, bool append = false) + { + return private_to_string::to_string(value, denominator, str, format, append); + } + + //*************************************************************************** /// Default format spec. /// etl::iu16string diff --git a/include/etl/to_u32string.h b/include/etl/to_u32string.h index f07451cd..a17e6ba8 100644 --- a/include/etl/to_u32string.h +++ b/include/etl/to_u32string.h @@ -65,6 +65,30 @@ namespace etl return private_to_string::to_string(value, str, format, append); } + //*************************************************************************** + /// Default format spec. + /// !etl::iu32string && !etl::u16string_view + //*************************************************************************** + template + typename etl::enable_if::value && !etl::is_same::value, const etl::iu32string&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, etl::iu32string& str, bool append = false) + { + etl::u32format_spec format; + + return private_to_string::to_string(value, denominator, str, format, append); + } + + //*************************************************************************** + /// Supplied format spec. + /// !etl::u16string_view && !etl::u16string_view + //*************************************************************************** + template + typename etl::enable_if::value && !etl::is_same::value, const etl::iu32string&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, etl::iu32string& str, const etl::u32format_spec& format, bool append = false) + { + return private_to_string::to_string(value, denominator, str, format, append); + } + //*************************************************************************** /// Default format spec. /// etl::iu32string diff --git a/include/etl/to_wstring.h b/include/etl/to_wstring.h index 1612d02e..7f710674 100644 --- a/include/etl/to_wstring.h +++ b/include/etl/to_wstring.h @@ -65,6 +65,30 @@ namespace etl return private_to_string::to_string(value, str, format, append); } + //*************************************************************************** + /// Default format spec. + /// !etl::iu32string && !etl::u16string_view + //*************************************************************************** + template + typename etl::enable_if::value && !etl::is_same::value, const etl::iwstring&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, etl::iwstring& str, bool append = false) + { + etl::wformat_spec format; + + return private_to_string::to_string(value, denominator, str, format, append); + } + + //*************************************************************************** + /// Supplied format spec. + /// !etl::u16string_view && !etl::u16string_view + //*************************************************************************** + template + typename etl::enable_if::value && !etl::is_same::value, const etl::iwstring&>::type + to_string(const T value, typename etl::make_unsigned::type denominator, etl::iwstring& str, const etl::wformat_spec& format, bool append = false) + { + return private_to_string::to_string(value, denominator, str, format, append); + } + //*************************************************************************** /// Default format spec. /// etl::iwstring diff --git a/test/test_to_string.cpp b/test/test_to_string.cpp index 5221884f..9dc4bc9a 100644 --- a/test/test_to_string.cpp +++ b/test/test_to_string.cpp @@ -278,6 +278,14 @@ namespace CHECK(etl::string<20>(STR(" -0.123456")) == etl::to_string(-0.123456, str, Format().precision(6).width(10).right())); CHECK(etl::string<20>(STR("-0.123456 ")) == etl::to_string(-0.123456, str, Format().precision(6).width(10).left())); + + // Positive rollover + CHECK(etl::string<20>(STR(" 2.000000")) == etl::to_string(1.9999996, str, Format().precision(6).width(10).right())); + CHECK(etl::string<20>(STR("2.000000 ")) == etl::to_string(1.9999996, str, Format().precision(6).width(10).left())); + + // Negative rollover + CHECK(etl::string<20>(STR(" -2.000000")) == etl::to_string(-1.9999996, str, Format().precision(6).width(10).right())); + CHECK(etl::string<20>(STR("-2.000000 ")) == etl::to_string(-1.9999996, str, Format().precision(6).width(10).left())); } //************************************************************************* @@ -425,6 +433,102 @@ namespace to_string(&cvi, str, Format().hex().width(10).left().fill(STR('0')), true); CHECK(compare == str); } + + //************************************************************************* + TEST(test_integer_denominator_default_format) + { + etl::string<20> result; + int value = -1234567; + + etl::to_string(value, 1000000, result); + + CHECK_EQUAL(etl::string<20>("-1").c_str(), result.c_str()); + } + + //************************************************************************* + TEST(test_integer_denominator_huge_precision) + { + etl::string<20> result; + int value = -1234560; + + etl::format_spec format = Format().precision(100); + + etl::to_string(value, 1000000, result, format); + + CHECK_EQUAL(etl::string<20>("-1.234560").c_str(), result.c_str()); + } + + //************************************************************************* + TEST(test_integer_denominator_shorter_width) + { + etl::string<20> result_i; + int value_i = -1234560; + + etl::string<20> result_d; + double value_d = -1.234560; + + etl::format_spec format = Format().precision(4).width(6).right(); + + etl::to_string(value_i, 1000000, result_i, format); + etl::to_string(value_d, result_d, format); + + CHECK_EQUAL(etl::string<20>(STR("-1.2346")).c_str(), result_i.c_str()); + CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + } + + //************************************************************************* + TEST(test_integer_denominator_larger_width) + { + etl::string<20> result_i; + int value_i = -1234560; + + etl::string<20> result_d; + double value_d = -1.234560; + + etl::format_spec format = Format().precision(4).width(15).right(); + + etl::to_string(value_i, 1000000, result_i, format); + etl::to_string(value_d, result_d, format); + + CHECK_EQUAL(etl::string<20>(STR(" -1.2346")).c_str(), result_i.c_str()); + CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + } + + //************************************************************************* + TEST(test_integer_denominator_positive_rollover) + { + etl::string<20> result_i; + int value_i = 1999990; + + etl::string<20> result_d; + double value_d = 1.999990; + + etl::format_spec format = Format().precision(4).right(); + + etl::to_string(value_i, 1000000, result_i, format); + etl::to_string(value_d, result_d, format); + + CHECK_EQUAL(etl::string<20>(STR("2.0000")).c_str(), result_i.c_str()); + CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + } + + //************************************************************************* + TEST(test_integer_denominator_negative_rollover) + { + etl::string<20> result_i; + int value_i = -1999990; + + etl::string<20> result_d; + double value_d = -1.999990; + + etl::format_spec format = Format().precision(4).right(); + + etl::to_string(value_i, 1000000, result_i, format); + etl::to_string(value_d, result_d, format); + + CHECK_EQUAL(etl::string<20>(STR("-2.0000")).c_str(), result_i.c_str()); + CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + } }; } diff --git a/test/test_to_u16string.cpp b/test/test_to_u16string.cpp index fff948be..85b3af67 100644 --- a/test/test_to_u16string.cpp +++ b/test/test_to_u16string.cpp @@ -348,6 +348,42 @@ namespace str.assign(STR("Result ")); CHECK(etl::u16string<20>(STR("Result true ")) == to_string(true, str, Format().precision(6).width(10).left().boolalpha(true), true)); } + + ////************************************************************************* + //TEST(test_integer_denominator_shorter_width) + //{ + // etl::u16string<20> result_i; + // int value_i = -1234567; + + // etl::u16string<20> result_d; + // double value_d = -2.9543; + + // etl::u16format_spec format = Format().precision(4).width(6).right(); + + // etl::to_string(value_i, 1000000, result_i, format); + // etl::to_string(value_d, result_d, format); + + // CHECK_EQUAL(etl::u16string<20>(STR("-1.2346")).c_str(), result_i.c_str()); + // CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + //} + + ////************************************************************************* + //TEST(test_integer_denominator_larger_width) + //{ + // etl::u16string<20> result_i; + // int value_i = -1234567; + + // etl::u16string<20> result_d; + // double value_d = -2.9543; + + // etl::u16format_spec format = Format().precision(4).width(15).right(); + + // etl::to_string(value_i, 1000000, result_i, format); + // etl::to_string(value_d, result_d, format); + + // CHECK_EQUAL(etl::u16string<20>(STR(" -1.2345")).c_str(), result_i.c_str()); + // CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + //} }; } diff --git a/test/test_to_u32string.cpp b/test/test_to_u32string.cpp index e5928416..07d9909e 100644 --- a/test/test_to_u32string.cpp +++ b/test/test_to_u32string.cpp @@ -353,6 +353,42 @@ namespace str.assign(STR("Result ")); CHECK(etl::u32string<20>(STR("Result true ")) == to_string(true, str, Format().precision(6).width(10).left().boolalpha(true), true)); } + + ////************************************************************************* + //TEST(test_integer_denominator_shorter_width) + //{ + // etl::u32string<20> result_i; + // int value_i = -1234567; + + // etl::u32string<20> result_d; + // double value_d = -2.9543; + + // etl::u32format_spec format = Format().precision(4).width(6).right(); + + // etl::to_string(value_i, 1000000, result_i, format); + // etl::to_string(value_d, result_d, format); + + // CHECK_EQUAL(etl::u32string<20>(STR("-1.2345")).c_str(), result_i.c_str()); + // CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + //} + + ////************************************************************************* + //TEST(test_integer_denominator_larger_width) + //{ + // etl::u32string<20> result_i; + // int value_i = -1234567; + + // etl::u32string<20> result_d; + // double value_d = -2.9543; + + // etl::u32format_spec format = Format().precision(4).width(15).right(); + + // etl::to_string(value_i, 1000000, result_i, format); + // etl::to_string(value_d, result_d, format); + + // CHECK_EQUAL(etl::u32string<20>(STR(" -1.2345")).c_str(), result_i.c_str()); + // CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + //} }; } diff --git a/test/test_to_wstring.cpp b/test/test_to_wstring.cpp index d213ab80..f1cc0f81 100644 --- a/test/test_to_wstring.cpp +++ b/test/test_to_wstring.cpp @@ -415,6 +415,42 @@ namespace to_string(&cvi, str, Format().hex().width(10).left().fill(STR('0')), true); CHECK(compare == str); } + + ////************************************************************************* + //TEST(test_integer_denominator_shorter_width) + //{ + // etl::wstring<20> result_i; + // int value_i = -1234567; + + // etl::wstring<20> result_d; + // double value_d = -2.9543; + + // etl::wformat_spec format = Format().precision(4).width(6).right(); + + // etl::to_string(value_i, 1000000, result_i, format); + // etl::to_string(value_d, result_d, format); + + // CHECK_EQUAL(etl::wstring<20>(STR("-1.2345")).c_str(), result_i.c_str()); + // CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + //} + + ////************************************************************************* + //TEST(test_integer_denominator_larger_width) + //{ + // etl::wstring<20> result_i; + // int value_i = -1234567; + + // etl::wstring<20> result_d; + // double value_d = -2.9543; + + // etl::wformat_spec format = Format().precision(4).width(15).right(); + + // etl::to_string(value_i, 1000000, result_i, format); + // etl::to_string(value_d, result_d, format); + + // CHECK_EQUAL(etl::wstring<20>(STR(" -1.2345")).c_str(), result_i.c_str()); + // CHECK_EQUAL(result_d.c_str(), result_i.c_str()); + //} }; }