aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utility/stringUtilsTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utility/stringUtilsTest.cpp')
-rw-r--r--tests/utility/stringUtilsTest.cpp69
1 files changed, 36 insertions, 33 deletions
diff --git a/tests/utility/stringUtilsTest.cpp b/tests/utility/stringUtilsTest.cpp
index 76f9f36d..158eec22 100644
--- a/tests/utility/stringUtilsTest.cpp
+++ b/tests/utility/stringUtilsTest.cpp
@@ -33,75 +33,78 @@ namespace
{
class stringUtilsTest : public suite
{
+ typedef vmime::utility::stringUtils stringUtils;
+
+
void testIsStringEqualNoCase1()
{
- assert_eq("1", true, vmime::stringUtils::isStringEqualNoCase(vmime::string("foo"), "foo", 3));
- assert_eq("2", true, vmime::stringUtils::isStringEqualNoCase(vmime::string("FOo"), "foo", 3));
+ assert_eq("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), "foo", 3));
+ assert_eq("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), "foo", 3));
- assert_eq("3", false, vmime::stringUtils::isStringEqualNoCase(vmime::string("foo"), "FOo", 3));
- assert_eq("4", false, vmime::stringUtils::isStringEqualNoCase(vmime::string("foo"), "bar", 3));
+ assert_eq("3", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "FOo", 3));
+ assert_eq("4", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "bar", 3));
}
void testIsStringEqualNoCase2()
{
- assert_eq("1", true, vmime::stringUtils::isStringEqualNoCase(vmime::string("foo"), vmime::string("foo")));
- assert_eq("2", true, vmime::stringUtils::isStringEqualNoCase(vmime::string("FOo"), vmime::string("foo")));
- assert_eq("3", true, vmime::stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("FOo")));
+ assert_eq("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), vmime::string("foo")));
+ assert_eq("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), vmime::string("foo")));
+ assert_eq("3", true, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("FOo")));
}
void testIsStringEqualNoCase3()
{
vmime::string str1("FooBar");
- assert_eq("1", true, vmime::stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "foobar", 6));
- assert_eq("2", false, vmime::stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "FooBar", 6));
- assert_eq("3", true, vmime::stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "fooBar", 3));
- assert_eq("4", false, vmime::stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 3, "fooBar", 6));
+ assert_eq("1", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "foobar", 6));
+ assert_eq("2", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "FooBar", 6));
+ assert_eq("3", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "fooBar", 3));
+ assert_eq("4", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 3, "fooBar", 6));
}
void testToLower()
{
- assert_eq("1", "foo", vmime::stringUtils::toLower("FOO"));
- assert_eq("2", "foo", vmime::stringUtils::toLower("foO"));
- assert_eq("3", "foo", vmime::stringUtils::toLower("foo"));
+ assert_eq("1", "foo", stringUtils::toLower("FOO"));
+ assert_eq("2", "foo", stringUtils::toLower("foO"));
+ assert_eq("3", "foo", stringUtils::toLower("foo"));
}
void testTrim()
{
- assert_eq("1", "foo", vmime::stringUtils::trim(" foo"));
- assert_eq("2", "foo", vmime::stringUtils::trim("\t\tfoo"));
- assert_eq("3", "foo", vmime::stringUtils::trim(" \t \tfoo"));
- assert_eq("4", "foo", vmime::stringUtils::trim(" \r\n\tfoo"));
-
- assert_eq("5", "foo", vmime::stringUtils::trim("foo "));
- assert_eq("6", "foo", vmime::stringUtils::trim("foo\t\t"));
- assert_eq("7", "foo", vmime::stringUtils::trim("foo \t \t"));
- assert_eq("8", "foo", vmime::stringUtils::trim("foo \r\n\t"));
-
- assert_eq( "9", "foo", vmime::stringUtils::trim("foo "));
- assert_eq("10", "foo", vmime::stringUtils::trim(" foo "));
- assert_eq("11", "foo", vmime::stringUtils::trim(" foo\t\t"));
- assert_eq("12", "foo", vmime::stringUtils::trim("\tfoo \r \t"));
- assert_eq("13", "foo", vmime::stringUtils::trim("\r \tfoo \n\t"));
+ assert_eq("1", "foo", stringUtils::trim(" foo"));
+ assert_eq("2", "foo", stringUtils::trim("\t\tfoo"));
+ assert_eq("3", "foo", stringUtils::trim(" \t \tfoo"));
+ assert_eq("4", "foo", stringUtils::trim(" \r\n\tfoo"));
+
+ assert_eq("5", "foo", stringUtils::trim("foo "));
+ assert_eq("6", "foo", stringUtils::trim("foo\t\t"));
+ assert_eq("7", "foo", stringUtils::trim("foo \t \t"));
+ assert_eq("8", "foo", stringUtils::trim("foo \r\n\t"));
+
+ assert_eq( "9", "foo", stringUtils::trim("foo "));
+ assert_eq("10", "foo", stringUtils::trim(" foo "));
+ assert_eq("11", "foo", stringUtils::trim(" foo\t\t"));
+ assert_eq("12", "foo", stringUtils::trim("\tfoo \r \t"));
+ assert_eq("13", "foo", stringUtils::trim("\r \tfoo \n\t"));
}
void testCountASCIIChars()
{
vmime::string str1("foo");
assert_eq("1", static_cast <vmime::string::size_type>(3),
- vmime::stringUtils::countASCIIchars(str1.begin(), str1.end()));
+ stringUtils::countASCIIchars(str1.begin(), str1.end()));
vmime::string str2("f=?oo");
assert_eq("2", static_cast <vmime::string::size_type>(3 + 1),
- vmime::stringUtils::countASCIIchars(str2.begin(), str2.end()));
+ stringUtils::countASCIIchars(str2.begin(), str2.end()));
vmime::string str3("foo\x7f");
assert_eq("3", static_cast <vmime::string::size_type>(4),
- vmime::stringUtils::countASCIIchars(str3.begin(), str3.end()));
+ stringUtils::countASCIIchars(str3.begin(), str3.end()));
vmime::string str4("foo\x80");
assert_eq("4", static_cast <vmime::string::size_type>(3),
- vmime::stringUtils::countASCIIchars(str4.begin(), str4.end()));
+ stringUtils::countASCIIchars(str4.begin(), str4.end()));
}
public: