The Pt::Unit module provides a complete framework for effective unit testing. Simple tests are implemented by deriving from TestCase, multi-method suites by deriving from TestSuite. Setup and teardown of resources is provided by the TestFixture interface. Test conditions are verified through the Assertion class and the PT_UNIT_ASSERT macros. Execution order and data-driven repetition are controlled by a TestProtocol. Tests are auto-registered with RegisterTest and run by the Application class, which reports results through Reporter. A ready-made main() function is available by including TestMain.h.
Classes | |
| class | Application |
| Run registered tests. More... | |
| class | Assertion |
| Test Assertion exception More... | |
| struct | RegisterTest< TestT > |
| Registers tests to an application. More... | |
| class | Reporter |
| Test event reporter More... | |
| class | Test |
| Test base class More... | |
| class | TestCase |
| Single test with setup and teardown. More... | |
| class | TestContext |
| Context in which test are run. More... | |
| class | TestFixture |
| Fixture interface for tests. More... | |
| class | TestProtocol |
| Protocol for test suites. More... | |
| class | TestSuite |
| Protocol and data driven testing. More... | |
Macros | |
| #define | PT_UNIT_ASSERT(cond) |
| Asserts that a condition is true. More... | |
| #define | PT_UNIT_ASSERT_MSG(cond, what) |
| Asserts that a condition is true with a custom message. More... | |
| #define | PT_UNIT_ASSERT_EQUALS(value1, value2) |
| Deprecated. Use PT_UNIT_ASSERT_EQUAL instead. | |
| #define | PT_UNIT_ASSERT_EQUAL(value1, value2) |
| Asserts that two values are equal. More... | |
| #define | PT_UNIT_ASSERT_NEAR(value1, value2) |
| Asserts that two floating-point values are approximately equal. More... | |
| #define | PT_UNIT_ASSERT_THROW(cond, EX) |
| Asserts that an expression throws a specific exception. More... | |
| #define | PT_UNIT_ASSERT_NOTHROW(cond) |
| Asserts that an expression does not throw. More... | |
| #define | PT_UNIT_FAIL(what) |
| Fails unconditionally with a message. More... | |
| #define PT_UNIT_ASSERT | ( | cond | ) |
Throws Assertion with the stringified condition and source location if cond evaluates to false.
| cond | The condition to verify. |
| #define PT_UNIT_ASSERT_MSG | ( | cond, | |
| what | |||
| ) |
Throws Assertion with the given message and source location if cond evaluates to false.
| cond | The condition to verify. |
| what | A message or stream expression describing the failure. |
| #define PT_UNIT_ASSERT_EQUAL | ( | value1, | |
| value2 | |||
| ) |
Throws Assertion if value1 and value2 are not equal. Both values are printed in the failure message.
| value1 | The first value. |
| value2 | The second value. |
| #define PT_UNIT_ASSERT_NEAR | ( | value1, | |
| value2 | |||
| ) |
Throws Assertion if the absolute difference between value1 and value2 exceeds a relative tolerance derived from machine epsilon.
| value1 | The first value. |
| value2 | The second value. |
| #define PT_UNIT_ASSERT_THROW | ( | cond, | |
| EX | |||
| ) |
Throws Assertion if cond does not throw an exception of type EX.
| cond | The expression to evaluate. |
| EX | The expected exception type. |
| #define PT_UNIT_ASSERT_NOTHROW | ( | cond | ) |
Throws Assertion if cond throws any exception.
| cond | The expression to evaluate. |
| #define PT_UNIT_FAIL | ( | what | ) |
Throws Assertion with the given message.
| what | A message or stream expression describing the failure. |