APM:Libraries
Classes | Macros
AP_Test.h File Reference

A simple unit test framework. More...

Go to the source code of this file.

Classes

class  Test
 

Macros

#define TEST(name)   Test _test(# name)
 
#define REQUIRE(expr)   _test.require(expr, # expr)
 

Detailed Description

A simple unit test framework.

AP_Test provides the usual test start, condition validation and reporting functions in a compact form.

Each test must be contained within a block; either a standalone function or a block within a function. The TEST macro is used to start a test; it creates the local object which will track the results of the test and saves the name for later reporting. Only one test may be performed within each block.

Within the test, use the REQUIRE macro to describe a condition that must be met for the test to pass. If the condition within the macro is not met, the condition will be output as a diagnostic and the test will be considered to have failed.

The test ends at the end of the block, and the result of the test will be output as a diagnostic.

Optionally at the end of the test suite, the Test::report method may be used to summarize the results of all of the tests that were performed.

Definition in file AP_Test.h.

Macro Definition Documentation

◆ REQUIRE

#define REQUIRE (   expr)    _test.require(expr, # expr)

Attach an expression to the test's success criteria.

The expression expr must evaluate true for the test to pass. If it does not, the text of the expression is output as a diagnostic and the test is marked as a failure.

Definition at line 134 of file AP_Test.h.

◆ TEST

#define TEST (   name)    Test _test(# name)

Start a new test.

This should be invoked at the beginning of a block, before any REQUIRE statements. A new test called name is started, and subsequent REQUIRE statements will be applied to the test. The test will continue until the end of the block (or until the _test object that is created otherwise goes out of scope).

Definition at line 126 of file AP_Test.h.