From 28523e97c609fd9c9e7b5f151b6ff63c345ba426 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 30 Dec 2012 14:44:15 -0500 Subject: [PATCH] Unit Tests - Added unit tests to illustrate bug #1136. --- src/E9.cpp | 2 +- test/text.t.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/E9.cpp b/src/E9.cpp index 05a7bdbdf..97a8c3e17 100644 --- a/src/E9.cpp +++ b/src/E9.cpp @@ -497,7 +497,7 @@ void E9::operator_equal ( // Bug 856. // // Special case for checking absent projects. Without the explicit "" check - // the right._value.lenghth() is used, which is 0, and therefore generates + // the right._value.length() is used, which is 0, and therefore generates // a false match. if (right._value == "") { diff --git a/test/text.t.cpp b/test/text.t.cpp index fcac02951..5b70e996c 100644 --- a/test/text.t.cpp +++ b/test/text.t.cpp @@ -36,7 +36,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (261); + UnitTest t (264); // void wrapText (std::vector & lines, const std::string& text, const int width, bool hyphenate) std::string text = "This is a test of the line wrapping code."; std::vector lines; @@ -48,7 +48,6 @@ int main (int argc, char** argv) t.is (lines[3], "wrapping", "wrapText line 3 -> 'wrapping'"); t.is (lines[4], "code.", "wrapText line 4 -> 'code.'"); - // void wrapText (std::vector & lines, const std::string& text, const int width) text = "This ☺ is a test of utf8 line extraction."; lines.clear (); wrapText (lines, text, 7, true); @@ -61,6 +60,13 @@ int main (int argc, char** argv) t.is (lines[5], "extrac-", "wrapText line 5 -> 'extrac-'"); t.is (lines[6], "tion.", "wrapText line 6 -> 'tion.'"); + text = "one two three\n four"; + lines.clear (); + wrapText (lines, text, 13, true); + t.is (lines.size (), (size_t) 2, "wrapText 'one two three\\n four' -> 2 lines"); + t.is (lines[0], "one two three", "wrapText line 0 -> 'one two three'"); + t.is (lines[1], " four", "wrapText line 1 -> ' four'"); + // void extractLine (std::string& text, std::string& line, int length, bool hyphenate) text = "This ☺ is a test of utf8 line extraction."; std::string line;