Exemplo n.º 1
0
void NormalTestTerminator::exitCurrentTest() const
{
    #if CPPUTEST_USE_STD_CPP_LIB
        throw CppUTestFailedException();
    #else
        TestTerminatorWithoutExceptions().exitCurrentTest();
    #endif
}
Exemplo n.º 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());
}
Exemplo n.º 3
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());
        }
    }
}
Exemplo n.º 4
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());
        }
    }
}
Exemplo n.º 5
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());
  }
}
Exemplo n.º 6
0
void CHECK_C_LOCATION(int condition, const char* conditionString, const char* fileName, int lineNumber)
{
    UtestShell::getCurrent()->assertTrue(condition != 0, "CHECK_C", conditionString, fileName, lineNumber, TestTerminatorWithoutExceptions());
}
Exemplo n.º 7
0
void FAIL_C_LOCATION(const char* fileName, int lineNumber)
{
    UtestShell::getCurrent()->fail("",  fileName, lineNumber, TestTerminatorWithoutExceptions());
}
Exemplo n.º 8
0
void CHECK_EQUAL_C_STRING_LOCATION(const char* expected, const char* actual, const char* fileName, int lineNumber)
{
    UtestShell::getCurrent()->assertCstrEqual(expected, actual, fileName, lineNumber, TestTerminatorWithoutExceptions());
}
Exemplo n.º 9
0
void CHECK_EQUAL_C_CHAR_LOCATION(char expected, char actual, const char* fileName, int lineNumber)
{
    UtestShell::getCurrent()->assertEquals(((expected) != (actual)), StringFrom(expected).asCharString(), StringFrom(actual).asCharString(), fileName, lineNumber, TestTerminatorWithoutExceptions());
}
Exemplo n.º 10
0
void CHECK_EQUAL_C_REAL_LOCATION(double expected, double actual, double threshold, const char* fileName, int lineNumber)
{
    UtestShell::getCurrent()->assertDoublesEqual(expected, actual, threshold,  fileName, lineNumber, TestTerminatorWithoutExceptions());
}
Exemplo n.º 11
0
void CHECK_EQUAL_C_INT_LOCATION(int expected, int actual, const char* fileName, int lineNumber)
{
    UtestShell::getCurrent()->assertLongsEqual((long)expected, (long)actual,  fileName, lineNumber, TestTerminatorWithoutExceptions());
}