summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-12-22 21:00:48 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-12-22 21:15:38 (GMT)
commit308ff634379e73a0c8668ffb0593d23f95b4dfa5 (patch)
tree21b0dd5fd9cbd90e141fd32449e298b65a40e04c /Swiften
parent333136df0bf355ef3ae3566f12bbdaf2795bcdaf (diff)
downloadswift-contrib-308ff634379e73a0c8668ffb0593d23f95b4dfa5.zip
swift-contrib-308ff634379e73a0c8668ffb0593d23f95b4dfa5.tar.bz2
Add a PreviousStatusStore.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Base/String.h4
-rw-r--r--Swiften/Base/UnitTest/StringTest.cpp16
2 files changed, 20 insertions, 0 deletions
diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h
index 0a5530c..7a6a9cc 100644
--- a/Swiften/Base/String.h
+++ b/Swiften/Base/String.h
@@ -94,6 +94,10 @@ namespace Swift {
return *this;
}
+ bool contains(const String& o) {
+ return data_.find(o.data_) != std::string::npos;
+ }
+
char operator[](size_t i) const {
return data_[i];
}
diff --git a/Swiften/Base/UnitTest/StringTest.cpp b/Swiften/Base/UnitTest/StringTest.cpp
index 6ad12fd..87e1a99 100644
--- a/Swiften/Base/UnitTest/StringTest.cpp
+++ b/Swiften/Base/UnitTest/StringTest.cpp
@@ -25,6 +25,9 @@ class StringTest : public CppUnit::TestFixture
CPPUNIT_TEST(testReplaceAll_MatchingReplace);
CPPUNIT_TEST(testGetLowerCase);
CPPUNIT_TEST(testSplit);
+ CPPUNIT_TEST(testContains);
+ CPPUNIT_TEST(testContainsFalse);
+ CPPUNIT_TEST(testContainsExact);
CPPUNIT_TEST_SUITE_END();
public:
@@ -158,6 +161,19 @@ class StringTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(String("def"), result[1]);
CPPUNIT_ASSERT_EQUAL(String("ghi"), result[2]);
}
+
+ void testContains() {
+ CPPUNIT_ASSERT(String("abcde").contains(String("bcd")));
+ }
+
+ void testContainsFalse() {
+ CPPUNIT_ASSERT(!String("abcde").contains(String("abcdef")));
+ }
+
+ void testContainsExact() {
+ CPPUNIT_ASSERT(String("abcde").contains(String("abcde")));
+ }
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(StringTest);