-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BString: fix Split() for multiple characters separators...
as suggested by Janus in #14045. Thanks! * add a unit test for BString::Split().
- Loading branch information
Showing
5 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "StringSplitTest.h" | ||
#include "cppunit/TestCaller.h" | ||
#include <String.h> | ||
#include <StringList.h> | ||
|
||
StringSplitTest::StringSplitTest(std::string name) : | ||
BTestCase(name) | ||
{ | ||
} | ||
|
||
|
||
|
||
StringSplitTest::~StringSplitTest() | ||
{ | ||
} | ||
|
||
|
||
void | ||
StringSplitTest::PerformTest(void) | ||
{ | ||
BString *str1; | ||
|
||
NextSubTest(); | ||
BStringList stringList1; | ||
str1 = new BString("test::string"); | ||
str1->Split(":", true, stringList1); | ||
CPPUNIT_ASSERT(stringList1.CountStrings() == 2); | ||
delete str1; | ||
|
||
NextSubTest(); | ||
BStringList stringList2; | ||
str1 = new BString("test::string"); | ||
str1->Split("::", true, stringList2); | ||
CPPUNIT_ASSERT(stringList2.CountStrings() == 2); | ||
delete str1; | ||
|
||
NextSubTest(); | ||
BStringList stringList3; | ||
str1 = new BString("test::string"); | ||
str1->Split("::", false, stringList3); | ||
CPPUNIT_ASSERT(stringList3.CountStrings() == 2); | ||
delete str1; | ||
|
||
NextSubTest(); | ||
BStringList stringList4; | ||
str1 = new BString("test::string"); | ||
str1->Split(":", false, stringList4); | ||
CPPUNIT_ASSERT(stringList4.CountStrings() == 3); | ||
delete str1; | ||
|
||
} | ||
|
||
|
||
CppUnit::Test *StringSplitTest::suite(void) | ||
{ | ||
typedef CppUnit::TestCaller<StringSplitTest> | ||
StringSplitTestCaller; | ||
|
||
return(new StringSplitTestCaller("BString::Split Test", &StringSplitTest::PerformTest)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef StringSplitTest_H | ||
#define StringSplitTest_H | ||
|
||
#include "TestCase.h" | ||
#include <String.h> | ||
|
||
|
||
class StringSplitTest : public BTestCase | ||
{ | ||
|
||
private: | ||
|
||
protected: | ||
|
||
public: | ||
static Test *suite(void); | ||
void PerformTest(void); | ||
StringSplitTest(std::string name = ""); | ||
virtual ~StringSplitTest(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters