summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /SwifTools/UnitTest
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'SwifTools/UnitTest')
-rw-r--r--SwifTools/UnitTest/LastLineTrackerTest.cpp92
-rw-r--r--SwifTools/UnitTest/LinkifyTest.cpp448
-rw-r--r--SwifTools/UnitTest/SpellParserTest.cpp64
-rw-r--r--SwifTools/UnitTest/TabCompleteTest.cpp486
4 files changed, 545 insertions, 545 deletions
diff --git a/SwifTools/UnitTest/LastLineTrackerTest.cpp b/SwifTools/UnitTest/LastLineTrackerTest.cpp
index 97790e5..0fc77b6 100644
--- a/SwifTools/UnitTest/LastLineTrackerTest.cpp
+++ b/SwifTools/UnitTest/LastLineTrackerTest.cpp
@@ -12,53 +12,53 @@
using namespace Swift;
class LastLineTrackerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(LastLineTrackerTest);
- CPPUNIT_TEST(testFocusNormal);
- CPPUNIT_TEST(testFocusOut);
- CPPUNIT_TEST(testFocusOtherTab);
- CPPUNIT_TEST(testRepeatedFocusOut);
- CPPUNIT_TEST(testRepeatedFocusIn);
- CPPUNIT_TEST_SUITE_END();
- public:
- LastLineTrackerTest () {
- }
- void testFocusNormal() {
- LastLineTracker testling;
- testling.setHasFocus(true);
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- }
- void testFocusOut() {
- LastLineTracker testling;
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- }
- void testFocusOtherTab() {
- LastLineTracker testling;
- testling.setHasFocus(true);
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- }
+ CPPUNIT_TEST_SUITE(LastLineTrackerTest);
+ CPPUNIT_TEST(testFocusNormal);
+ CPPUNIT_TEST(testFocusOut);
+ CPPUNIT_TEST(testFocusOtherTab);
+ CPPUNIT_TEST(testRepeatedFocusOut);
+ CPPUNIT_TEST(testRepeatedFocusIn);
+ CPPUNIT_TEST_SUITE_END();
+ public:
+ LastLineTrackerTest () {
+ }
+ void testFocusNormal() {
+ LastLineTracker testling;
+ testling.setHasFocus(true);
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ }
+ void testFocusOut() {
+ LastLineTracker testling;
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ }
+ void testFocusOtherTab() {
+ LastLineTracker testling;
+ testling.setHasFocus(true);
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ }
- void testRepeatedFocusOut() {
- LastLineTracker testling;
- testling.setHasFocus(true);
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- }
- void testRepeatedFocusIn() {
- LastLineTracker testling;
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- testling.setHasFocus(true);
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- }
+ void testRepeatedFocusOut() {
+ LastLineTracker testling;
+ testling.setHasFocus(true);
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ }
+ void testRepeatedFocusIn() {
+ LastLineTracker testling;
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ testling.setHasFocus(true);
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(LastLineTrackerTest);
diff --git a/SwifTools/UnitTest/LinkifyTest.cpp b/SwifTools/UnitTest/LinkifyTest.cpp
index 663581d..69a0e23 100644
--- a/SwifTools/UnitTest/LinkifyTest.cpp
+++ b/SwifTools/UnitTest/LinkifyTest.cpp
@@ -12,230 +12,230 @@
using namespace Swift;
class LinkifyTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(LinkifyTest);
- CPPUNIT_TEST(testLinkify_URLWithResource);
- CPPUNIT_TEST(testLinkify_HTTPSURLWithResource);
- 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(testLinkify_Tilde);
- CPPUNIT_TEST(testLinkify_Equal);
- CPPUNIT_TEST(testLinkify_Authentication);
- CPPUNIT_TEST(testLinkify_At);
- CPPUNIT_TEST(testLinkify_Amps);
- CPPUNIT_TEST(testLinkify_UnicodeCharacter);
- CPPUNIT_TEST(testLinkify_NewLine);
- CPPUNIT_TEST(testLinkify_Tab);
- CPPUNIT_TEST(testLinkify_Action);
-
- CPPUNIT_TEST(testLinkify_SplitNone);
- CPPUNIT_TEST(testLinkify_SplitAll);
- CPPUNIT_TEST(testLinkify_SplitFirst);
- CPPUNIT_TEST(testLinkify_SplitSecond);
- CPPUNIT_TEST(testLinkify_SplitMiddle);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testLinkify_URLWithResource() {
- std::string result = Linkify::linkify("http://swift.im/blog");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"),
- result);
- }
-
- void testLinkify_HTTPSURLWithResource() {
- std::string result = Linkify::linkify("https://swift.im/blog");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"https://swift.im/blog\">https://swift.im/blog</a>"),
- result);
- }
-
- void testLinkify_URLWithEmptyResource() {
- std::string result = Linkify::linkify("http://swift.im/");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im/\">http://swift.im/</a>"),
- result);
- }
-
-
- void testLinkify_BareURL() {
- std::string result = Linkify::linkify("http://swift.im");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im\">http://swift.im</a>"),
- result);
- }
-
- void testLinkify_URLSurroundedByWhitespace() {
- std::string result = Linkify::linkify("Foo http://swift.im/blog Bar");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar"),
- result);
- }
-
- void testLinkify_MultipleURLs() {
- std::string result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::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() {
- std::string result = Linkify::linkify("http://fOo.cOm/bAz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"),
- result);
- }
-
- void testLinkify_HierarchicalResource() {
- std::string result = Linkify::linkify("http://foo.com/bar/baz/");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"),
- result);
- }
-
- void testLinkify_Anchor() {
- std::string result = Linkify::linkify("http://foo.com/bar#baz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"),
- result);
- }
-
- void testLinkify_Plus() {
- std::string result = Linkify::linkify("http://foo.com/bar+baz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"),
- result);
- }
-
- void testLinkify_Tilde() {
- std::string result = Linkify::linkify("http://foo.com/~kev/");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://foo.com/~kev/\">http://foo.com/~kev/</a>"),
- result);
- }
-
- void testLinkify_Equal() {
- std::string result = Linkify::linkify("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0\">http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0</a>"),
- result);
- }
-
- void testLinkify_Authentication() {
- std::string result = Linkify::linkify("http://bob:bla@swift.im/foo/bar");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://bob:bla@swift.im/foo/bar\">http://bob:bla@swift.im/foo/bar</a>"),
- result);
- }
-
- void testLinkify_At() {
- std::string result = Linkify::linkify("http://swift.im/foo@bar");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im/foo@bar\">http://swift.im/foo@bar</a>"),
- result);
- }
-
- void testLinkify_Amps() {
- std::string result = Linkify::linkify("http://swift.im/foo&bar&baz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im/foo&bar&baz\">http://swift.im/foo&bar&baz</a>"),
- result);
- }
-
- void testLinkify_UnicodeCharacter() {
- std::string result = Linkify::linkify("http://\xe2\x98\x83.net");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://\xe2\x98\x83.net\">http://\xe2\x98\x83.net</a>"),
- result);
- }
-
- void testLinkify_NewLine() {
- std::string result = Linkify::linkify("http://swift.im\nfoo");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im\">http://swift.im</a>\nfoo"),
- result);
- }
-
- void testLinkify_Tab() {
- std::string result = Linkify::linkify("http://swift.im\tfoo");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im\">http://swift.im</a>\tfoo"),
- result);
- }
-
- void testLinkify_Action() {
- std::string result = Linkify::linkify("*http://swift.im*");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("*<a href=\"http://swift.im\">http://swift.im</a>*"),
- result);
- }
-
- void checkResult(const std::string& testling, size_t expectedIndex, std::string expectedSplit[]) {
- std::pair<std::vector<std::string>, size_t> result = Linkify::splitLink(testling);
- CPPUNIT_ASSERT_EQUAL(expectedIndex, result.second);
- for (size_t i = 0; i < result.first.size(); i++) {
- CPPUNIT_ASSERT_EQUAL(expectedSplit[i], result.first[i]);
- }
- }
-
- void testLinkify_SplitNone() {
- std::string testling = "http this ain't";
- size_t expectedIndex = 1;
- std::string expectedSplit[] = {"http this ain't"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
-
- void testLinkify_SplitAll() {
- std::string testling = "http://swift.im";
- size_t expectedIndex = 0;
- std::string expectedSplit[] = {"http://swift.im"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
-
- void testLinkify_SplitFirst() {
- std::string testling = "http://swift.im is a link";
- size_t expectedIndex = 0;
- std::string expectedSplit[] = {"http://swift.im", " is a link"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
-
- void testLinkify_SplitSecond() {
- std::string testling = "this is a link: http://swift.im";
- size_t expectedIndex = 1;
- std::string expectedSplit[] = {"this is a link: ", "http://swift.im"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
-
- void testLinkify_SplitMiddle() {
- std::string testling = "Shove a link like http://swift.im in the middle";
- size_t expectedIndex = 1;
- std::string expectedSplit[] = {"Shove a link like ","http://swift.im", " in the middle"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
+ CPPUNIT_TEST_SUITE(LinkifyTest);
+ CPPUNIT_TEST(testLinkify_URLWithResource);
+ CPPUNIT_TEST(testLinkify_HTTPSURLWithResource);
+ 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(testLinkify_Tilde);
+ CPPUNIT_TEST(testLinkify_Equal);
+ CPPUNIT_TEST(testLinkify_Authentication);
+ CPPUNIT_TEST(testLinkify_At);
+ CPPUNIT_TEST(testLinkify_Amps);
+ CPPUNIT_TEST(testLinkify_UnicodeCharacter);
+ CPPUNIT_TEST(testLinkify_NewLine);
+ CPPUNIT_TEST(testLinkify_Tab);
+ CPPUNIT_TEST(testLinkify_Action);
+
+ CPPUNIT_TEST(testLinkify_SplitNone);
+ CPPUNIT_TEST(testLinkify_SplitAll);
+ CPPUNIT_TEST(testLinkify_SplitFirst);
+ CPPUNIT_TEST(testLinkify_SplitSecond);
+ CPPUNIT_TEST(testLinkify_SplitMiddle);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testLinkify_URLWithResource() {
+ std::string result = Linkify::linkify("http://swift.im/blog");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"),
+ result);
+ }
+
+ void testLinkify_HTTPSURLWithResource() {
+ std::string result = Linkify::linkify("https://swift.im/blog");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"https://swift.im/blog\">https://swift.im/blog</a>"),
+ result);
+ }
+
+ void testLinkify_URLWithEmptyResource() {
+ std::string result = Linkify::linkify("http://swift.im/");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im/\">http://swift.im/</a>"),
+ result);
+ }
+
+
+ void testLinkify_BareURL() {
+ std::string result = Linkify::linkify("http://swift.im");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>"),
+ result);
+ }
+
+ void testLinkify_URLSurroundedByWhitespace() {
+ std::string result = Linkify::linkify("Foo http://swift.im/blog Bar");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar"),
+ result);
+ }
+
+ void testLinkify_MultipleURLs() {
+ std::string result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::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() {
+ std::string result = Linkify::linkify("http://fOo.cOm/bAz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"),
+ result);
+ }
+
+ void testLinkify_HierarchicalResource() {
+ std::string result = Linkify::linkify("http://foo.com/bar/baz/");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"),
+ result);
+ }
+
+ void testLinkify_Anchor() {
+ std::string result = Linkify::linkify("http://foo.com/bar#baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"),
+ result);
+ }
+
+ void testLinkify_Plus() {
+ std::string result = Linkify::linkify("http://foo.com/bar+baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"),
+ result);
+ }
+
+ void testLinkify_Tilde() {
+ std::string result = Linkify::linkify("http://foo.com/~kev/");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://foo.com/~kev/\">http://foo.com/~kev/</a>"),
+ result);
+ }
+
+ void testLinkify_Equal() {
+ std::string result = Linkify::linkify("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0\">http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0</a>"),
+ result);
+ }
+
+ void testLinkify_Authentication() {
+ std::string result = Linkify::linkify("http://bob:bla@swift.im/foo/bar");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://bob:bla@swift.im/foo/bar\">http://bob:bla@swift.im/foo/bar</a>"),
+ result);
+ }
+
+ void testLinkify_At() {
+ std::string result = Linkify::linkify("http://swift.im/foo@bar");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im/foo@bar\">http://swift.im/foo@bar</a>"),
+ result);
+ }
+
+ void testLinkify_Amps() {
+ std::string result = Linkify::linkify("http://swift.im/foo&bar&baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im/foo&bar&baz\">http://swift.im/foo&bar&baz</a>"),
+ result);
+ }
+
+ void testLinkify_UnicodeCharacter() {
+ std::string result = Linkify::linkify("http://\xe2\x98\x83.net");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://\xe2\x98\x83.net\">http://\xe2\x98\x83.net</a>"),
+ result);
+ }
+
+ void testLinkify_NewLine() {
+ std::string result = Linkify::linkify("http://swift.im\nfoo");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>\nfoo"),
+ result);
+ }
+
+ void testLinkify_Tab() {
+ std::string result = Linkify::linkify("http://swift.im\tfoo");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>\tfoo"),
+ result);
+ }
+
+ void testLinkify_Action() {
+ std::string result = Linkify::linkify("*http://swift.im*");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("*<a href=\"http://swift.im\">http://swift.im</a>*"),
+ result);
+ }
+
+ void checkResult(const std::string& testling, size_t expectedIndex, std::string expectedSplit[]) {
+ std::pair<std::vector<std::string>, size_t> result = Linkify::splitLink(testling);
+ CPPUNIT_ASSERT_EQUAL(expectedIndex, result.second);
+ for (size_t i = 0; i < result.first.size(); i++) {
+ CPPUNIT_ASSERT_EQUAL(expectedSplit[i], result.first[i]);
+ }
+ }
+
+ void testLinkify_SplitNone() {
+ std::string testling = "http this ain't";
+ size_t expectedIndex = 1;
+ std::string expectedSplit[] = {"http this ain't"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
+
+ void testLinkify_SplitAll() {
+ std::string testling = "http://swift.im";
+ size_t expectedIndex = 0;
+ std::string expectedSplit[] = {"http://swift.im"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
+
+ void testLinkify_SplitFirst() {
+ std::string testling = "http://swift.im is a link";
+ size_t expectedIndex = 0;
+ std::string expectedSplit[] = {"http://swift.im", " is a link"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
+
+ void testLinkify_SplitSecond() {
+ std::string testling = "this is a link: http://swift.im";
+ size_t expectedIndex = 1;
+ std::string expectedSplit[] = {"this is a link: ", "http://swift.im"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
+
+ void testLinkify_SplitMiddle() {
+ std::string testling = "Shove a link like http://swift.im in the middle";
+ size_t expectedIndex = 1;
+ std::string expectedSplit[] = {"Shove a link like ","http://swift.im", " in the middle"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
};
diff --git a/SwifTools/UnitTest/SpellParserTest.cpp b/SwifTools/UnitTest/SpellParserTest.cpp
index 3747eb1..da233e5 100644
--- a/SwifTools/UnitTest/SpellParserTest.cpp
+++ b/SwifTools/UnitTest/SpellParserTest.cpp
@@ -20,38 +20,38 @@
using namespace Swift;
class SpellParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(SpellParserTest);
- CPPUNIT_TEST(testSimpleCheckFragment);
- CPPUNIT_TEST(testWWWCheckFragment);
- CPPUNIT_TEST_SUITE_END();
- public:
- SpellParserTest() {
- parser_ = new SpellParser();
- };
- void tearDown() {
- position_.clear();
- }
- void testSimpleCheckFragment() {
- parser_->check("fragment test", position_);
- int size = position_.size();
- CPPUNIT_ASSERT_EQUAL(2, size);
- CPPUNIT_ASSERT_EQUAL(0, boost::get<0>(position_.front()));
- CPPUNIT_ASSERT_EQUAL(8, boost::get<1>(position_.front()));
- CPPUNIT_ASSERT_EQUAL(9, boost::get<0>(position_.back()));
- CPPUNIT_ASSERT_EQUAL(13, boost::get<1>(position_.back()));
- }
- void testWWWCheckFragment() {
- parser_->check("www.link.com fragment test", position_);
- int size = position_.size();
- CPPUNIT_ASSERT_EQUAL(2, size);
- CPPUNIT_ASSERT_EQUAL(13, boost::get<0>(position_.front()));
- CPPUNIT_ASSERT_EQUAL(21, boost::get<1>(position_.front()));
- CPPUNIT_ASSERT_EQUAL(22, boost::get<0>(position_.back()));
- CPPUNIT_ASSERT_EQUAL(26, boost::get<1>(position_.back()));
- }
- private:
- SpellParser *parser_;
- PositionPairList position_;
+ CPPUNIT_TEST_SUITE(SpellParserTest);
+ CPPUNIT_TEST(testSimpleCheckFragment);
+ CPPUNIT_TEST(testWWWCheckFragment);
+ CPPUNIT_TEST_SUITE_END();
+ public:
+ SpellParserTest() {
+ parser_ = new SpellParser();
+ };
+ void tearDown() {
+ position_.clear();
+ }
+ void testSimpleCheckFragment() {
+ parser_->check("fragment test", position_);
+ int size = position_.size();
+ CPPUNIT_ASSERT_EQUAL(2, size);
+ CPPUNIT_ASSERT_EQUAL(0, boost::get<0>(position_.front()));
+ CPPUNIT_ASSERT_EQUAL(8, boost::get<1>(position_.front()));
+ CPPUNIT_ASSERT_EQUAL(9, boost::get<0>(position_.back()));
+ CPPUNIT_ASSERT_EQUAL(13, boost::get<1>(position_.back()));
+ }
+ void testWWWCheckFragment() {
+ parser_->check("www.link.com fragment test", position_);
+ int size = position_.size();
+ CPPUNIT_ASSERT_EQUAL(2, size);
+ CPPUNIT_ASSERT_EQUAL(13, boost::get<0>(position_.front()));
+ CPPUNIT_ASSERT_EQUAL(21, boost::get<1>(position_.front()));
+ CPPUNIT_ASSERT_EQUAL(22, boost::get<0>(position_.back()));
+ CPPUNIT_ASSERT_EQUAL(26, boost::get<1>(position_.back()));
+ }
+ private:
+ SpellParser *parser_;
+ PositionPairList position_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(SpellParserTest);
diff --git a/SwifTools/UnitTest/TabCompleteTest.cpp b/SwifTools/UnitTest/TabCompleteTest.cpp
index 2642410..56c91a8 100644
--- a/SwifTools/UnitTest/TabCompleteTest.cpp
+++ b/SwifTools/UnitTest/TabCompleteTest.cpp
@@ -12,254 +12,254 @@
using namespace Swift;
class TabCompleteTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(TabCompleteTest);
- CPPUNIT_TEST(testEmpty);
- CPPUNIT_TEST(testNoMatch);
- CPPUNIT_TEST(testOneMatch);
- CPPUNIT_TEST(testTwoMatch);
- CPPUNIT_TEST(testChangeMatch);
- CPPUNIT_TEST(testRemoveDuringComplete);
- CPPUNIT_TEST(testAddDuringComplete);
- CPPUNIT_TEST(testSwiftRoomSample);
- CPPUNIT_TEST_SUITE_END();
-
+ CPPUNIT_TEST_SUITE(TabCompleteTest);
+ CPPUNIT_TEST(testEmpty);
+ CPPUNIT_TEST(testNoMatch);
+ CPPUNIT_TEST(testOneMatch);
+ CPPUNIT_TEST(testTwoMatch);
+ CPPUNIT_TEST(testChangeMatch);
+ CPPUNIT_TEST(testRemoveDuringComplete);
+ CPPUNIT_TEST(testAddDuringComplete);
+ CPPUNIT_TEST(testSwiftRoomSample);
+ CPPUNIT_TEST_SUITE_END();
+
public:
- TabCompleteTest() {}
-
- void setUp() {
- completer_ = TabComplete();
- }
-
- void testEmpty() {
- std::string blah("Blah");
- CPPUNIT_ASSERT_EQUAL(
- blah,
- completer_.completeWord(blah));
- CPPUNIT_ASSERT_EQUAL(
- blah,
- completer_.completeWord(blah));
- }
-
- void testNoMatch() {
- completer_.addWord("Bleh");
- std::string blah("Blah");
- CPPUNIT_ASSERT_EQUAL(
- blah,
- completer_.completeWord(blah));
- CPPUNIT_ASSERT_EQUAL(
- blah,
- completer_.completeWord(blah));
- }
-
- void testOneMatch() {
- std::string short1("Bl");
- std::string long1("Blehling");
- completer_.addWord(long1);
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(short1));
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long1));
- }
-
- void testTwoMatch() {
- std::string short1("Hur");
- std::string long1("Hurgle");
- std::string long2("Hurdler");
- completer_.addWord(long1);
- completer_.addWord("Blah");
- completer_.addWord(long2);
- completer_.addWord("Bleh");
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(short1));
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long2));
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(long1));
- }
-
- void testChangeMatch() {
- std::string short1("Hur");
- std::string short2("Rub");
- std::string long1("Hurgle");
- std::string long2("Rubbish");
- completer_.addWord(long2);
- completer_.addWord("Blah");
- completer_.addWord(long1);
- completer_.addWord("Bleh");
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(short1));
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(short2));
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(long2));
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(short1));
- }
-
- void testRemoveDuringComplete() {
- std::string short1("Kev");
- std::string long1("Kevin");
- std::string long2("Kevlar");
- completer_.addWord(long1);
- completer_.addWord("Blah");
- completer_.addWord(long2);
- completer_.addWord("Bleh");
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(short1));
- completer_.removeWord(long2);
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long2));
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long1));
- }
-
- void testAddDuringComplete() {
- std::string short1("Rem");
- std::string long1("Remko");
- std::string long2("Remove");
- std::string long3("Remedial");
- completer_.addWord(long1);
- completer_.addWord("Blah");
- completer_.addWord(long2);
- completer_.addWord("Bleh");
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(short1));
- completer_.addWord(long3);
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long2));
- CPPUNIT_ASSERT_EQUAL(
- long3,
- completer_.completeWord(long1));
- }
-
- void testSwiftRoomSample() {
- std::string t("t");
- std::string Anpan("Anpan");
- std::string cdubouloz("cdubouloz");
- std::string Tobias("Tobias");
- std::string Zash("Zash");
- std::string lastsky("lastsky");
- std::string Steve("Steve Kille");
- std::string Flo("Flo");
- std::string Test("Test");
- std::string test("test");
- completer_.addWord(Anpan);
- completer_.addWord(cdubouloz);
- completer_.addWord(Tobias);
- completer_.addWord(lastsky);
- completer_.addWord(Steve);
- completer_.addWord(Flo);
- completer_.addWord(Zash);
-
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Tobias));
-
- completer_.addWord(Test);
-
- CPPUNIT_ASSERT_EQUAL(
- Test,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Test));
- CPPUNIT_ASSERT_EQUAL(
- Test,
- completer_.completeWord(Tobias));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Test));
-
- completer_.addWord(Zash);
- completer_.addWord(Zash);
- completer_.addWord(Zash);
- completer_.addWord(Zash);
-
- completer_.removeWord(Test);
-
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Tobias));
-
- completer_.addWord(test);
-
- completer_.addWord(Zash);
- completer_.addWord(Zash);
- completer_.addWord(Zash);
- completer_.addWord(Zash);
-
-
- CPPUNIT_ASSERT_EQUAL(
- test,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(test));
- CPPUNIT_ASSERT_EQUAL(
- test,
- completer_.completeWord(Tobias));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(test));
-
- completer_.removeWord(test);
-
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Tobias));
-
- completer_.removeWord(Tobias);
- CPPUNIT_ASSERT_EQUAL(
- t,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- t,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- t,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- t,
- completer_.completeWord(t));
-
- completer_.addWord(Tobias);
-
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Tobias));
-
- }
+ TabCompleteTest() {}
+
+ void setUp() {
+ completer_ = TabComplete();
+ }
+
+ void testEmpty() {
+ std::string blah("Blah");
+ CPPUNIT_ASSERT_EQUAL(
+ blah,
+ completer_.completeWord(blah));
+ CPPUNIT_ASSERT_EQUAL(
+ blah,
+ completer_.completeWord(blah));
+ }
+
+ void testNoMatch() {
+ completer_.addWord("Bleh");
+ std::string blah("Blah");
+ CPPUNIT_ASSERT_EQUAL(
+ blah,
+ completer_.completeWord(blah));
+ CPPUNIT_ASSERT_EQUAL(
+ blah,
+ completer_.completeWord(blah));
+ }
+
+ void testOneMatch() {
+ std::string short1("Bl");
+ std::string long1("Blehling");
+ completer_.addWord(long1);
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(short1));
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long1));
+ }
+
+ void testTwoMatch() {
+ std::string short1("Hur");
+ std::string long1("Hurgle");
+ std::string long2("Hurdler");
+ completer_.addWord(long1);
+ completer_.addWord("Blah");
+ completer_.addWord(long2);
+ completer_.addWord("Bleh");
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(short1));
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long2));
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(long1));
+ }
+
+ void testChangeMatch() {
+ std::string short1("Hur");
+ std::string short2("Rub");
+ std::string long1("Hurgle");
+ std::string long2("Rubbish");
+ completer_.addWord(long2);
+ completer_.addWord("Blah");
+ completer_.addWord(long1);
+ completer_.addWord("Bleh");
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(short1));
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(short2));
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(long2));
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(short1));
+ }
+
+ void testRemoveDuringComplete() {
+ std::string short1("Kev");
+ std::string long1("Kevin");
+ std::string long2("Kevlar");
+ completer_.addWord(long1);
+ completer_.addWord("Blah");
+ completer_.addWord(long2);
+ completer_.addWord("Bleh");
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(short1));
+ completer_.removeWord(long2);
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long2));
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long1));
+ }
+
+ void testAddDuringComplete() {
+ std::string short1("Rem");
+ std::string long1("Remko");
+ std::string long2("Remove");
+ std::string long3("Remedial");
+ completer_.addWord(long1);
+ completer_.addWord("Blah");
+ completer_.addWord(long2);
+ completer_.addWord("Bleh");
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(short1));
+ completer_.addWord(long3);
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long2));
+ CPPUNIT_ASSERT_EQUAL(
+ long3,
+ completer_.completeWord(long1));
+ }
+
+ void testSwiftRoomSample() {
+ std::string t("t");
+ std::string Anpan("Anpan");
+ std::string cdubouloz("cdubouloz");
+ std::string Tobias("Tobias");
+ std::string Zash("Zash");
+ std::string lastsky("lastsky");
+ std::string Steve("Steve Kille");
+ std::string Flo("Flo");
+ std::string Test("Test");
+ std::string test("test");
+ completer_.addWord(Anpan);
+ completer_.addWord(cdubouloz);
+ completer_.addWord(Tobias);
+ completer_.addWord(lastsky);
+ completer_.addWord(Steve);
+ completer_.addWord(Flo);
+ completer_.addWord(Zash);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Tobias));
+
+ completer_.addWord(Test);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Test,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Test));
+ CPPUNIT_ASSERT_EQUAL(
+ Test,
+ completer_.completeWord(Tobias));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Test));
+
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+
+ completer_.removeWord(Test);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Tobias));
+
+ completer_.addWord(test);
+
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+
+
+ CPPUNIT_ASSERT_EQUAL(
+ test,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(test));
+ CPPUNIT_ASSERT_EQUAL(
+ test,
+ completer_.completeWord(Tobias));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(test));
+
+ completer_.removeWord(test);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Tobias));
+
+ completer_.removeWord(Tobias);
+ CPPUNIT_ASSERT_EQUAL(
+ t,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ t,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ t,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ t,
+ completer_.completeWord(t));
+
+ completer_.addWord(Tobias);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Tobias));
+
+ }
private:
- TabComplete completer_;
+ TabComplete completer_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(TabCompleteTest);