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:
krish_iyer
2018-04-07 16:52:44 +00:00
committed by Jérôme Duval
parent 509c7718dd
commit f960e7e9a2
17 changed files with 274 additions and 255 deletions
@@ -4,13 +4,13 @@
#include <String.h> #include <String.h>
#include <UTF8.h> #include <UTF8.h>
StringAccessTest::StringAccessTest(std::string name) :
BTestCase(name) StringAccessTest::StringAccessTest(std::string name)
: BTestCase(name)
{ {
} }
StringAccessTest::~StringAccessTest() StringAccessTest::~StringAccessTest()
{ {
} }
@@ -93,5 +93,6 @@ CppUnit::Test *StringAccessTest::suite(void)
typedef CppUnit::TestCaller<StringAccessTest> typedef CppUnit::TestCaller<StringAccessTest>
StringAccessTestCaller; 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 "cppunit/TestCaller.h"
#include <String.h> #include <String.h>
StringAppendTest::StringAppendTest(std::string name) :
BTestCase(name) StringAppendTest::StringAppendTest(std::string name)
: BTestCase(name)
{ {
} }
StringAppendTest::~StringAppendTest() StringAppendTest::~StringAppendTest()
{ {
} }
@@ -143,5 +143,6 @@ CppUnit::Test *StringAppendTest::suite(void)
typedef CppUnit::TestCaller<StringAppendTest> typedef CppUnit::TestCaller<StringAppendTest>
StringAppendTestCaller; StringAppendTestCaller;
return(new StringAppendTestCaller("BString::Append Test", &StringAppendTest::PerformTest)); return(new StringAppendTestCaller("BString::Append Test",
&StringAppendTest::PerformTest));
} }
@@ -3,13 +3,12 @@
#include <String.h> #include <String.h>
StringAssignTest::StringAssignTest(std::string name) : StringAssignTest::StringAssignTest(std::string name)
BTestCase(name) : BTestCase(name)
{ {
} }
StringAssignTest::~StringAssignTest() StringAssignTest::~StringAssignTest()
{ {
} }
@@ -123,5 +122,6 @@ CppUnit::Test *StringAssignTest::suite(void)
typedef CppUnit::TestCaller<StringAssignTest> typedef CppUnit::TestCaller<StringAssignTest>
StringAssignTestCaller; 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 "cppunit/TestCaller.h"
#include <String.h> #include <String.h>
StringCaseTest::StringCaseTest(std::string name) :
BTestCase(name) StringCaseTest::StringCaseTest(std::string name)
: BTestCase(name)
{ {
} }
StringCaseTest::~StringCaseTest() StringCaseTest::~StringCaseTest()
{ {
} }
@@ -84,5 +84,6 @@ CppUnit::Test *StringCaseTest::suite(void)
typedef CppUnit::TestCaller<StringCaseTest> typedef CppUnit::TestCaller<StringCaseTest>
StringCaseTestCaller; StringCaseTestCaller;
return(new StringCaseTestCaller("BString::Case Test", &StringCaseTest::PerformTest)); return(new StringCaseTestCaller("BString::Case Test",
&StringCaseTest::PerformTest));
} }
@@ -3,13 +3,12 @@
#include <String.h> #include <String.h>
StringCharAccessTest::StringCharAccessTest(std::string name) : StringCharAccessTest::StringCharAccessTest(std::string name)
BTestCase(name) : BTestCase(name)
{ {
} }
StringCharAccessTest::~StringCharAccessTest() StringCharAccessTest::~StringCharAccessTest()
{ {
} }
@@ -44,5 +43,6 @@ CppUnit::Test *StringCharAccessTest::suite(void)
typedef CppUnit::TestCaller<StringCharAccessTest> typedef CppUnit::TestCaller<StringCharAccessTest>
StringCharAccessTestCaller; 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 "cppunit/TestCaller.h"
#include <String.h> #include <String.h>
StringCompareTest::StringCompareTest(std::string name) :
BTestCase(name) StringCompareTest::StringCompareTest(std::string name)
: BTestCase(name)
{ {
} }
StringCompareTest::~StringCompareTest() StringCompareTest::~StringCompareTest()
{ {
} }
@@ -150,5 +150,6 @@ CppUnit::Test *StringCompareTest::suite(void)
typedef CppUnit::TestCaller<StringCompareTest> typedef CppUnit::TestCaller<StringCompareTest>
StringCompareTestCaller; StringCompareTestCaller;
return(new StringCompareTestCaller("BString::Compare Test", &StringCompareTest::PerformTest)); return(new StringCompareTestCaller("BString::Compare Test",
&StringCompareTest::PerformTest));
} }
@@ -3,13 +3,12 @@
#include <String.h> #include <String.h>
StringConstructionTest::StringConstructionTest(std::string name) : StringConstructionTest::StringConstructionTest(std::string name)
BTestCase(name) : BTestCase(name)
{ {
} }
StringConstructionTest::~StringConstructionTest() StringConstructionTest::~StringConstructionTest()
{ {
} }
@@ -71,5 +70,6 @@ CppUnit::Test *StringConstructionTest::suite(void)
typedef CppUnit::TestCaller<StringConstructionTest> typedef CppUnit::TestCaller<StringConstructionTest>
StringConstructionTestCaller; 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 "cppunit/TestCaller.h"
#include <String.h> #include <String.h>
StringEscapeTest::StringEscapeTest(std::string name) :
BTestCase(name) StringEscapeTest::StringEscapeTest(std::string name)
: BTestCase(name)
{ {
} }
StringEscapeTest::~StringEscapeTest() StringEscapeTest::~StringEscapeTest()
{ {
} }
@@ -123,5 +123,6 @@ CppUnit::Test *StringEscapeTest::suite(void)
typedef CppUnit::TestCaller<StringEscapeTest> typedef CppUnit::TestCaller<StringEscapeTest>
StringEscapeTestCaller; 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 "cppunit/TestCaller.h"
#include <String.h> #include <String.h>
StringFormatAppendTest::StringFormatAppendTest(std::string name) :
BTestCase(name) StringFormatAppendTest::StringFormatAppendTest(std::string name)
: BTestCase(name)
{ {
} }
StringFormatAppendTest::~StringFormatAppendTest() StringFormatAppendTest::~StringFormatAppendTest()
{ {
} }
@@ -113,7 +113,8 @@ StringFormatAppendTest::PerformTest(void)
// Misc test // Misc test
NextSubTest(); NextSubTest();
BString s; 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); CPPUNIT_ASSERT(strcmp(s.String(), "This is a test sentence") == 0);
} }
@@ -123,5 +124,6 @@ CppUnit::Test *StringFormatAppendTest::suite(void)
typedef CppUnit::TestCaller<StringFormatAppendTest> typedef CppUnit::TestCaller<StringFormatAppendTest>
StringFormatAppendTestCaller; 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 "cppunit/TestCaller.h"
#include <String.h> #include <String.h>
StringInsertTest::StringInsertTest(std::string name) :
BTestCase(name) StringInsertTest::StringInsertTest(std::string name)
: BTestCase(name)
{ {
} }
StringInsertTest::~StringInsertTest() StringInsertTest::~StringInsertTest()
{ {
} }
@@ -143,5 +143,6 @@ CppUnit::Test *StringInsertTest::suite(void)
typedef CppUnit::TestCaller<StringInsertTest> typedef CppUnit::TestCaller<StringInsertTest>
StringInsertTestCaller; 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 <String.h>
#include <UTF8.h> #include <UTF8.h>
StringPrependTest::StringPrependTest(std::string name) :
BTestCase(name) StringPrependTest::StringPrependTest(std::string name)
: BTestCase(name)
{ {
} }
StringPrependTest::~StringPrependTest() StringPrependTest::~StringPrependTest()
{ {
} }
@@ -81,5 +81,6 @@ CppUnit::Test *StringPrependTest::suite(void)
typedef CppUnit::TestCaller<StringPrependTest> typedef CppUnit::TestCaller<StringPrependTest>
StringPrependTestCaller; 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 <String.h>
#include <stdio.h> #include <stdio.h>
StringRemoveTest::StringRemoveTest(std::string name) :
BTestCase(name) StringRemoveTest::StringRemoveTest(std::string name)
: BTestCase(name)
{ {
} }
StringRemoveTest::~StringRemoveTest() StringRemoveTest::~StringRemoveTest()
{ {
} }
@@ -252,5 +252,6 @@ CppUnit::Test *StringRemoveTest::suite(void)
typedef CppUnit::TestCaller<StringRemoveTest> typedef CppUnit::TestCaller<StringRemoveTest>
StringRemoveTestCaller; 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 "cppunit/TestCaller.h"
#include <String.h> #include <String.h>
StringReplaceTest::StringReplaceTest(std::string name) :
BTestCase(name) StringReplaceTest::StringReplaceTest(std::string name)
: BTestCase(name)
{ {
} }
StringReplaceTest::~StringReplaceTest() StringReplaceTest::~StringReplaceTest()
{ {
} }
@@ -76,13 +76,15 @@ StringReplaceTest::PerformTest(void)
NextSubTest(); NextSubTest();
str1 = new BString("she sells sea shells on the sea shore"); str1 = new BString("she sells sea shells on the sea shore");
str1->Replace('s', 't', 4, 2); 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; delete str1;
NextSubTest(); NextSubTest();
str1 = new BString("she sells sea shells on the sea shore"); str1 = new BString("she sells sea shells on the sea shore");
str1->Replace('s', 's', 4, 2); 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; delete str1;
NextSubTest(); NextSubTest();
@@ -210,13 +212,15 @@ StringReplaceTest::PerformTest(void)
NextSubTest(); NextSubTest();
str1 = new BString("She sells Sea shells on the sea shore"); str1 = new BString("She sells Sea shells on the sea shore");
str1->IReplace('s', 't', 4, 2); 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; delete str1;
NextSubTest(); NextSubTest();
str1 = new BString("She sells Sea shells on the sea shore"); str1 = new BString("She sells Sea shells on the sea shore");
str1->IReplace('s', 's', 4, 2); 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; delete str1;
NextSubTest(); NextSubTest();
@@ -382,5 +386,6 @@ CppUnit::Test *StringReplaceTest::suite(void)
typedef CppUnit::TestCaller<StringReplaceTest> typedef CppUnit::TestCaller<StringReplaceTest>
StringReplaceTestCaller; 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 <String.h>
#include <stdio.h> #include <stdio.h>
StringSearchTest::StringSearchTest(std::string name) :
BTestCase(name) StringSearchTest::StringSearchTest(std::string name)
: BTestCase(name)
{ {
} }
StringSearchTest::~StringSearchTest() StringSearchTest::~StringSearchTest()
{ {
} }
@@ -416,7 +416,7 @@ StringSearchTest::PerformTest(void)
NextSubTest(); NextSubTest();
string1 = new BString("last but not least"); string1 = new BString("last but not least");
string2 = new BString("lAsT"); string2 = new BString("lAsT");
i = (int32)string1->StartsWith(*string2); i = (int32)string1->IStartsWith(*string2);
CPPUNIT_ASSERT(i != 0); CPPUNIT_ASSERT(i != 0);
delete string1; delete string1;
delete string2; delete string2;
@@ -424,14 +424,14 @@ StringSearchTest::PerformTest(void)
// IStartsWith(const char*) // IStartsWith(const char*)
NextSubTest(); NextSubTest();
string1 = new BString("last but not least"); string1 = new BString("last but not least");
i = (int32)string1->StartsWith("lAsT"); i = (int32)string1->IStartsWith("lAsT");
CPPUNIT_ASSERT(i != 0); CPPUNIT_ASSERT(i != 0);
delete string1; delete string1;
// IStartsWith(const char*, int32) // IStartsWith(const char*, int32)
NextSubTest(); NextSubTest();
string1 = new BString("last but not least"); string1 = new BString("last but not least");
i = (int32)string1->StartsWith("lAsT", 4); i = (int32)string1->IStartsWith("lAsT", 4);
CPPUNIT_ASSERT(i != 0); CPPUNIT_ASSERT(i != 0);
delete string1; delete string1;
@@ -485,7 +485,7 @@ StringSearchTest::PerformTest(void)
// EndsWith(const char*, int32) // EndsWith(const char*, int32)
NextSubTest(); NextSubTest();
string1 = new BString("last but not least"); string1 = new BString("last but not least");
i = (int32)string1->EndsWith("sT", 2); i = (int32)string1->EndsWith("st", 2);
CPPUNIT_ASSERT(i != 0); CPPUNIT_ASSERT(i != 0);
delete string1; delete string1;
@@ -636,5 +636,6 @@ CppUnit::Test *StringSearchTest::suite(void)
typedef CppUnit::TestCaller<StringSearchTest> typedef CppUnit::TestCaller<StringSearchTest>
StringSearchTestCaller; 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 <String.h>
#include <StringList.h> #include <StringList.h>
StringSplitTest::StringSplitTest(std::string name) :
BTestCase(name) StringSplitTest::StringSplitTest(std::string name)
: BTestCase(name)
{ {
} }
StringSplitTest::~StringSplitTest() StringSplitTest::~StringSplitTest()
{ {
} }
@@ -24,28 +24,28 @@ StringSplitTest::PerformTest(void)
BStringList stringList1; BStringList stringList1;
str1 = new BString("test::string"); str1 = new BString("test::string");
str1->Split(":", true, stringList1); str1->Split(":", true, stringList1);
CPPUNIT_ASSERT(stringList1.CountStrings() == 2); CPPUNIT_ASSERT_EQUAL(2, stringList1.CountStrings());
delete str1; delete str1;
NextSubTest(); NextSubTest();
BStringList stringList2; BStringList stringList2;
str1 = new BString("test::string"); str1 = new BString("test::string");
str1->Split("::", true, stringList2); str1->Split("::", true, stringList2);
CPPUNIT_ASSERT(stringList2.CountStrings() == 2); CPPUNIT_ASSERT_EQUAL(2, stringList2.CountStrings());
delete str1; delete str1;
NextSubTest(); NextSubTest();
BStringList stringList3; BStringList stringList3;
str1 = new BString("test::string"); str1 = new BString("test::string");
str1->Split("::", false, stringList3); str1->Split("::", false, stringList3);
CPPUNIT_ASSERT(stringList3.CountStrings() == 2); CPPUNIT_ASSERT_EQUAL(2, stringList3.CountStrings());
delete str1; delete str1;
NextSubTest(); NextSubTest();
BStringList stringList4; BStringList stringList4;
str1 = new BString("test::string"); str1 = new BString("test::string");
str1->Split(":", false, stringList4); str1->Split(":", false, stringList4);
CPPUNIT_ASSERT(stringList4.CountStrings() == 3); CPPUNIT_ASSERT_EQUAL(3, stringList4.CountStrings());
delete str1; delete str1;
} }
@@ -56,5 +56,6 @@ CppUnit::Test *StringSplitTest::suite(void)
typedef CppUnit::TestCaller<StringSplitTest> typedef CppUnit::TestCaller<StringSplitTest>
StringSplitTestCaller; 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 <String.h>
#include <stdio.h> #include <stdio.h>
StringSubCopyTest::StringSubCopyTest(std::string name) :
BTestCase(name) StringSubCopyTest::StringSubCopyTest(std::string name)
: BTestCase(name)
{ {
} }
StringSubCopyTest::~StringSubCopyTest() StringSubCopyTest::~StringSubCopyTest()
{ {
} }
@@ -46,5 +46,6 @@ CppUnit::Test *StringSubCopyTest::suite(void)
typedef CppUnit::TestCaller<StringSubCopyTest> typedef CppUnit::TestCaller<StringSubCopyTest>
StringSubCopyTestCaller; 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 "StringSearchTest.h"
#include "StringSplitTest.h" #include "StringSplitTest.h"
CppUnit::Test *StringTestSuite() CppUnit::Test *StringTestSuite()
{ {
CppUnit::TestSuite *testSuite = new CppUnit::TestSuite(); CppUnit::TestSuite *testSuite = new CppUnit::TestSuite();