1 #include "StringSubCopyTest.h" 2 #include "cppunit/TestCaller.h" 3 #include <String.h> 4 #include <stdio.h> 5 6 7 StringSubCopyTest::StringSubCopyTest(std::string name) 8 : BTestCase(name) 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", 50 &StringSubCopyTest::PerformTest)); 51 } 52