xref: /haiku/src/tests/kits/support/bstring/StringSplitTest.cpp (revision b31cb92f29fe89eaca84d173d0f70d38bf0c6a3d)
1 #include "StringSplitTest.h"
2 #include "cppunit/TestCaller.h"
3 #include <String.h>
4 #include <StringList.h>
5 
6 
7 StringSplitTest::StringSplitTest(std::string name)
8 		: BTestCase(name)
9 {
10 }
11 
12 
13 StringSplitTest::~StringSplitTest()
14 {
15 }
16 
17 
18 void
19 StringSplitTest::PerformTest(void)
20 {
21 	BString *str1;
22 
23 	NextSubTest();
24 	BStringList stringList1;
25 	str1 = new BString("test::string");
26 	str1->Split(":", true, stringList1);
27 	CPPUNIT_ASSERT_EQUAL(2, stringList1.CountStrings());
28 	delete str1;
29 
30 	NextSubTest();
31 	BStringList stringList2;
32 	str1 = new BString("test::string");
33 	str1->Split("::", true, stringList2);
34 	CPPUNIT_ASSERT_EQUAL(2, stringList2.CountStrings());
35 	delete str1;
36 
37 	NextSubTest();
38 	BStringList stringList3;
39 	str1 = new BString("test::string");
40 	str1->Split("::", false, stringList3);
41 	CPPUNIT_ASSERT_EQUAL(2, stringList3.CountStrings());
42 	delete str1;
43 
44 	NextSubTest();
45 	BStringList stringList4;
46 	str1 = new BString("test::string");
47 	str1->Split(":", false, stringList4);
48 	CPPUNIT_ASSERT_EQUAL(3, stringList4.CountStrings());
49 	delete str1;
50 
51 }
52 
53 
54 CppUnit::Test *StringSplitTest::suite(void)
55 {
56 	typedef CppUnit::TestCaller<StringSplitTest>
57 		StringSplitTestCaller;
58 
59 	return(new StringSplitTestCaller("BString::Split Test",
60 		&StringSplitTest::PerformTest));
61 }
62