- Added UTF8 string width calculation.
This commit is contained in:
Paul Beckingham 2013-03-02 17:15:28 -05:00
parent 8e536fa4a8
commit 551b4dbe90
3 changed files with 22 additions and 1 deletions

View file

@ -32,7 +32,7 @@
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (6);
UnitTest t (10);
std::string ascii_text = "This is a test";
std::string utf8_text = "más sábado miércoles";
@ -57,6 +57,12 @@ int main (int argc, char** argv)
t.is (utf8_substr (ascii_text, 0, 2), "Th", "ASCII utf8_substr");
t.is (utf8_substr (utf8_text, 0, 2), "", "UTF8 utf8_substr");
// unsigned int utf8_width (const std::string&);
t.is (utf8_width ("one"), 3, "utf8_width 'one' --> 3");
t.is (utf8_width ("más sábado miércoles"), 20, "utf8_width 'más sábado miércoles' --> 20");
t.is (utf8_width ("改变各种颜色"), 12, "utf8_width '改变各种颜色' --> 12");
t.is (utf8_width (""), 2, "utf8_width '改' --> 2");
return 0;
}