TestAssertions.h

Includes:

Overview

Use the links in the table of contents to the left to access the documentation.



Macro Definitions

CPTAssert

Basic assertion macro.


CPTAssert


Basic assertion macro.

#define CPTAssert(x) \ 
    do { \ 
    try { \ 
    if (not (x)) { \ 
    throw TestFailure(__FILE__, __LINE__, #x); \ 
    } \ 
    } \ 
    catch (TestFailure& testFaiure) { \ 
    throw; \ 
    } \ 
    catch (std::exception& exception) { \ 
    throw TestFailure(__FILE__, __LINE__, exception.what()); \ 
    } \ 
    catch (...) { \ 
    throw TestFailure(__FILE__, __LINE__, "Uncaught exception"); \ 
    } \ 
    } while (0) 
Parameters
x

An expression that should evaluate to anything non-false on success and false on failure.

Discussion

The basic assertion macro in CPlusTest records the file, line number, and reason for failure if the passed expression is false. It will also catch exceptions descending from std::exception and report their reason for failure, and will report other thrown exceptions as generic uncaught exceptions.

Did this document help you? Yes It's good, but... Not helpful...

 

Last Updated: 2009-08-12