summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-16 20:59:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-16 20:59:49 (GMT)
commitf9f84b3d960bfe92103235edef607d8db8d0b6b0 (patch)
tree6f2466f7c21c03a8abafcde53d1f2132159c042a
parent4d182bfb1621687a818f0a80fc77a392f381c5da (diff)
downloadswift-f9f84b3d960bfe92103235edef607d8db8d0b6b0.zip
swift-f9f84b3d960bfe92103235edef607d8db8d0b6b0.tar.bz2
Add another linkifier test.
-rw-r--r--SwifTools/UnitTest/LinkifyTest.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/SwifTools/UnitTest/LinkifyTest.cpp b/SwifTools/UnitTest/LinkifyTest.cpp
index a249d48..b55067c 100644
--- a/SwifTools/UnitTest/LinkifyTest.cpp
+++ b/SwifTools/UnitTest/LinkifyTest.cpp
@@ -1,69 +1,78 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include "SwifTools/Linkify.h"
using namespace Swift;
class LinkifyTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(LinkifyTest);
CPPUNIT_TEST(testLinkify_URLWithResource);
CPPUNIT_TEST(testLinkify_URLWithEmptyResource);
CPPUNIT_TEST(testLinkify_BareURL);
CPPUNIT_TEST(testLinkify_URLSurroundedByWhitespace);
CPPUNIT_TEST(testLinkify_MultipleURLs);
CPPUNIT_TEST(testLinkify_CamelCase);
+ CPPUNIT_TEST(testLinkify_HierarchicalResource);
CPPUNIT_TEST_SUITE_END();
public:
void testLinkify_URLWithResource() {
String result = Linkify::linkify("http://swift.im/blog");
CPPUNIT_ASSERT_EQUAL(
String("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"),
result);
}
void testLinkify_URLWithEmptyResource() {
String result = Linkify::linkify("http://swift.im/");
CPPUNIT_ASSERT_EQUAL(
String("<a href=\"http://swift.im/\">http://swift.im/</a>"),
result);
}
void testLinkify_BareURL() {
String result = Linkify::linkify("http://swift.im");
CPPUNIT_ASSERT_EQUAL(
String("<a href=\"http://swift.im\">http://swift.im</a>"),
result);
}
void testLinkify_URLSurroundedByWhitespace() {
String result = Linkify::linkify("Foo http://swift.im/blog Bar");
CPPUNIT_ASSERT_EQUAL(
String("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar"),
result);
}
void testLinkify_MultipleURLs() {
String result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz");
CPPUNIT_ASSERT_EQUAL(
String("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar <a href=\"http://el-tramo.be/about\">http://el-tramo.be/about</a> Baz"),
result);
}
void testLinkify_CamelCase() {
String result = Linkify::linkify("http://fOo.cOm/bAz");
CPPUNIT_ASSERT_EQUAL(
String("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"),
result);
}
+
+ void testLinkify_HierarchicalResource() {
+ String result = Linkify::linkify("http://foo.com/bar/baz/");
+
+ CPPUNIT_ASSERT_EQUAL(
+ String("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"),
+ result);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(LinkifyTest);