Merge remote-tracking branch 'origin/development'

# Conflicts:
#	include/etl/basic_format_spec.h
#	include/etl/private/to_string_helper.h
#	include/etl/to_string.h
#	include/etl/to_u16string.h
#	include/etl/to_u32string.h
#	include/etl/to_wstring.h
#	include/etl/version.h
#	support/Release notes.txt
This commit is contained in:
John Wellbelove 2019-04-14 19:43:09 +01:00
parent 9c817107ea
commit a2f4ea123c
3 changed files with 263 additions and 0 deletions

View File

@ -326,6 +326,73 @@ namespace
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result true ")), to_string(true, str, Format().precision(6).width(10).left().boolalpha(true), true));
}
//*************************************************************************
TEST(test_floating_point_no_append)
{
etl::u16string<20> str;
CHECK_EQUAL(etl::u16string<20>(STR(" 12.345678")), etl::to_u16string(12.345678, str, Format().precision(6).width(10).right()));
CHECK_EQUAL(etl::u16string<20>(STR("12.345678 ")), etl::to_u16string(12.345678, str, Format().precision(6).width(10).left()));
}
//*************************************************************************
TEST(test_floating_point_append)
{
etl::u16string<20> str;
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result 12.345678")), etl::to_u16string(12.345678, str, Format().precision(6).width(10).right(), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result 12.345678 ")), etl::to_u16string(12.345678, str, Format().precision(6).width(10).left(), true));
}
//*************************************************************************
TEST(test_bool_no_append)
{
etl::u16string<20> str;
CHECK_EQUAL(etl::u16string<20>(STR(" 0")), to_u16string(false, str, Format().precision(6).width(10).right().boolalpha(false)));
CHECK_EQUAL(etl::u16string<20>(STR(" 1")), to_u16string(true, str, Format().precision(6).width(10).right().boolalpha(false)));
CHECK_EQUAL(etl::u16string<20>(STR("0 ")), to_u16string(false, str, Format().precision(6).width(10).left().boolalpha(false)));
CHECK_EQUAL(etl::u16string<20>(STR("1 ")), to_u16string(true, str, Format().precision(6).width(10).left().boolalpha(false)));
CHECK_EQUAL(etl::u16string<20>(STR(" false")), to_u16string(false, str, Format().precision(6).width(10).right().boolalpha(true)));
CHECK_EQUAL(etl::u16string<20>(STR(" true")), to_u16string(true, str, Format().precision(6).width(10).right().boolalpha(true)));
CHECK_EQUAL(etl::u16string<20>(STR("false ")), to_u16string(false, str, Format().precision(6).width(10).left().boolalpha(true)));
CHECK_EQUAL(etl::u16string<20>(STR("true ")), to_u16string(true, str, Format().precision(6).width(10).left().boolalpha(true)));
}
//*************************************************************************
TEST(test_bool_append)
{
etl::u16string<20> str;
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result 0")), to_u16string(false, str, Format().precision(6).width(10).right().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result 1")), to_u16string(true, str, Format().precision(6).width(10).right().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result 0 ")), to_u16string(false, str, Format().precision(6).width(10).left().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result 1 ")), to_u16string(true, str, Format().precision(6).width(10).left().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result false")), to_u16string(false, str, Format().precision(6).width(10).right().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result true")), to_u16string(true, str, Format().precision(6).width(10).right().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result false ")), to_u16string(false, str, Format().precision(6).width(10).left().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u16string<20>(STR("Result true ")), to_u16string(true, str, Format().precision(6).width(10).left().boolalpha(true), true));
}
};
}

View File

