mirror of
https://github.com/polybar/polybar.git
synced 2024-11-18 13:55:11 -05:00
Test utf8_to_ucs4 error correction
This commit is contained in:
parent
5b1fae4fc1
commit
40bc8c7955
1 changed files with 15 additions and 0 deletions
|
@ -266,4 +266,19 @@ TEST_P(Utf8ToUCS4InvalidTest, correctness) {
|
|||
EXPECT_FALSE(success);
|
||||
EXPECT_EQ(0, result_list.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the conversion works with partially valid strings and that invalid parts are dropped.
|
||||
*/
|
||||
TEST(String, utf8ToUCS4Partial) {
|
||||
string_util::unicode_charlist result_list{};
|
||||
string str = "\xe0\x70\x80"; // a valid ascii character between two invalid characters
|
||||
bool success = string_util::utf8_to_ucs4(str, result_list);
|
||||
EXPECT_FALSE(success);
|
||||
EXPECT_EQ(1, result_list.size());
|
||||
|
||||
EXPECT_EQ(0x70, result_list[0].codepoint);
|
||||
EXPECT_EQ(1, result_list[0].offset);
|
||||
EXPECT_EQ(1, result_list[0].length);
|
||||
}
|
||||
// }}}
|
||||
|
|
Loading…
Reference in a new issue