1 #include "StringEscapeTest.h"
2 #include "cppunit/TestCaller.h"
5 StringEscapeTest::StringEscapeTest(std::string name
) :
12 StringEscapeTest::~StringEscapeTest()
18 StringEscapeTest::PerformTest(void)
22 //CharacterEscape(char*, char)
24 string1
= new BString("abcdefghi");
25 string1
->CharacterEscape("acf", '/');
26 CPPUNIT_ASSERT(strcmp(string1
->String(), "/ab/cde/fghi") == 0);
31 string1
= new BString
;
32 string1
->CharacterEscape("abc", '/');
33 CPPUNIT_ASSERT(strcmp(string1
->String(), "") == 0);
36 //BString doesn't contain wanted characters
38 string1
= new BString("abcdefghi");
39 string1
->CharacterEscape("z34", 'z');
40 CPPUNIT_ASSERT(strcmp(string1
->String(), "abcdefghi") == 0);
43 //CharacterEscape(char *, char*, char)
45 string1
= new BString("something");
46 string1
->CharacterEscape("newstring", "esi", '0');
47 CPPUNIT_ASSERT(strcmp(string1
->String(), "n0ew0str0ing") == 0);
51 //assigned string is NULL
52 //it crashes r5 implementation, but not ours :)
54 string1
= new BString("something");
55 string1
->CharacterEscape((char*)NULL
, "ei", '-');
56 CPPUNIT_ASSERT(strcmp(string1
->String(), "") == 0);
62 string1
= new BString
;
63 string1
->CharacterEscape("newstring", "esi", '0');
64 CPPUNIT_ASSERT(strcmp(string1
->String(), "n0ew0str0ing") == 0);
67 //CharacterDeescape(char)
69 string1
= new BString("/a/nh/g/bhhgy/fgtuhjkb/");
70 string1
->CharacterDeescape('/');
71 CPPUNIT_ASSERT(strcmp(string1
->String(), "anhgbhhgyfgtuhjkb") == 0);
76 string1
= new BString
;
77 string1
->CharacterDeescape('/');
78 CPPUNIT_ASSERT(strcmp(string1
->String(), "") == 0);
81 //String doesn't contain character to escape
83 string1
= new BString("/a/nh/g/bhhgy/fgtuhjkb/");
84 string1
->CharacterDeescape('-');
85 CPPUNIT_ASSERT(strcmp(string1
->String(), "/a/nh/g/bhhgy/fgtuhjkb/") == 0);
88 //CharacterDeescape(char* original, char)
90 string1
= new BString("oldString");
91 string1
->CharacterDeescape("-ne-ws-tri-ng-", '-');
92 CPPUNIT_ASSERT(strcmp(string1
->String(), "newstring") == 0);
97 string1
= new BString
;
98 string1
->CharacterDeescape("new/str/ing", '/');
99 CPPUNIT_ASSERT(strcmp(string1
->String(), "newstring") == 0);
103 //assigned string is empty
104 //it crashes r5 implementation, but not ours :)
106 string1
= new BString("pippo");
107 string1
->CharacterDeescape((char*)NULL
, '/');
108 CPPUNIT_ASSERT(strcmp(string1
->String(), "") == 0);
112 //String doesn't contain character to escape
114 string1
= new BString("Old");
115 string1
->CharacterDeescape("/a/nh/g/bhhgy/fgtuhjkb/", '-');
116 CPPUNIT_ASSERT(strcmp(string1
->String(), "/a/nh/g/bhhgy/fgtuhjkb/") == 0);
121 CppUnit::Test
*StringEscapeTest::suite(void)
123 typedef CppUnit::TestCaller
<StringEscapeTest
>
124 StringEscapeTestCaller
;
126 return(new StringEscapeTestCaller("BString::Escape Test", &StringEscapeTest::PerformTest
));