@ -329,6 +329,73 @@ namespace
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result true ")), to_string(true, str, Format().precision(6).width(10).left().boolalpha(true), true));
}
//*************************************************************************
TEST(test_floating_point_no_append)
{
etl::u32string<20> str;
CHECK_EQUAL(etl::u32string<20>(STR(" 12.345678")), etl::to_u32string(12.345678, str, Format().precision(6).width(10).right()));
CHECK_EQUAL(etl::u32string<20>(STR("12.345678 ")), etl::to_u32string(12.345678, str, Format().precision(6).width(10).left()));
}
//*************************************************************************
TEST(test_floating_point_append)
{
etl::u32string<20> str;
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result 12.345678")), etl::to_u32string(12.345678, str, Format().precision(6).width(10).right(), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result 12.345678 ")), etl::to_u32string(12.345678, str, Format().precision(6).width(10).left(), true));
}
//*************************************************************************
TEST(test_bool_no_append)
{
etl::u32string<20> str;
CHECK_EQUAL(etl::u32string<20>(STR(" 0")), to_u32string(false, str, Format().precision(6).width(10).right().boolalpha(false)));
CHECK_EQUAL(etl::u32string<20>(STR(" 1")), to_u32string(true, str, Format().precision(6).width(10).right().boolalpha(false)));
CHECK_EQUAL(etl::u32string<20>(STR("0 ")), to_u32string(false, str, Format().precision(6).width(10).left().boolalpha(false)));
CHECK_EQUAL(etl::u32string<20>(STR("1 ")), to_u32string(true, str, Format().precision(6).width(10).left().boolalpha(false)));
CHECK_EQUAL(etl::u32string<20>(STR(" false")), to_u32string(false, str, Format().precision(6).width(10).right().boolalpha(true)));
CHECK_EQUAL(etl::u32string<20>(STR(" true")), to_u32string(true, str, Format().precision(6).width(10).right().boolalpha(true)));
CHECK_EQUAL(etl::u32string<20>(STR("false ")), to_u32string(false, str, Format().precision(6).width(10).left().boolalpha(true)));
CHECK_EQUAL(etl::u32string<20>(STR("true ")), to_u32string(true, str, Format().precision(6).width(10).left().boolalpha(true)));
}
//*************************************************************************
TEST(test_bool_append)
{
etl::u32string<20> str;
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result 0")), to_u32string(false, str, Format().precision(6).width(10).right().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result 1")), to_u32string(true, str, Format().precision(6).width(10).right().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result 0 ")), to_u32string(false, str, Format().precision(6).width(10).left().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result 1 ")), to_u32string(true, str, Format().precision(6).width(10).left().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result false")), to_u32string(false, str, Format().precision(6).width(10).right().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result true")), to_u32string(true, str, Format().precision(6).width(10).right().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result false ")), to_u32string(false, str, Format().precision(6).width(10).left().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::u32string<20>(STR("Result true ")), to_u32string(true, str, Format().precision(6).width(10).left().boolalpha(true), true));
}
};
}

View File

