예제 #1
0
static MockValue_c getMockValueCFromNamedValue(const MockNamedValue& namedValue)
{
	MockValue_c returnValue;
	if (PlatformSpecificStrCmp(namedValue.getType().asCharString(), "int") == 0) {
		returnValue.type = MOCKVALUETYPE_INTEGER;
		returnValue.value.intValue = namedValue.getIntValue();
	}
	else if (PlatformSpecificStrCmp(namedValue.getType().asCharString(), "double") == 0) {
		returnValue.type = MOCKVALUETYPE_DOUBLE;
		returnValue.value.doubleValue = namedValue.getDoubleValue();
	}
	else if (PlatformSpecificStrCmp(namedValue.getType().asCharString(), "char*") == 0) {
		returnValue.type = MOCKVALUETYPE_STRING;
		returnValue.value.stringValue = namedValue.getStringValue();
	}
	else if (PlatformSpecificStrCmp(namedValue.getType().asCharString(), "void*") == 0) {
		returnValue.type = MOCKVALUETYPE_POINTER;
		returnValue.value.pointerValue = namedValue.getPointerValue();
	}
	else {
		returnValue.type = MOCKVALUETYPE_OBJECT;
		returnValue.value.objectValue = namedValue.getObjectPointer();
	}
	return returnValue;
}
예제 #2
0
파일: Utest.cpp 프로젝트: Scopher/cpputest
void UtestShell::assertCstrEqual(const char* expected, const char* actual, const char* fileName, int lineNumber)
{
	getTestResult()->countCheck();
	if (actual == 0 && expected == 0) return;
	if (actual == 0 || expected == 0)
		failWith(StringEqualFailure(this, fileName, lineNumber, expected, actual));
	if (PlatformSpecificStrCmp(expected, actual) != 0)
		failWith(StringEqualFailure(this, fileName, lineNumber, expected, actual));
}
예제 #3
0
bool SimpleString::endsWith(const SimpleString& other) const
{
    int buffer_length = PlatformSpecificStrLen(buffer);
    int other_buffer_length = PlatformSpecificStrLen(other.buffer);
    if (other_buffer_length == 0) return true;
    if (buffer_length == 0) return false;
    if (buffer_length < other_buffer_length) return false;
    return PlatformSpecificStrCmp(buffer + buffer_length - other_buffer_length, other.buffer) == 0;
}
예제 #4
0
void MemoryLeakDetector::ConstructMemoryLeakReport(MemLeakPeriod period)
{
	MemoryLeakDetectorNode* leak = memoryTable_.getFirstLeak(period);
	int total_leaks = 0;
	bool giveWarningOnUsingMalloc = false;
	output_buffer_.add(MEM_LEAK_HEADER);
	output_buffer_.setWriteLimit(SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN - MEM_LEAK_NORMAL_MALLOC_FOOTER_SIZE);

	while (leak) {
		output_buffer_.add(MEM_LEAK_LEAK, leak->number_, (unsigned long) leak->size_, leak->file_, leak->line_, leak->allocator_->alloc_name(), leak->memory_, leak->memory_);
		if (PlatformSpecificStrCmp(leak->allocator_->alloc_name(), "malloc") == 0)
			giveWarningOnUsingMalloc = true;
		total_leaks++;
		leak = memoryTable_.getNextLeak(leak, period);
	}
	bool buffer_reached_its_capacity = output_buffer_.reachedItsCapacity();
	output_buffer_.resetWriteLimit();
	if (buffer_reached_its_capacity)
		output_buffer_.add(MEM_LEAK_TOO_MUCH);
	output_buffer_.add("%s %d\n", MEM_LEAK_FOOTER, total_leaks);
	if (giveWarningOnUsingMalloc)
		output_buffer_.add(MEM_LEAK_ADDITION_MALLOC_WARNING);
}
예제 #5
0
bool operator== (const SimpleString& left, const SimpleString& right)
{
    return 0 == PlatformSpecificStrCmp (left.asCharString (), right.asCharString ());
}
bool TestMemoryAllocator::isOfEqualType(TestMemoryAllocator* allocator)
{
	return PlatformSpecificStrCmp(this->name(), allocator->name()) == 0;
}
예제 #7
0
bool CodeMemoryReportFormatter::isNewAllocator(TestMemoryAllocator* allocator)
{
    return PlatformSpecificStrCmp(allocator->alloc_name(), defaultNewAllocator()->alloc_name()) == 0 || PlatformSpecificStrCmp(allocator->alloc_name(), defaultNewArrayAllocator()->alloc_name()) == 0;
}