Unit tests update
This commit is contained in:
parent
b51d7a399c
commit
2bc3fe4dd1
|
@ -368,10 +368,9 @@ const FString& FString::operator += (const wchar_t s[])
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString& FString::operator += (const std::string& s)
|
const FString& FString::operator += (const std::string& s)
|
||||||
{
|
{
|
||||||
const wchar_t* wc_string = c_to_wc_str(s.c_str());
|
if ( ! s.empty() )
|
||||||
|
|
||||||
if ( wc_string )
|
|
||||||
{
|
{
|
||||||
|
const wchar_t* wc_string = c_to_wc_str(s.c_str());
|
||||||
_insert (length, uInt(s.length()), wc_string);
|
_insert (length, uInt(s.length()), wc_string);
|
||||||
delete[] wc_string;
|
delete[] wc_string;
|
||||||
}
|
}
|
||||||
|
@ -382,10 +381,9 @@ const FString& FString::operator += (const std::string& s)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString& FString::operator += (const char s[])
|
const FString& FString::operator += (const char s[])
|
||||||
{
|
{
|
||||||
const wchar_t* wc_string = c_to_wc_str(s);
|
if ( s )
|
||||||
|
|
||||||
if ( wc_string )
|
|
||||||
{
|
{
|
||||||
|
const wchar_t* wc_string = c_to_wc_str(s);
|
||||||
_insert (length, uInt(std::wcslen(wc_string)), wc_string);
|
_insert (length, uInt(std::wcslen(wc_string)), wc_string);
|
||||||
delete[] wc_string;
|
delete[] wc_string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ class FStringTest : public CPPUNIT_NS::TestFixture
|
||||||
void initLengthTest();
|
void initLengthTest();
|
||||||
void copyConstructorTest();
|
void copyConstructorTest();
|
||||||
void assignmentTest();
|
void assignmentTest();
|
||||||
|
void additionAssignmentTest();
|
||||||
|
void additionTest();
|
||||||
void caseTest();
|
void caseTest();
|
||||||
void equalTest();
|
void equalTest();
|
||||||
void lessEqualTest();
|
void lessEqualTest();
|
||||||
|
@ -78,6 +80,8 @@ class FStringTest : public CPPUNIT_NS::TestFixture
|
||||||
CPPUNIT_TEST (initLengthTest);
|
CPPUNIT_TEST (initLengthTest);
|
||||||
CPPUNIT_TEST (copyConstructorTest);
|
CPPUNIT_TEST (copyConstructorTest);
|
||||||
CPPUNIT_TEST (assignmentTest);
|
CPPUNIT_TEST (assignmentTest);
|
||||||
|
CPPUNIT_TEST (additionAssignmentTest);
|
||||||
|
CPPUNIT_TEST (additionTest);
|
||||||
CPPUNIT_TEST (caseTest);
|
CPPUNIT_TEST (caseTest);
|
||||||
CPPUNIT_TEST (equalTest);
|
CPPUNIT_TEST (equalTest);
|
||||||
CPPUNIT_TEST (notEqualTest);
|
CPPUNIT_TEST (notEqualTest);
|
||||||
|
@ -288,6 +292,86 @@ void FStringTest::assignmentTest()
|
||||||
CPPUNIT_ASSERT ( s1.getLength() == 1 );
|
CPPUNIT_ASSERT ( s1.getLength() == 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FStringTest::additionAssignmentTest()
|
||||||
|
{
|
||||||
|
FString s1;
|
||||||
|
s1 += FString("abc");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abc" );
|
||||||
|
s1 += FString("def");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abcdef" );
|
||||||
|
|
||||||
|
s1.clear();
|
||||||
|
CPPUNIT_ASSERT ( s1.isNull() );
|
||||||
|
CPPUNIT_ASSERT ( s1.isEmpty() );
|
||||||
|
s1 += std::wstring(L"abc");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abc" );
|
||||||
|
s1 += std::wstring(L"def");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abcdef" );
|
||||||
|
|
||||||
|
s1.clear();
|
||||||
|
s1 += const_cast<wchar_t*>(L"abc");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abc" );
|
||||||
|
s1 += const_cast<wchar_t*>(L"def");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abcdef" );
|
||||||
|
|
||||||
|
s1.clear();
|
||||||
|
s1 += std::string("abc");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abc" );
|
||||||
|
s1 += std::string("def");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abcdef" );
|
||||||
|
|
||||||
|
s1.clear();
|
||||||
|
s1 += const_cast<char*>("abc");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abc" );
|
||||||
|
s1 += const_cast<char*>("def");
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"abcdef" );
|
||||||
|
|
||||||
|
s1.clear();
|
||||||
|
s1 += wchar_t('a');
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"a" );
|
||||||
|
s1 += wchar_t('b');
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"ab" );
|
||||||
|
|
||||||
|
s1.clear();
|
||||||
|
s1 += char('a');
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"a" );
|
||||||
|
s1 += char('b');
|
||||||
|
CPPUNIT_ASSERT ( s1 == L"ab" );
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FStringTest::additionTest()
|
||||||
|
{
|
||||||
|
FString s1("abc");
|
||||||
|
FString s2 = s1 + FString("def");
|
||||||
|
CPPUNIT_ASSERT ( s2 == L"abcdef" );
|
||||||
|
|
||||||
|
s2.clear();
|
||||||
|
s2 = s1 + std::wstring(L"def");
|
||||||
|
CPPUNIT_ASSERT ( s2 == L"abcdef" );
|
||||||
|
|
||||||
|
s2.clear();
|
||||||
|
s2 = s1 + const_cast<wchar_t*>(L"def");
|
||||||
|
CPPUNIT_ASSERT ( s2 == L"abcdef" );
|
||||||
|
|
||||||
|
s2.clear();
|
||||||
|
s2 = s1 + std::string("def");
|
||||||
|
CPPUNIT_ASSERT ( s2 == L"abcdef" );
|
||||||
|
|
||||||
|
s2.clear();
|
||||||
|
s2 = s1 + const_cast<char*>("def");
|
||||||
|
CPPUNIT_ASSERT ( s2 == L"abcdef" );
|
||||||
|
|
||||||
|
s2.clear();
|
||||||
|
s2 = s1 + wchar_t(L'd');
|
||||||
|
CPPUNIT_ASSERT ( s2 == L"abcd" );
|
||||||
|
|
||||||
|
s2.clear();
|
||||||
|
s2 = s1 + char('d');
|
||||||
|
CPPUNIT_ASSERT ( s2 == L"abcd" );
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FStringTest::caseTest()
|
void FStringTest::caseTest()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue