xref: /haiku/src/tests/kits/support/bstring/StringCaseTest.cpp (revision eee13b4d9a4bda5ddd1b627845c43a7c905bef19)
1 #include "StringCaseTest.h"
2 #include "cppunit/TestCaller.h"
3 #include <String.h>
4 
5 StringCaseTest::StringCaseTest(std::string name) :
6 		BTestCase(name)
7 {
8 }
9 
10 
11 
12 StringCaseTest::~StringCaseTest()
13 {
14 }
15 
16 
17 void
18 StringCaseTest::PerformTest(void)
19 {
20 	BString *string;
21 
22 	//Capitalize
23 	NextSubTest();
24 	string = new BString("this is a sentence");
25 	string->Capitalize();
26 	CPPUNIT_ASSERT(strcmp(string->String(), "This is a sentence") == 0);
27 	delete string;
28 
29 	NextSubTest();
30 	string = new BString("134this is a sentence");
31 	string->Capitalize();
32 	CPPUNIT_ASSERT(strcmp(string->String(), "134this is a sentence") == 0);
33 	delete string;
34 
35 	//ToLower
36 	NextSubTest();
37 	string = new BString("1a2B3c4d5e6f7G");
38 	string->ToLower();
39 	CPPUNIT_ASSERT(strcmp(string->String(), "1a2b3c4d5e6f7g") == 0);
40 	delete string;
41 
42 	//ToUpper
43 	NextSubTest();
44 	string = new BString("1a2b3c4d5E6f7g");
45 	string->ToUpper();
46 	CPPUNIT_ASSERT(strcmp(string->String(), "1A2B3C4D5E6F7G") == 0);
47 	delete string;
48 
49 	//CapitalizeEachWord
50 	NextSubTest();
51 	string = new BString("each wOrd 3will_be >capiTalized");
52 	string->CapitalizeEachWord();
53 	CPPUNIT_ASSERT(strcmp(string->String(), "Each Word 3Will_Be >Capitalized") == 0);
54 	delete string;
55 }
56 
57 
58 CppUnit::Test *StringCaseTest::suite(void)
59 {
60 	typedef CppUnit::TestCaller<StringCaseTest>
61 		StringCaseTestCaller;
62 
63 	return(new StringCaseTestCaller("BString::Case Test", &StringCaseTest::PerformTest));
64 }
65