@ -392,6 +392,135 @@ namespace
to_string(&cvi, str, Format().hex().width(10).left().fill(STR('0')), true);
CHECK_EQUAL(compare, str);
}
//*************************************************************************
TEST(test_floating_point_no_append)
{
etl::wstring<20> str;
CHECK_EQUAL(etl::wstring<20>(STR(" 12.345678")), etl::to_wstring(12.345678, str, Format().precision(6).width(10).right()));
CHECK_EQUAL(etl::wstring<20>(STR("12.345678 ")), etl::to_wstring(12.345678, str, Format().precision(6).width(10).left()));
}
//*************************************************************************
TEST(test_floating_point_append)
{
etl::wstring<20> str;
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result 12.345678")), etl::to_wstring(12.345678, str, Format().precision(6).width(10).right(), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result 12.345678 ")), etl::to_wstring(12.345678, str, Format().precision(6).width(10).left(), true));
}
//*************************************************************************
TEST(test_bool_no_append)
{
etl::wstring<20> str;
CHECK_EQUAL(etl::wstring<20>(STR(" 0")), to_wstring(false, str, Format().precision(6).width(10).right().boolalpha(false)));
CHECK_EQUAL(etl::wstring<20>(STR(" 1")), to_wstring(true, str, Format().precision(6).width(10).right().boolalpha(false)));
CHECK_EQUAL(etl::wstring<20>(STR("0 ")), to_wstring(false, str, Format().precision(6).width(10).left().boolalpha(false)));
CHECK_EQUAL(etl::wstring<20>(STR("1 ")), to_wstring(true, str, Format().precision(6).width(10).left().boolalpha(false)));
CHECK_EQUAL(etl::wstring<20>(STR(" false")), to_wstring(false, str, Format().precision(6).width(10).right().boolalpha(true)));
CHECK_EQUAL(etl::wstring<20>(STR(" true")), to_wstring(true, str, Format().precision(6).width(10).right().boolalpha(true)));
CHECK_EQUAL(etl::wstring<20>(STR("false ")), to_wstring(false, str, Format().precision(6).width(10).left().boolalpha(true)));
CHECK_EQUAL(etl::wstring<20>(STR("true ")), to_wstring(true, str, Format().precision(6).width(10).left().boolalpha(true)));
}
//*************************************************************************
TEST(test_bool_append)
{
etl::wstring<20> str;
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result 0")), to_wstring(false, str, Format().precision(6).width(10).right().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result 1")), to_wstring(true, str, Format().precision(6).width(10).right().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result 0 ")), to_wstring(false, str, Format().precision(6).width(10).left().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result 1 ")), to_wstring(true, str, Format().precision(6).width(10).left().boolalpha(false), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result false")), to_wstring(false, str, Format().precision(6).width(10).right().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result true")), to_wstring(true, str, Format().precision(6).width(10).right().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result false ")), to_wstring(false, str, Format().precision(6).width(10).left().boolalpha(true), true));
str.assign(STR("Result "));
CHECK_EQUAL(etl::wstring<20>(STR("Result true ")), to_wstring(true, str, Format().precision(6).width(10).left().boolalpha(true), true));
}
//*************************************************************************
TEST(test_pointer_no_append)
{
etl::wstring<20> str;
static const volatile int cvi = 0;
std::wostringstream oss;
oss.width(10);
oss.fill(STR('0'));
oss << std::hex << std::uppercase << std::right << uintptr_t(&cvi);
std::wstring temp(oss.str());
etl::wstring<20> compare(temp.begin(), temp.end());
to_wstring(&cvi, str, Format().hex().width(10).right().fill(STR('0')));
CHECK_EQUAL(compare, str);
oss.clear();
oss.str(STR(""));
oss.width(10);
oss.fill(STR('0'));
oss << std::hex << std::uppercase << std::left << uintptr_t(&cvi);
temp = oss.str();
compare.assign(temp.begin(), temp.end());
to_wstring(&cvi, str, Format().hex().width(10).left().fill(STR('0')));
CHECK_EQUAL(compare, str);
}
//*************************************************************************
TEST(test_pointer_append)
{
etl::wstring<20> str;
static const volatile int cvi = 0;
std::wostringstream oss;
oss.width(10);
oss.fill(STR('0'));
oss << std::hex << std::uppercase << std::right << uintptr_t(&cvi);
std::wstring temp(STR("Result "));
temp.append(oss.str());
etl::wstring<20> compare(temp.begin(), temp.end());
str.assign(STR("Result "));
to_wstring(&cvi, str, Format().hex().width(10).right().fill(STR('0')), true);
CHECK_EQUAL(compare, str);
oss.clear();
oss.str(STR(""));
oss.width(10);
oss.fill(STR('0'));
oss << std::hex << std::uppercase << std::left << uintptr_t(&cvi);
temp = STR("Result ");
temp.append(oss.str());
compare.assign(temp.begin(), temp.end());
str.assign(STR("Result "));
to_wstring(&cvi, str, Format().hex().width(10).left().fill(STR('0')), true);
CHECK_EQUAL(compare, str);
}
};
}