tts v2.3.0
The Tiny Test System
 
Loading...
Searching...
No Matches

◆ TTS_AND_THEN

#define TTS_AND_THEN (   ...)    TTS_AND_THEN_IMPL(TTS_UNIQUE(id), __VA_ARGS__)

Add a scoped tests to current scoped environment.

Compared to regular local scope, whenever a scoped test is run, the data defined in the enclosing TTS_WHEN are re-initialized, thus serving as a setup/tear-down system.

Example

#define TTS_MAIN
#include <tts/tts.hpp>
TTS_CASE( "Check test with sub-test" )
{
TTS_WHEN("We start some sub-test")
{
int i = 99;
TTS_AND_THEN("We increment a variable")
{
TTS_EQUAL(i,99);
i++;
TTS_EQUAL(i,100);
}
TTS_AND_THEN("We decrement a variable")
{
// At the start of this sub-test, i is equal to 99 again
TTS_EQUAL(i,99);
i--;
TTS_EQUAL(i,98);
}
}
};
#define TTS_CASE(ID)
Introduces a new test scenario and registers it into the current test driver.
Definition: case.hpp:147
#define TTS_EQUAL(LHS, RHS,...)
Performs equality comparison between two expressions.
Definition: relation.hpp:90
#define TTS_WHEN(STORY)
Start a block of scoped environment.
Definition: when.hpp:80
#define TTS_AND_THEN(...)
Add a scoped tests to current scoped environment.
Definition: when.hpp:144