mirror of
https://review.haiku-os.org/haiku
synced 2025-02-01 03:06:08 +01:00
Whoops! Forgot these tests...
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1354 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
de78848fb3
commit
a57dca3940
71
src/tests/kits/support/bstring/StringPrependTest.cpp
Normal file
71
src/tests/kits/support/bstring/StringPrependTest.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include "StringPrependTest.h"
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
#include <UTF8.h>
|
||||
|
||||
StringPrependTest::StringPrependTest(std::string name) :
|
||||
BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringPrependTest::~StringPrependTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StringPrependTest::PerformTest(void)
|
||||
{
|
||||
BString *str1, *str2;
|
||||
|
||||
NextSubTest();
|
||||
str1 = new BString("a String");
|
||||
str2 = new BString("PREPENDED");
|
||||
str1->Prepend(*str2);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "PREPENDEDa String") == 0);
|
||||
delete str1;
|
||||
delete str2;
|
||||
|
||||
NextSubTest();
|
||||
str1 = new BString("String");
|
||||
str1->Prepend("PREPEND");
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "PREPENDString") == 0);
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
str1 = new BString("String");
|
||||
str1->Prepend((char*)NULL);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "String") == 0);
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
str1 = new BString("String");
|
||||
str1->Prepend("PREPENDED", 3);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "PREString") == 0);
|
||||
delete str1;
|
||||
|
||||
NextSubTest();
|
||||
str1 = new BString("String");
|
||||
str2 = new BString("PREPEND", 4);
|
||||
str1->Prepend(*str2);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "PREPString") == 0);
|
||||
delete str1;
|
||||
delete str2;
|
||||
|
||||
NextSubTest();
|
||||
str1 = new BString("aString");
|
||||
str1->Prepend('c', 4);
|
||||
CPPUNIT_ASSERT(strcmp(str1->String(), "ccccaString") == 0);
|
||||
delete str1;
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test *StringPrependTest::suite(void)
|
||||
{
|
||||
typedef CppUnit::TestCaller<StringPrependTest>
|
||||
StringPrependTestCaller;
|
||||
|
||||
return(new StringPrependTestCaller("BString::Prepend Test", &StringPrependTest::PerformTest));
|
||||
}
|
22
src/tests/kits/support/bstring/StringPrependTest.h
Normal file
22
src/tests/kits/support/bstring/StringPrependTest.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef StringPrependTest_H
|
||||
#define StringPrependTest_H
|
||||
|
||||
#include "TestCase.h"
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class StringPrependTest : public BTestCase
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
static Test *suite(void);
|
||||
void PerformTest(void);
|
||||
StringPrependTest(std::string name = "");
|
||||
virtual ~StringPrependTest();
|
||||
};
|
||||
|
||||
#endif
|
48
src/tests/kits/support/bstring/StringSubCopyTest.cpp
Normal file
48
src/tests/kits/support/bstring/StringSubCopyTest.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "StringSubCopyTest.h"
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include <String.h>
|
||||
#include <stdio.h>
|
||||
|
||||
StringSubCopyTest::StringSubCopyTest(std::string name) :
|
||||
BTestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringSubCopyTest::~StringSubCopyTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StringSubCopyTest::PerformTest(void)
|
||||
{
|
||||
BString *string1, *string2;
|
||||
|
||||
NextSubTest();
|
||||
string1 = new BString;
|
||||
string2 = new BString("Something");
|
||||
string2->CopyInto(*string1, 4, 30);
|
||||
CPPUNIT_ASSERT(strcmp(string1->String(), "thing") == 0);
|
||||
delete string1;
|
||||
delete string2;
|
||||
|
||||
NextSubTest();
|
||||
char tmp[10];
|
||||
memset(tmp, 0, 10);
|
||||
string1 = new BString("ABC");
|
||||
string1->CopyInto(tmp, 0, 4);
|
||||
CPPUNIT_ASSERT(strcmp(tmp, "ABC") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(string1->String(), "ABC") == 0);
|
||||
delete string1;
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test *StringSubCopyTest::suite(void)
|
||||
{
|
||||
typedef CppUnit::TestCaller<StringSubCopyTest>
|
||||
StringSubCopyTestCaller;
|
||||
|
||||
return(new StringSubCopyTestCaller("BString::SubCopy Test", &StringSubCopyTest::PerformTest));
|
||||
}
|
22
src/tests/kits/support/bstring/StringSubCopyTest.h
Normal file
22
src/tests/kits/support/bstring/StringSubCopyTest.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef StringSubCopyTest_H
|
||||
#define StringSubCopyTest_H
|
||||
|
||||
#include "TestCase.h"
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class StringSubCopyTest : public BTestCase
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
static Test *suite(void);
|
||||
void PerformTest(void);
|
||||
StringSubCopyTest(std::string name = "");
|
||||
virtual ~StringSubCopyTest();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user