Tests: Added ::leftJustify, ::rightJustify tests

This commit is contained in:
Paul Beckingham 2016-01-05 16:46:20 -05:00
parent 4a2ac6f4fc
commit 201bf5ad21

View file

@ -31,7 +31,7 @@
////////////////////////////////////////////////////////////////////////////////
int main (int, char**)
{
UnitTest t (62);
UnitTest t (76);
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width, bool hyphenate)
std::string text = "This is a test of the line wrapping code.";
@ -99,7 +99,6 @@ int main (int, char**)
t.is (line, "AAAAAAAAA-", "extractLine hyphenated unbreakable line");
t.diag (line);
// void split (std::vector<std::string>& results, const std::string& input, const char delimiter)
std::string unsplit = "";
std::vector <std::string> items = split (unsplit, '-');
@ -164,6 +163,28 @@ int main (int, char**)
t.is (format (1.23456789, 8, 8), "1.2345679", "format (1.23456789, 8, 8) -> 1.2345679");
t.is (format (2444238.56789, 12, 11), "2444238.5679", "format (2444238.56789, 12, 11) -> 2444238.5679");
// std::string leftJustify (const std::string&, const int);
t.is (leftJustify (123, 3), "123", "leftJustify 123,3 -> '123'");
t.is (leftJustify (123, 4), "123 ", "leftJustify 123,4 -> '123 '");
t.is (leftJustify (123, 5), "123 ", "leftJustify 123,5 -> '123 '");
// std::string leftJustify (const std::string&, const int);
t.is (leftJustify ("foo", 3), "foo", "leftJustify foo,3 -> 'foo'");
t.is (leftJustify ("foo", 4), "foo ", "leftJustify foo,4 -> 'foo '");
t.is (leftJustify ("foo", 5), "foo ", "leftJustify foo,5 -> 'foo '");
t.is (leftJustify ("föo", 5), "föo ", "leftJustify föo,5 -> 'föo '");
// std::string rightJustify (const std::string&, const int);
t.is (rightJustify (123, 3), "123", "rightJustify 123,3 -> '123'");
t.is (rightJustify (123, 4), " 123", "rightJustify 123,4 -> ' 123'");
t.is (rightJustify (123, 5), " 123", "rightJustify 123,5 -> ' 123'");
// std::string rightJustify (const std::string&, const int);
t.is (rightJustify ("foo", 3), "foo", "rightJustify foo,3 -> 'foo'");
t.is (rightJustify ("foo", 4), " foo", "rightJustify foo,4 -> ' foo'");
t.is (rightJustify ("foo", 5), " foo", "rightJustify foo,5 -> ' foo'");
t.is (rightJustify ("föo", 5), " föo", "rightJustify föo,5 -> ' föo'");
return 0;
}