xref: /haiku/src/tests/kits/support/bstring/StringSubCopyTest.cpp (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 #include "StringSubCopyTest.h"
2 #include "cppunit/TestCaller.h"
3 #include <String.h>
4 #include <stdio.h>
5 
6 StringSubCopyTest::StringSubCopyTest(std::string name) :
7 		BTestCase(name)
8 {
9 }
10 
11 
12 
13 StringSubCopyTest::~StringSubCopyTest()
14 {
15 }
16 
17 
18 void
19 StringSubCopyTest::PerformTest(void)
20 {
21 	BString *string1, *string2;
22 
23 	//CopyInto(BString&, int32, int32)
24 	NextSubTest();
25 	string1 = new BString;
26 	string2 = new BString("Something");
27 	string2->CopyInto(*string1, 4, 30);
28 	CPPUNIT_ASSERT(strcmp(string1->String(), "thing") == 0);
29 	delete string1;
30 	delete string2;
31 
32 	//CopyInto(const char*, int32, int32)
33 	NextSubTest();
34 	char tmp[10];
35 	memset(tmp, 0, 10);
36 	string1 = new BString("ABC");
37 	string1->CopyInto(tmp, 0, 4);
38 	CPPUNIT_ASSERT(strcmp(tmp, "ABC") == 0);
39 	CPPUNIT_ASSERT(strcmp(string1->String(), "ABC") == 0);
40 	delete string1;
41 }
42 
43 
44 CppUnit::Test *StringSubCopyTest::suite(void)
45 {
46 	typedef CppUnit::TestCaller<StringSubCopyTest>
47 		StringSubCopyTestCaller;
48 
49 	return(new StringSubCopyTestCaller("BString::SubCopy Test", &StringSubCopyTest::PerformTest));
50 }
51