#include #include #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(testLinkify_Anchor); CPPUNIT_TEST(testLinkify_Plus); CPPUNIT_TEST_SUITE_END(); public: void testLinkify_URLWithResource() { String result = Linkify::linkify("http://swift.im/blog"); CPPUNIT_ASSERT_EQUAL( String("http://swift.im/blog"), result); } void testLinkify_URLWithEmptyResource() { String result = Linkify::linkify("http://swift.im/"); CPPUNIT_ASSERT_EQUAL( String("http://swift.im/"), result); } void testLinkify_BareURL() { String result = Linkify::linkify("http://swift.im"); CPPUNIT_ASSERT_EQUAL( String("http://swift.im"), result); } void testLinkify_URLSurroundedByWhitespace() { String result = Linkify::linkify("Foo http://swift.im/blog Bar"); CPPUNIT_ASSERT_EQUAL( String("Foo http://swift.im/blog 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 http://swift.im/blog Bar http://el-tramo.be/about Baz"), result); } void testLinkify_CamelCase() { String result = Linkify::linkify("http://fOo.cOm/bAz"); CPPUNIT_ASSERT_EQUAL( String("http://fOo.cOm/bAz"), result); } void testLinkify_HierarchicalResource() { String result = Linkify::linkify("http://foo.com/bar/baz/"); CPPUNIT_ASSERT_EQUAL( String("http://foo.com/bar/baz/"), result); } void testLinkify_Anchor() { String result = Linkify::linkify("http://foo.com/bar#baz"); CPPUNIT_ASSERT_EQUAL( String("http://foo.com/bar#baz"), result); } void testLinkify_Plus() { String result = Linkify::linkify("http://foo.com/bar+baz"); CPPUNIT_ASSERT_EQUAL( String("http://foo.com/bar+baz"), result); } }; CPPUNIT_TEST_SUITE_REGISTRATION(LinkifyTest);