Enhancement - caseless compare

- Fixed bug in text.cpp:find that failed to locate a substring if it occurred
  at the end of the string.
This commit is contained in:
Paul Beckingham
2010-01-27 16:28:57 -05:00
parent 0c5a71b02f
commit 4f1183a358
3 changed files with 62 additions and 43 deletions

View File

@@ -34,7 +34,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (178);
UnitTest t (180);
// 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.";
@@ -342,6 +342,7 @@ int main (int argc, char** argv)
// Test case-sensitive.
t.is ((int) find ("foo", "xx", true), (int) std::string::npos, "foo !contains xx");
t.is ((int) find ("foo", "oo", true), 1, "foo contains oo");
t.is ((int) find ("foo", "fo", true), 0, "foo contains fo");
t.is ((int) find ("foo", "FO", true), (int) std::string::npos, "foo !contains fo");
@@ -350,6 +351,7 @@ int main (int argc, char** argv)
// Test case-insensitive.
t.is ((int) find ("foo", "xx", false), (int) std::string::npos, "foo !contains xx (caseless)");
t.is ((int) find ("foo", "oo", false), 1, "foo contains oo (caseless)");
t.is ((int) find ("foo", "fo", false), 0, "foo contains fo (caseless)");
t.is ((int) find ("foo", "FO", false), 0, "foo contains FO (caseless)");