void TestRegistry::listTestGroupAndCaseNames(TestResult& result)
{
    SimpleString groupAndNameList;

    for (UtestShell *test = tests_; test != NULL; test = test->getNext()) {
        if (testShouldRun(test, result)) {
            SimpleString groupAndName;
            groupAndName += "#";
            groupAndName += test->getGroup();
            groupAndName += ".";
            groupAndName += test->getName();
            groupAndName += "#";

            if (!groupAndNameList.contains(groupAndName)) {
                groupAndNameList += groupAndName;
                groupAndNameList += " ";
            }
        }
    }

    groupAndNameList.replace("#", "");

    if (groupAndNameList.endsWith(" "))
        groupAndNameList = groupAndNameList.subString(0, groupAndNameList.size() - 1);
    result.print(groupAndNameList.asCharString());
}
Пример #2
0
void FailableMemoryAllocator::failIfMaximumNumberOfFailedAllocsExceeded(int toFailCount)
{
    UtestShell* currentTest = UtestShell::getCurrent();

    if (toFailCount >= MAX_NUMBER_OF_FAILED_ALLOCS)
        currentTest->failWith(FailFailure(currentTest, currentTest->getName().asCharString(),
            currentTest->getLineNumber(), "Maximum number of failed memory allocations exceeded"),
            TestTerminatorWithoutExceptions());
}
UtestShell* TestRegistry::findTestWithName(const SimpleString& name)
{
    UtestShell* current = tests_;
    while (current) {
        if (current->getName() == name)
            return current;
        current = current->getNext();
    }
    return NULL;
}
Пример #4
0
void FailableMemoryAllocator::failIfUndoneFailedAllocs()
{
    for (int i = 0; i < toFailCount_; i++) {
        if (allocsToFail_[i] != FAILED_ALLOC_DONE) {
            UtestShell* currentTest = UtestShell::getCurrent();
            SimpleString failText = StringFromFormat("Expected allocation number %d was never done", allocsToFail_[i]);
            currentTest->failWith(FailFailure(currentTest, currentTest->getName().asCharString(),
                    currentTest->getLineNumber(), failText), TestTerminatorWithoutExceptions());
        }
    }
}
Пример #5
0
void FailableMemoryAllocator::failIfUndoneFailedLocationAllocs()
{
    for (int i = 0; i < locationToFailCount_; i++) {
        if (!locationAllocsToFail_[i].done) {
            UtestShell* currentTest = UtestShell::getCurrent();
            SimpleString failText = StringFromFormat("Expected failing alloc at %s:%d was never done",
                    locationAllocsToFail_[i].file,
                    locationAllocsToFail_[i].line);
            currentTest->failWith(FailFailure(currentTest, currentTest->getName().asCharString(),
                    currentTest->getLineNumber(), failText), TestTerminatorWithoutExceptions());
        }
    }
}
Пример #6
0
void FailableMemoryAllocator::checkAllFailedAllocsWereDone()
{
  if (head_) {
    UtestShell* currentTest = UtestShell::getCurrent();
    SimpleString failText;
    if (head_->file_)
      failText = StringFromFormat("Expected failing alloc at %s:%d was never done", head_->file_, head_->line_);
    else
      failText = StringFromFormat("Expected allocation number %d was never done", head_->allocNumberToFail_);

    currentTest->failWith(FailFailure(currentTest, currentTest->getName().asCharString(),
    currentTest->getLineNumber(), failText), TestTerminatorWithoutExceptions());
  }
}
Пример #7
0
void JUnitTestOutput::printCurrentTestStarted(const UtestShell& test)
{
	impl_->results_.testCount_++;
	impl_->results_.group_ = test.getGroup();
	impl_->results_.startTime_ = GetPlatformSpecificTimeInMillis();

	if (impl_->results_.tail_ == 0) {
		impl_->results_.head_ = impl_->results_.tail_
				= new JUnitTestCaseResultNode;
	}
	else {
		impl_->results_.tail_->next_ = new JUnitTestCaseResultNode;
		impl_->results_.tail_ = impl_->results_.tail_->next_;
	}
	impl_->results_.tail_->name_ = test.getName();
}
Пример #8
0
void JUnitTestOutput::printCurrentTestStarted(const UtestShell& test)
{
    impl_->results_.testCount_++;
    impl_->results_.group_ = test.getGroup();
    impl_->results_.startTime_ = GetPlatformSpecificTimeInMillis();

    if (impl_->results_.tail_ == NULLPTR) {
        impl_->results_.head_ = impl_->results_.tail_
                = new JUnitTestCaseResultNode;
    }
    else {
        impl_->results_.tail_->next_ = new JUnitTestCaseResultNode;
        impl_->results_.tail_ = impl_->results_.tail_->next_;
    }
    impl_->results_.tail_->name_ = test.getName();
    impl_->results_.tail_->file_ = test.getFile();
    impl_->results_.tail_->lineNumber_ = test.getLineNumber();
    if (!test.willRun()) {
        impl_->results_.tail_->ignored_ = true;
    }
}
Пример #9
0
void NormalMemoryReportFormatter::report_test_end(TestResult* result, UtestShell& test)
{
	result->print(StringFromFormat("ENDTEST(%s, %s)\n", test.getGroup().asCharString(), test.getName().asCharString()).asCharString());
}
Пример #10
0
void CodeMemoryReportFormatter::report_test_start(TestResult* result, UtestShell& test)
{
	clearReporting();
	result->print(StringFromFormat("*/\nTEST(%s_memoryReport, %s)\n{ /* at %s:%d */\n",
			test.getGroup().asCharString(), test.getName().asCharString(), test.getFile().asCharString(), test.getLineNumber()).asCharString());
}
Пример #11
0
	virtual void fail(char* fail_string)
	{
		UtestShell* currentTest = UtestShell::getCurrent();
		currentTest->getTestResult()->addFailure(FailFailure(currentTest, currentTest->getName().asCharString(), currentTest->getLineNumber(), fail_string));
		currentTest->exitCurrentTestWithoutException();
	}