Code Cleanup

- Relocated the Table::getCharLength() from Johannes to text.cpp/characters()
  because it is a general-purpose function, and will be the start of the UTF8
  conversion of all text.cpp code.
- Added unit tests for characters().
This commit is contained in:
Paul Beckingham
2010-08-01 13:05:53 -04:00
parent 6e1aa42d1a
commit 2f1c582d7d
5 changed files with 35 additions and 28 deletions

View File

@@ -34,7 +34,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (191);
UnitTest t (194);
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width)
std::string text = "This is a test of the line wrapping code.";
@@ -387,6 +387,11 @@ int main (int argc, char** argv)
t.is (strippedLength (std::string ("\033[0m")), 0, "strippedLength ^[[0m -> 0");
t.is (strippedLength (std::string ("\033[1m\033[0m")), 0, "strippedLength ^[[1m^[[0m -> 0");
// int characters (const std::string&);
t.is (characters ("Çirçös"), 6, "characters (Çirçös) == 6");
t.is (characters ("ツネナラム"), 5, "characters (ツネナラム) == 6");
t.is (characters ("Zwölf Boxkämpfer"), 16, "characters (Zwölf Boxkämpfer) == 6");
return 0;
}