Use parameter instead of assuming 10 numeric digits
This commit is contained in:
parent
199db7640e
commit
420257f578
2 changed files with 31 additions and 12 deletions
|
@ -63,7 +63,7 @@ namespace {
|
|||
}
|
||||
} //unnamed namespace
|
||||
|
||||
TEST_CASE ("Check int to char array conversions", "[s2i][int_conv]") {
|
||||
TEST_CASE ("Check int to char array conversions", "[i2s][int_conv]") {
|
||||
using dhandy::int_to_ary;
|
||||
using dhandy::bt::string;
|
||||
using dhandy::bt::make_string;
|
||||
|
@ -157,7 +157,7 @@ TEST_CASE ("Check int to char array conversions", "[s2i][int_conv]") {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE ("Check char array to int conversions", "[i2s][int_conv]") {
|
||||
TEST_CASE ("Check char array to int conversions", "[s2i][int_conv]") {
|
||||
AryConversionTestHelper<std::uint32_t, 10>("0", 0, true);
|
||||
AryConversionTestHelper<std::int32_t, 10>("0", 0, true);
|
||||
AryConversionTestHelper<std::int16_t, 10>("0", 0, true);
|
||||
|
@ -200,7 +200,7 @@ TEST_CASE ("Check char array to int conversions", "[i2s][int_conv]") {
|
|||
AryConversionTestHelperIns<std::int32_t, 16>("aAbBc", 0xaabbc, true);
|
||||
}
|
||||
|
||||
TEST_CASE ("Check string_view conversions work as expected", "[i2s][int_conv]") {
|
||||
TEST_CASE ("Check string_view conversions work as expected", "[s2i][int_conv]") {
|
||||
using dhandy::int_conv;
|
||||
using dhandy::int_conv_raw;
|
||||
using std::string_view;
|
||||
|
@ -265,7 +265,7 @@ TEST_CASE ("Check upcase/downcase int to array conversions", "[i2s][int_conv]")
|
|||
CHECK("-256" == int4);
|
||||
}
|
||||
|
||||
TEST_CASE ("Try int conv with non-char", "[i2s][int_conv]") {
|
||||
TEST_CASE ("Try int conv with non-char", "[s2i][int_conv]") {
|
||||
using dhandy::int_to_ary;
|
||||
using dhandy::ASCIITranslator;
|
||||
|
||||
|
@ -273,3 +273,21 @@ TEST_CASE ("Try int conv with non-char", "[i2s][int_conv]") {
|
|||
auto val1 = int_to_ary<int, 10, ASCIITranslator<wchar_t>>(235713).to_string_view();
|
||||
CHECK(exp1 == val1);
|
||||
}
|
||||
|
||||
TEST_CASE ("Check some fancy conversions", "[i2s][int_conv]") {
|
||||
using dhandy::int_to_ary;
|
||||
using std::string;
|
||||
using MyFancyTranslator = dhandy::ASCIITranslator<char, '0', 'a', '+', '-', '\0', 4>;
|
||||
|
||||
string str1 = int_to_ary<int, 10, MyFancyTranslator>(3).to_string();
|
||||
CHECK("3" == str1);
|
||||
|
||||
string str2 = int_to_ary<int, 10, MyFancyTranslator>(5).to_string();
|
||||
CHECK("b" == str2);
|
||||
|
||||
string str3 = int_to_ary<int, 10, MyFancyTranslator>(11).to_string();
|
||||
CHECK("11" == str3);
|
||||
|
||||
string str4 = int_to_ary<int, 10, MyFancyTranslator>(537).to_string();
|
||||
CHECK("b3d" == str4);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue