SimpleString& SimpleString::operator=(const SimpleString& other)
{
	if (this != &other) {
		deallocStringBuffer(buffer_);
		size_t len = other.size() + 1;
		buffer_ = allocStringBuffer(len);
		PlatformSpecificStrCpy(buffer_, other.buffer_);
	}
	return *this;
}
Example #2
0
SimpleString& SimpleString::operator+=(const char* rhs)
{
    int len = this->size() + PlatformSpecificStrLen(rhs) + 1;
    char* tbuffer = allocString(len);
    PlatformSpecificStrCpy(tbuffer, this->buffer);
    PlatformSpecificStrCat(tbuffer, rhs);
    deallocString(buffer);
    buffer = tbuffer;
    return *this;
}
Example #3
0
SimpleString::SimpleString (const char *otherBuffer)
{
    if (otherBuffer == 0) {
        buffer = getEmptryString();
    }
    else {
        int len = PlatformSpecificStrLen (otherBuffer) + 1;
        buffer = allocString(len);
        PlatformSpecificStrCpy (buffer, otherBuffer);
    }
}
SimpleString::SimpleString(const char *otherBuffer)
{
	if (otherBuffer == 0) {
		buffer_ = getEmptyString();
	}
	else {
		size_t len = PlatformSpecificStrLen(otherBuffer) + 1;
		buffer_ = allocStringBuffer(len);
		PlatformSpecificStrCpy(buffer_, otherBuffer);
	}
}
SimpleString::SimpleString(const char *other, size_t repeatCount)
{
	size_t len = PlatformSpecificStrLen(other) * repeatCount + 1;
	buffer_ = allocStringBuffer(len);
	char* next = buffer_;
	for (size_t i = 0; i < repeatCount; i++) {
		PlatformSpecificStrCpy(next, other);
		next += PlatformSpecificStrLen(other);
	}
	*next = 0;

}
Example #6
0
SimpleString::SimpleString(const char *other, int repeatCount)
{
	int len = PlatformSpecificStrLen(other) * repeatCount + 1;
	buffer = allocString(len);
	char* next = buffer;
	for (int i = 0; i < repeatCount; i++) {
		PlatformSpecificStrCpy(next, other);
		next += PlatformSpecificStrLen(other);
	}
	*next = 0;

}
Example #7
0
TEST(TestHarness_c, cpputest_realloc_larger)
{
	const char* number_string = "123456789";

	char* mem1 = (char*) cpputest_malloc(10);

	PlatformSpecificStrCpy(mem1, number_string);
	CHECK(mem1 != 0);

	char* mem2 = (char*) cpputest_realloc(mem1, 1000);

	CHECK(mem2 != 0);
	STRCMP_EQUAL(number_string, mem2);

	cpputest_free(mem2);
}
Example #8
0
SimpleString::SimpleString (const SimpleString& other)
{
    int len = other.size() + 1;
    buffer = allocString(len);
    PlatformSpecificStrCpy(buffer, other.buffer);
}
SimpleString::SimpleString(const SimpleString& other)
{
	size_t len = other.size() + 1;
	buffer_ = allocStringBuffer(len);
	PlatformSpecificStrCpy(buffer_, other.buffer_);
}