Support kit: Fixed issues in BString unit tests
1: Changed CPPUNIT_ASSERT -> CPPUNIT_ASSERT_EQUAL 2: Fixed coding style: Added two lines after including libraries, maintained 80 characters(MAX) in each line and space at comment start 3: Fixed the failure for "BString::Search" test "i != 0 by chaning the testing method(StartsWith->IStartsWith) and changed the string to be searched(sT->st) Change-Id: I1237d1f2d0e3af7757963cc940bae929f487f088
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
#include <String.h>
|
||||
#include <UTF8.h>
|
||||
|
||||
StringAccessTest::StringAccessTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringAccessTest::StringAccessTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringAccessTest::~StringAccessTest()
|
||||
{
|
||||
}
|
||||
@@ -93,5 +93,6 @@ CppUnit::Test *StringAccessTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringAccessTest>
|
||||
StringAccessTestCaller;
|
||||
|
||||
return(new StringAccessTestCaller("BString::Access Test", &StringAccessTest::PerformTest));
|
||||
return(new StringAccessTestCaller("BString::Access Test",
|
||||
&StringAccessTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
|
||||
StringAppendTest::StringAppendTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringAppendTest::StringAppendTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringAppendTest::~StringAppendTest()
|
||||
{
|
||||
}
|
||||
@@ -143,5 +143,6 @@ CppUnit::Test *StringAppendTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringAppendTest>
|
||||
StringAppendTestCaller;
|
||||
|
||||
return(new StringAppendTestCaller("BString::Append Test", &StringAppendTest::PerformTest));
|
||||
return(new StringAppendTestCaller("BString::Append Test",
|
||||
&StringAppendTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
#include <String.h>
|
||||
|
||||
|
||||
StringAssignTest::StringAssignTest(std::string name) :
|
||||
BTestCase(name)
|
||||
StringAssignTest::StringAssignTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringAssignTest::~StringAssignTest()
|
||||
{
|
||||
}
|
||||
@@ -123,5 +122,6 @@ CppUnit::Test *StringAssignTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringAssignTest>
|
||||
StringAssignTestCaller;
|
||||
|
||||
return(new StringAssignTestCaller("BString::Assign Test", &StringAssignTest::PerformTest));
|
||||
return(new StringAssignTestCaller("BString::Assign Test",
|
||||
&StringAssignTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
|
||||
StringCaseTest::StringCaseTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringCaseTest::StringCaseTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringCaseTest::~StringCaseTest()
|
||||
{
|
||||
}
|
||||
@@ -84,5 +84,6 @@ CppUnit::Test *StringCaseTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringCaseTest>
|
||||
StringCaseTestCaller;
|
||||
|
||||
return(new StringCaseTestCaller("BString::Case Test", &StringCaseTest::PerformTest));
|
||||
return(new StringCaseTestCaller("BString::Case Test",
|
||||
&StringCaseTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
#include <String.h>
|
||||
|
||||
|
||||
StringCharAccessTest::StringCharAccessTest(std::string name) :
|
||||
BTestCase(name)
|
||||
StringCharAccessTest::StringCharAccessTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringCharAccessTest::~StringCharAccessTest()
|
||||
{
|
||||
}
|
||||
@@ -44,5 +43,6 @@ CppUnit::Test *StringCharAccessTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringCharAccessTest>
|
||||
StringCharAccessTestCaller;
|
||||
|
||||
return(new StringCharAccessTestCaller("BString::CharAccess Test", &StringCharAccessTest::PerformTest));
|
||||
return(new StringCharAccessTestCaller("BString::CharAccess Test",
|
||||
&StringCharAccessTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
|
||||
StringCompareTest::StringCompareTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringCompareTest::StringCompareTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringCompareTest::~StringCompareTest()
|
||||
{
|
||||
}
|
||||
@@ -150,5 +150,6 @@ CppUnit::Test *StringCompareTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringCompareTest>
|
||||
StringCompareTestCaller;
|
||||
|
||||
return(new StringCompareTestCaller("BString::Compare Test", &StringCompareTest::PerformTest));
|
||||
return(new StringCompareTestCaller("BString::Compare Test",
|
||||
&StringCompareTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
#include <String.h>
|
||||
|
||||
|
||||
StringConstructionTest::StringConstructionTest(std::string name) :
|
||||
BTestCase(name)
|
||||
StringConstructionTest::StringConstructionTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringConstructionTest::~StringConstructionTest()
|
||||
{
|
||||
}
|
||||
@@ -71,5 +70,6 @@ CppUnit::Test *StringConstructionTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringConstructionTest>
|
||||
StringConstructionTestCaller;
|
||||
|
||||
return(new StringConstructionTestCaller("BString::Construction Test", &StringConstructionTest::PerformTest));
|
||||
return(new StringConstructionTestCaller("BString::Construction Test",
|
||||
&StringConstructionTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
|
||||
StringEscapeTest::StringEscapeTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringEscapeTest::StringEscapeTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringEscapeTest::~StringEscapeTest()
|
||||
{
|
||||
}
|
||||
@@ -123,5 +123,6 @@ CppUnit::Test *StringEscapeTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringEscapeTest>
|
||||
StringEscapeTestCaller;
|
||||
|
||||
return(new StringEscapeTestCaller("BString::Escape Test", &StringEscapeTest::PerformTest));
|
||||
return(new StringEscapeTestCaller("BString::Escape Test",
|
||||
&StringEscapeTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
|
||||
StringFormatAppendTest::StringFormatAppendTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringFormatAppendTest::StringFormatAppendTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringFormatAppendTest::~StringFormatAppendTest()
|
||||
{
|
||||
}
|
||||
@@ -113,7 +113,8 @@ StringFormatAppendTest::PerformTest(void)
|
||||
// Misc test
|
||||
NextSubTest();
|
||||
BString s;
|
||||
s << "This" << ' ' << "is" << ' ' << 'a' << ' ' << "test" << ' ' << "sentence";
|
||||
s << "This" << ' ' << "is" << ' ' << 'a' << ' ' << "test"
|
||||
<< ' ' << "sentence";
|
||||
CPPUNIT_ASSERT(strcmp(s.String(), "This is a test sentence") == 0);
|
||||
}
|
||||
|
||||
@@ -123,5 +124,6 @@ CppUnit::Test *StringFormatAppendTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringFormatAppendTest>
|
||||
StringFormatAppendTestCaller;
|
||||
|
||||
return(new StringFormatAppendTestCaller("BString::FormatAppend Test", &StringFormatAppendTest::PerformTest));
|
||||
return(new StringFormatAppendTestCaller("BString::FormatAppend Test",
|
||||
&StringFormatAppendTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
|
||||
StringInsertTest::StringInsertTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringInsertTest::StringInsertTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringInsertTest::~StringInsertTest()
|
||||
{
|
||||
}
|
||||
@@ -143,5 +143,6 @@ CppUnit::Test *StringInsertTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringInsertTest>
|
||||
StringInsertTestCaller;
|
||||
|
||||
return(new StringInsertTestCaller("BString::Insert Test", &StringInsertTest::PerformTest));
|
||||
return(new StringInsertTestCaller("BString::Insert Test",
|
||||
&StringInsertTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#include <String.h>
|
||||
#include <UTF8.h>
|
||||
|
||||
StringPrependTest::StringPrependTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringPrependTest::StringPrependTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringPrependTest::~StringPrependTest()
|
||||
{
|
||||
}
|
||||
@@ -81,5 +81,6 @@ CppUnit::Test *StringPrependTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringPrependTest>
|
||||
StringPrependTestCaller;
|
||||
|
||||
return(new StringPrependTestCaller("BString::Prepend Test", &StringPrependTest::PerformTest));
|
||||
return(new StringPrependTestCaller("BString::Prepend Test",
|
||||
&StringPrependTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#include <String.h>
|
||||
#include <stdio.h>
|
||||
|
||||
StringRemoveTest::StringRemoveTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringRemoveTest::StringRemoveTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringRemoveTest::~StringRemoveTest()
|
||||
{
|
||||
}
|
||||
@@ -252,5 +252,6 @@ CppUnit::Test *StringRemoveTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringRemoveTest>
|
||||
StringRemoveTestCaller;
|
||||
|
||||
return(new StringRemoveTestCaller("BString::Remove Test", &StringRemoveTest::PerformTest));
|
||||
return(new StringRemoveTestCaller("BString::Remove Test",
|
||||
&StringRemoveTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
|
||||
StringReplaceTest::StringReplaceTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringReplaceTest::StringReplaceTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringReplaceTest::~StringReplaceTest()
|
||||
{
|
||||
}
|
||||
@@ -76,13 +76,15 @@ StringReplaceTest::PerformTest(void)
|
||||
NextSubTest();
|
||||
str1 = new BString("she sells sea shells on the sea shore");
|
||||
str1->Replace('s', 't', 4, 2);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "she tellt tea thells on the sea shore") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(),
|
||||
"she tellt tea thells on the sea shore") == 0);
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
str1 = new BString("she sells sea shells on the sea shore");
|
||||
str1->Replace('s', 's', 4, 2);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "she sells sea shells on the sea shore") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(),
|
||||
"she sells sea shells on the sea shore") == 0);
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
@@ -210,13 +212,15 @@ StringReplaceTest::PerformTest(void)
|
||||
NextSubTest();
|
||||
str1 = new BString("She sells Sea shells on the sea shore");
|
||||
str1->IReplace('s', 't', 4, 2);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "She tellt tea thells on the sea shore") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(),
|
||||
"She tellt tea thells on the sea shore") == 0);
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
str1 = new BString("She sells Sea shells on the sea shore");
|
||||
str1->IReplace('s', 's', 4, 2);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "She sells sea shells on the sea shore") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(),
|
||||
"She sells sea shells on the sea shore") == 0);
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
@@ -382,5 +386,6 @@ CppUnit::Test *StringReplaceTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringReplaceTest>
|
||||
StringReplaceTestCaller;
|
||||
|
||||
return(new StringReplaceTestCaller("BString::Replace Test", &StringReplaceTest::PerformTest));
|
||||
return(new StringReplaceTestCaller("BString::Replace Test",
|
||||
&StringReplaceTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#include <String.h>
|
||||
#include <stdio.h>
|
||||
|
||||
StringSearchTest::StringSearchTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringSearchTest::StringSearchTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringSearchTest::~StringSearchTest()
|
||||
{
|
||||
}
|
||||
@@ -416,7 +416,7 @@ StringSearchTest::PerformTest(void)
|
||||
NextSubTest();
|
||||
string1 = new BString("last but not least");
|
||||
string2 = new BString("lAsT");
|
||||
i = (int32)string1->StartsWith(*string2);
|
||||
i = (int32)string1->IStartsWith(*string2);
|
||||
CPPUNIT_ASSERT(i != 0);
|
||||
delete string1;
|
||||
delete string2;
|
||||
@@ -424,14 +424,14 @@ StringSearchTest::PerformTest(void)
|
||||
// IStartsWith(const char*)
|
||||
NextSubTest();
|
||||
string1 = new BString("last but not least");
|
||||
i = (int32)string1->StartsWith("lAsT");
|
||||
i = (int32)string1->IStartsWith("lAsT");
|
||||
CPPUNIT_ASSERT(i != 0);
|
||||
delete string1;
|
||||
|
||||
// IStartsWith(const char*, int32)
|
||||
NextSubTest();
|
||||
string1 = new BString("last but not least");
|
||||
i = (int32)string1->StartsWith("lAsT", 4);
|
||||
i = (int32)string1->IStartsWith("lAsT", 4);
|
||||
CPPUNIT_ASSERT(i != 0);
|
||||
delete string1;
|
||||
|
||||
@@ -485,7 +485,7 @@ StringSearchTest::PerformTest(void)
|
||||
// EndsWith(const char*, int32)
|
||||
NextSubTest();
|
||||
string1 = new BString("last but not least");
|
||||
i = (int32)string1->EndsWith("sT", 2);
|
||||
i = (int32)string1->EndsWith("st", 2);
|
||||
CPPUNIT_ASSERT(i != 0);
|
||||
delete string1;
|
||||
|
||||
@@ -636,5 +636,6 @@ CppUnit::Test *StringSearchTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringSearchTest>
|
||||
StringSearchTestCaller;
|
||||
|
||||
return(new StringSearchTestCaller("BString::Search Test", &StringSearchTest::PerformTest));
|
||||
return(new StringSearchTestCaller("BString::Search Test",
|
||||
&StringSearchTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#include <String.h>
|
||||
#include <StringList.h>
|
||||
|
||||
StringSplitTest::StringSplitTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringSplitTest::StringSplitTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringSplitTest::~StringSplitTest()
|
||||
{
|
||||
}
|
||||
@@ -24,28 +24,28 @@ StringSplitTest::PerformTest(void)
|
||||
BStringList stringList1;
|
||||
str1 = new BString("test::string");
|
||||
str1->Split(":", true, stringList1);
|
||||
CPPUNIT_ASSERT(stringList1.CountStrings() == 2);
|
||||
CPPUNIT_ASSERT_EQUAL(2, stringList1.CountStrings());
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
BStringList stringList2;
|
||||
str1 = new BString("test::string");
|
||||
str1->Split("::", true, stringList2);
|
||||
CPPUNIT_ASSERT(stringList2.CountStrings() == 2);
|
||||
CPPUNIT_ASSERT_EQUAL(2, stringList2.CountStrings());
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
BStringList stringList3;
|
||||
str1 = new BString("test::string");
|
||||
str1->Split("::", false, stringList3);
|
||||
CPPUNIT_ASSERT(stringList3.CountStrings() == 2);
|
||||
CPPUNIT_ASSERT_EQUAL(2, stringList3.CountStrings());
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
BStringList stringList4;
|
||||
str1 = new BString("test::string");
|
||||
str1->Split(":", false, stringList4);
|
||||
CPPUNIT_ASSERT(stringList4.CountStrings() == 3);
|
||||
CPPUNIT_ASSERT_EQUAL(3, stringList4.CountStrings());
|
||||
delete str1;
|
||||
|
||||
}
|
||||
@@ -56,5 +56,6 @@ CppUnit::Test *StringSplitTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringSplitTest>
|
||||
StringSplitTestCaller;
|
||||
|
||||
return(new StringSplitTestCaller("BString::Split Test", &StringSplitTest::PerformTest));
|
||||
return(new StringSplitTestCaller("BString::Split Test",
|
||||
&StringSplitTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#include <String.h>
|
||||
#include <stdio.h>
|
||||
|
||||
StringSubCopyTest::StringSubCopyTest(std::string name) :
|
||||
BTestCase(name)
|
||||
|
||||
StringSubCopyTest::StringSubCopyTest(std::string name)
|
||||
: BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringSubCopyTest::~StringSubCopyTest()
|
||||
{
|
||||
}
|
||||
@@ -46,5 +46,6 @@ CppUnit::Test *StringSubCopyTest::suite(void)
|
||||
typedef CppUnit::TestCaller<StringSubCopyTest>
|
||||
StringSubCopyTestCaller;
|
||||
|
||||
return(new StringSubCopyTestCaller("BString::SubCopy Test", &StringSubCopyTest::PerformTest));
|
||||
return(new StringSubCopyTestCaller("BString::SubCopy Test",
|
||||
&StringSubCopyTest::PerformTest));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "StringSearchTest.h"
|
||||
#include "StringSplitTest.h"
|
||||
|
||||
|
||||
CppUnit::Test *StringTestSuite()
|
||||
{
|
||||
CppUnit::TestSuite *testSuite = new CppUnit::TestSuite();
|
||||
|
||||
Reference in New Issue
Block a user