aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utility/stringUtilsTest.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2017-02-10 20:20:22 +0000
committerVincent Richard <[email protected]>2017-02-10 20:20:22 +0000
commit9a3d6880e844231404a4cfafe4e0349798eaacad (patch)
treef7987c26f11cae75e959c16b160346276cd61ac0 /tests/utility/stringUtilsTest.cpp
parentIssue #163: default encoder (fallback). (diff)
downloadvmime-9a3d6880e844231404a4cfafe4e0349798eaacad.tar.gz
vmime-9a3d6880e844231404a4cfafe4e0349798eaacad.zip
Fixed issue #160: invalid characters in hostname.
Diffstat (limited to 'tests/utility/stringUtilsTest.cpp')
-rw-r--r--tests/utility/stringUtilsTest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/utility/stringUtilsTest.cpp b/tests/utility/stringUtilsTest.cpp
index a21c2742..d86bbda0 100644
--- a/tests/utility/stringUtilsTest.cpp
+++ b/tests/utility/stringUtilsTest.cpp
@@ -43,6 +43,9 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VMIME_TEST(testCountASCIIChars)
VMIME_TEST(testUnquote)
+
+ VMIME_TEST(testIsValidHostname)
+ VMIME_TEST(testIsValidFQDN)
VMIME_TEST_LIST_END
@@ -160,5 +163,30 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("4", "quoted with \"escape\"", stringUtils::unquote("\"quoted with \\\"escape\\\"\"")); // "quoted with \"escape\""
}
+ void testIsValidHostname()
+ {
+ VASSERT_TRUE ("1", stringUtils::isValidHostname("localhost"));
+ VASSERT_TRUE ("2", stringUtils::isValidHostname("localhost.localdomain"));
+ VASSERT_TRUE ("3", stringUtils::isValidHostname("example.com"));
+ VASSERT_TRUE ("4", stringUtils::isValidHostname("host.example.com"));
+ VASSERT_FALSE("5", stringUtils::isValidHostname(".example.com"));
+ VASSERT_FALSE("6", stringUtils::isValidHostname(".-example.com"));
+ VASSERT_FALSE("7", stringUtils::isValidHostname(".example-.com"));
+ VASSERT_FALSE("8", stringUtils::isValidHostname(".exa--mple.com"));
+ VASSERT_FALSE("9", stringUtils::isValidHostname("-example.com"));
+ }
+
+ void testIsValidFQDN()
+ {
+ VASSERT_FALSE("1", stringUtils::isValidFQDN("localhost"));
+ VASSERT_FALSE("2", stringUtils::isValidFQDN("localhost.localdomain"));
+ VASSERT_FALSE("3", stringUtils::isValidFQDN("example.com"));
+ VASSERT_TRUE ("4", stringUtils::isValidFQDN("host.example.com"));
+ VASSERT_FALSE("5", stringUtils::isValidFQDN(".example.com"));
+ VASSERT_FALSE("6", stringUtils::isValidFQDN(".-example.com"));
+ VASSERT_FALSE("7", stringUtils::isValidFQDN(".example-.com"));
+ VASSERT_FALSE("8", stringUtils::isValidFQDN(".exa--mple.com"));
+ }
+
VMIME_TEST_SUITE_END