summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-02-28 02:25:45 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-02-28 02:25:45 +0000
commit20ba8c707adc2cafd76b2b29c59531d3ec0a7d94 (patch)
tree88cfbe969aa3acfa7ab1b34f718b3f43cdc8096e /test
parent87a229cab18679042beb06076e5dec1dcfadaeae (diff)
* Util.{h,cc}: added startsWith().
* CookieBox.cc: rewrited criteriaFind() using Util::startsWith() and Util::endsWith(). * SocketCore.cc: struct addrinfo is now zero-initialized. * common.h: added #include directive of limit.h. * DownloadEngine.cc: added #include directive of sys/time.h and algorithm. * Exception.h: added #include directive of stdio.h. * AbstractCommand.h: added #include directive of sys/time.h. * DownloadCommand.h: added #include directive of sys/time.h. * *.h: added #include directive of common.h to all base classes. subclasses' one was removed.
Diffstat (limited to 'test')
-rw-r--r--test/UtilTest.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/UtilTest.cc b/test/UtilTest.cc
index e6ab1a60..ec37edf4 100644
--- a/test/UtilTest.cc
+++ b/test/UtilTest.cc
@@ -12,6 +12,7 @@ class UtilTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testSlice);
CPPUNIT_TEST(testEndsWith);
CPPUNIT_TEST(testReplace);
+ CPPUNIT_TEST(testStartsWith);
CPPUNIT_TEST_SUITE_END();
private:
@@ -24,6 +25,7 @@ public:
void testSlice();
void testEndsWith();
void testReplace();
+ void testStartsWith();
};
@@ -121,3 +123,37 @@ void UtilTest::testReplace() {
CPPUNIT_ASSERT_EQUAL(string("abc"), Util::replace("abc", "", "a"));
CPPUNIT_ASSERT_EQUAL(string("xbc"), Util::replace("abc", "a", "x"));
}
+
+void UtilTest::testStartsWith() {
+ string target;
+ string part;
+
+ target = "abcdefg";
+ part = "abc";
+ CPPUNIT_ASSERT(Util::startsWith(target, part));
+
+ target = "abcdefg";
+ part = "abx";
+ CPPUNIT_ASSERT(!Util::startsWith(target, part));
+
+ target = "abcdefg";
+ part = "bcd";
+ CPPUNIT_ASSERT(!Util::startsWith(target, part));
+
+ target = "";
+ part = "a";
+ CPPUNIT_ASSERT(!Util::startsWith(target, part));
+
+ target = "";
+ part = "";
+ CPPUNIT_ASSERT(Util::startsWith(target, part));
+
+ target = "a";
+ part = "";
+ CPPUNIT_ASSERT(Util::startsWith(target, part));
+
+ target = "a";
+ part = "a";
+ CPPUNIT_ASSERT(Util::startsWith(target, part));
+
+}