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:
parent
b947d539d4
commit
e440e9f423
48
src/tests/kits/support/bstring/StringCharAccessTest.cpp
Normal file
48
src/tests/kits/support/bstring/StringCharAccessTest.cpp
Normal 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));
|
||||
}
|
22
src/tests/kits/support/bstring/StringCharAccessTest.h
Normal file
22
src/tests/kits/support/bstring/StringCharAccessTest.h
Normal 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
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user