Browse Source

add test for Non-ASCII characters

default-1
Roker 4 years ago
parent
commit
858110c357
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      src/unittest_toutf8.cc

+ 10
- 4
src/unittest_toutf8.cc View File

@ -30,17 +30,17 @@ const std::vector<std::string> testValuesIdentical =
{ std::string(nullo, nullo+4) }, // Yeah, 4 NUL bytes
{ "\taeiouAEIU~+-&\\ =?:\n\f</>\r" },
};
}
class ToUtf8TestIdentical : public ::testing::TestWithParam<std::string>
class ToUtf8Test : public ::testing::TestWithParam<std::string>
{
// intentionally left blank for now.
};
INSTANTIATE_TEST_CASE_P(ToUtf8TestInstance, ToUtf8TestIdentical, testing::ValuesIn(testValuesIdentical) );
INSTANTIATE_TEST_CASE_P(ToUtf8TestInstance, ToUtf8Test, testing::ValuesIn(testValuesIdentical) );
TEST_P( ToUtf8TestIdentical, Meh )
TEST_P( ToUtf8Test, Meh )
{
const auto& v = GetParam();
EXPECT_EQ( v, to_utf8("UTF-8", v) );
@ -48,3 +48,9 @@ TEST_P( ToUtf8TestIdentical, Meh )
EXPECT_EQ( v, to_utf8("ISO-8859-1", v) );
EXPECT_EQ( v, to_utf8("iso-8859-1", v) );
}
TEST( ToUtf8, Latin1 )
{
EXPECT_EQ( to_utf8("ISO-8859-1", "\x84\xdc" "bergr\xf6\xdf" "en\xe4" "nderung\x93: 10\x80!"), "„Übergrößenänderung“: 10€!" );
EXPECT_EQ( to_utf8("UTF-8", "„Übergrößenänderung“: 10€!"), "„Übergrößenänderung“: 10€!" );
}

Loading…
Cancel
Save