BString char access tests

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1729 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2002-10-28 08:42:18 +00:00
parent b947d539d4
commit e440e9f423
3 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,48 @@
#include "StringCharAccessTest.h"
#include "cppunit/TestCaller.h"
#include <String.h>
StringCharAccessTest::StringCharAccessTest(std::string name) :
BTestCase(name)
{
}
StringCharAccessTest::~StringCharAccessTest()
{
}
void
StringCharAccessTest::PerformTest(void)
{
BString string("A simple string");
//operator[]
NextSubTest();
CPPUNIT_ASSERT(string[0] == 'A');
CPPUNIT_ASSERT(string[1] == ' ');
//&operator[]
NextSubTest();
string[0] = 'a';
CPPUNIT_ASSERT(strcmp(string.String(), "a simple string") == 0);
//ByteAt(int32)
NextSubTest();
CPPUNIT_ASSERT(string[-10] == 0);
CPPUNIT_ASSERT(string[200] == 0);
CPPUNIT_ASSERT(string[1] == ' ');
CPPUNIT_ASSERT(string[7] == 'e');
}
CppUnit::Test *StringCharAccessTest::suite(void)
{
typedef CppUnit::TestCaller<StringCharAccessTest>
StringCharAccessTestCaller;
return(new StringCharAccessTestCaller("BString::CharAccess Test", &StringCharAccessTest::PerformTest));
}

View File

@ -0,0 +1,22 @@
#ifndef StringCharAccessTest_H
#define StringCharAccessTest_H
#include "TestCase.h"
#include <String.h>
class StringCharAccessTest : public BTestCase
{
private:
protected:
public:
static Test *suite(void);
void PerformTest(void);
StringCharAccessTest(std::string name = "");
virtual ~StringCharAccessTest();
};
#endif

View File

@ -13,6 +13,7 @@
#include "StringRemoveTest.h"
#include "StringCompareTest.h"
#include "StringFormatAppendTest.h"
#include "StringCharAccessTest.h"
CppUnit::Test *StringTestSuite()
{
@ -30,6 +31,7 @@ CppUnit::Test *StringTestSuite()
testSuite->addTest(StringRemoveTest::suite());
testSuite->addTest(StringCompareTest::suite());
testSuite->addTest(StringFormatAppendTest::suite());
testSuite->addTest(StringCharAccessTest::suite());
return(testSuite);
}