Again, more tests for BString
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1556 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f4e51a2dfb
commit
ce06a3c712
@ -120,8 +120,28 @@ StringCompareTest::PerformTest(void)
|
||||
delete string1;
|
||||
|
||||
//operator>=(const char *) const;
|
||||
NextSubTest();
|
||||
string1 = new BString("BBBBB");
|
||||
CPPUNIT_ASSERT(*string1 >= "AAAAA");
|
||||
CPPUNIT_ASSERT(*string1 >= "BBBBB");
|
||||
delete string1;
|
||||
|
||||
//operator>(const char *) const;
|
||||
NextSubTest();
|
||||
string1 = new BString("BBBBB");
|
||||
CPPUNIT_ASSERT(*string1 > "AAAAA");
|
||||
delete string1;
|
||||
|
||||
//operator!=(const char *) const;
|
||||
NextSubTest();
|
||||
string1 = new BString("AAAAA");
|
||||
CPPUNIT_ASSERT((*string1 != "AAAAA") == false);
|
||||
delete string1;
|
||||
|
||||
NextSubTest();
|
||||
string1 = new BString("AAAAA");
|
||||
CPPUNIT_ASSERT(*string1 != "BBBB");
|
||||
delete string1;
|
||||
}
|
||||
|
||||
|
||||
|
93
src/tests/kits/support/bstring/StringFormatAppendTest.cpp
Normal file
93
src/tests/kits/support/bstring/StringFormatAppendTest.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include "StringFormatAppendTest.h"
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
|
||||
StringFormatAppendTest::StringFormatAppendTest(std::string name) :
|
||||
BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringFormatAppendTest::~StringFormatAppendTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StringFormatAppendTest::PerformTest(void)
|
||||
{
|
||||
BString *string, *string2;
|
||||
|
||||
//operator<<(const char *);
|
||||
NextSubTest();
|
||||
string = new BString("some");
|
||||
*string << " ";
|
||||
*string << "text";
|
||||
CPPUNIT_ASSERT(strcmp(string->String(), "some text") == 0);
|
||||
delete string;
|
||||
|
||||
//operator<<(const BString &);
|
||||
NextSubTest();
|
||||
string = new BString("some ");
|
||||
string2 = new BString("text");
|
||||
*string << *string2;
|
||||
CPPUNIT_ASSERT(strcmp(string->String(), "some text") == 0);
|
||||
delete string;
|
||||
delete string2;
|
||||
|
||||
//operator<<(char);
|
||||
NextSubTest();
|
||||
string = new BString("str");
|
||||
*string << 'i' << 'n' << 'g';
|
||||
CPPUNIT_ASSERT(strcmp(string->String(), "string") == 0);
|
||||
delete string;
|
||||
|
||||
//operator<<(int);
|
||||
NextSubTest();
|
||||
string = new BString("level ");
|
||||
*string << (int)42;
|
||||
CPPUNIT_ASSERT(strcmp(string->String(), "level 42") == 0);
|
||||
delete string;
|
||||
|
||||
NextSubTest();
|
||||
string = new BString("error ");
|
||||
*string << (int)-1;
|
||||
CPPUNIT_ASSERT(strcmp(string->String(), "error -1") == 0);
|
||||
delete string;
|
||||
|
||||
//operator<<(unsigned int);
|
||||
NextSubTest();
|
||||
NextSubTest();
|
||||
string = new BString("number ");
|
||||
*string << (unsigned int)296;
|
||||
CPPUNIT_ASSERT(strcmp(string->String(), "number 296") == 0);
|
||||
delete string;
|
||||
|
||||
//operator<<(uint32);
|
||||
//operator<<(int32);
|
||||
//operator<<(uint64);
|
||||
//operator<<(int64);
|
||||
|
||||
//operator<<(float);
|
||||
NextSubTest();
|
||||
string = new BString;
|
||||
*string << (float)34.542;
|
||||
CPPUNIT_ASSERT(strcmp(string->String(), "34.54") == 0);
|
||||
delete string;
|
||||
|
||||
//Misc test
|
||||
NextSubTest();
|
||||
BString s;
|
||||
s << "This" << ' ' << "is" << ' ' << 'a' << ' ' << "test" << ' ' << "sentence";
|
||||
CPPUNIT_ASSERT(strcmp(s.String(), "This is a test sentence") == 0);
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test *StringFormatAppendTest::suite(void)
|
||||
{
|
||||
typedef CppUnit::TestCaller<StringFormatAppendTest>
|
||||
StringFormatAppendTestCaller;
|
||||
|
||||
return(new StringFormatAppendTestCaller("BString::FormatAppend Test", &StringFormatAppendTest::PerformTest));
|
||||
}
|
22
src/tests/kits/support/bstring/StringFormatAppendTest.h
Normal file
22
src/tests/kits/support/bstring/StringFormatAppendTest.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef StringFormatAppendTest_H
|
||||
#define StringFormatAppendTest_H
|
||||
|
||||
#include "TestCase.h"
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class StringFormatAppendTest : public BTestCase
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
static Test *suite(void);
|
||||
void PerformTest(void);
|
||||
StringFormatAppendTest(std::string name = "");
|
||||
virtual ~StringFormatAppendTest();
|
||||
};
|
||||
|
||||
#endif
|
@ -12,6 +12,7 @@
|
||||
#include "StringEscapeTest.h"
|
||||
#include "StringRemoveTest.h"
|
||||
#include "StringCompareTest.h"
|
||||
#include "StringFormatAppendTest.h"
|
||||
|
||||
CppUnit::Test *StringTestSuite()
|
||||
{
|
||||
@ -28,6 +29,7 @@ CppUnit::Test *StringTestSuite()
|
||||
testSuite->addTest(StringEscapeTest::suite());
|
||||
testSuite->addTest(StringRemoveTest::suite());
|
||||
testSuite->addTest(StringCompareTest::suite());
|
||||
testSuite->addTest(StringFormatAppendTest::suite());
|
||||
|
||||
return(testSuite);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user