diff options
author | Vlad Voicu <vladv@rosedu.org> | 2012-01-19 21:49:08 (GMT) |
---|---|---|
committer | vlad <vlad@tyrion.(none)> | 2012-10-13 13:55:44 (GMT) |
commit | eca3a097403adbd85fe3b0cf366f29ecc37cacc6 (patch) | |
tree | dbc86052c3c5e8f98eee56af06b20d79261d27f0 /SwifTools/UnitTest | |
parent | 66d6e33635a22bfdfdd82ffab1b1693aa77f6181 (diff) | |
download | swift-contrib-eca3a097403adbd85fe3b0cf366f29ecc37cacc6.zip swift-contrib-eca3a097403adbd85fe3b0cf366f29ecc37cacc6.tar.bz2 |
Big spell checker chunk
Diffstat (limited to 'SwifTools/UnitTest')
-rw-r--r-- | SwifTools/UnitTest/SConscript | 1 | ||||
-rw-r--r-- | SwifTools/UnitTest/SpellParserTest.cpp | 51 |
2 files changed, 52 insertions, 0 deletions
diff --git a/SwifTools/UnitTest/SConscript b/SwifTools/UnitTest/SConscript index e469deb..913ef37 100644 --- a/SwifTools/UnitTest/SConscript +++ b/SwifTools/UnitTest/SConscript @@ -4,4 +4,5 @@ env.Append(UNITTEST_SOURCES = [ File("LinkifyTest.cpp"), File("TabCompleteTest.cpp"), File("LastLineTrackerTest.cpp"), + File("SpellParserTest.cpp"), ]) diff --git a/SwifTools/UnitTest/SpellParserTest.cpp b/SwifTools/UnitTest/SpellParserTest.cpp new file mode 100644 index 0000000..974f356 --- /dev/null +++ b/SwifTools/UnitTest/SpellParserTest.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012 Vlad Voicu + * Licensed under the Simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +#include <boost/algorithm/string.hpp> + +#include <SwifTools/SpellParser.h> + +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_[0])); + CPPUNIT_ASSERT_EQUAL(8, boost::get<1>(position_[0])); + CPPUNIT_ASSERT_EQUAL(9, boost::get<0>(position_[1])); + CPPUNIT_ASSERT_EQUAL(13, boost::get<1>(position_[1])); + } + 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_[0])); + CPPUNIT_ASSERT_EQUAL(21, boost::get<1>(position_[0])); + CPPUNIT_ASSERT_EQUAL(22, boost::get<0>(position_[1])); + CPPUNIT_ASSERT_EQUAL(26, boost::get<1>(position_[1])); + } + private: + SpellParser *parser_; + PositionPairVector position_; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(SpellParserTest); |