Macros for defining tests scenarios.
More...
|
| #define | TTS_CASE(ID) |
| | Introduces a new test scenario and registers it into the current test driver.
|
| |
| #define | TTS_CASE_TPL(ID, ...) |
| | Introduces a template test case and registers it into the current test driver.
|
| |
| #define | TTS_CASE_WITH(ID, TYPES, ...) |
| | Introduces a template test case providing dynamically generated data to the test code.
|
| |
|
| #define | TTS_WHEN(STORY) |
| | Start a block of scoped environment.
|
| |
| #define | TTS_AND_THEN(MESSAGE) |
| | Add a scoped tests to current scoped environment.
|
| |
◆ TTS_AND_THEN
| #define TTS_AND_THEN |
( |
|
MESSAGE | ) |
|
#include <tts/test/when.hpp>
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.
- See also
- TTS_WHEN
#define TTS_MAIN
#include <tts/tts.hpp>
#include <iostream>
TTS_CASE(
"Check test with sub-test") {
TTS_WHEN(
"We start some sub-test") {
int i = 99;
{
std::cout << ">> Sub-test 1: i = " << i << "\n";
i++;
}
{
std::cout << ">> Sub-test 2: i = " << i << "\n";
i--;
}
}
}
;
#define TTS_EQUAL(LHS, RHS,...)
Performs equality comparison between two expressions.
Definition relation.hpp:134
#define TTS_AND_THEN(MESSAGE)
Add a scoped tests to current scoped environment.
Definition when.hpp:112
#define TTS_WHEN(STORY)
Start a block of scoped environment.
Definition when.hpp:73
#define TTS_CASE(ID)
Introduces a new test scenario and registers it into the current test driver.
Definition case.hpp:139
◆ TTS_CASE
#include <tts/engine/case.hpp>
Introduces a new test scenario and registers it into the current test driver.
The code block following TTS_CASE contains user-defined code for a given test case. Test cases performing no actual tests will be reported as invalid.
- Parameters
-
| ID | A literal string describing the scenario intents. |
#define TTS_MAIN
#include <tts/tts.hpp>
◆ TTS_CASE_TPL
| #define TTS_CASE_TPL |
( |
|
ID, |
|
|
|
... |
|
) |
| |
#include <tts/engine/case.hpp>
Introduces a template test case and registers it into the current test driver.
The code block following TTS_CASE contains user-defined code for a given test case. Those tests are parametrized by a template type of your choice passed as lambda function parameters of the template type tts::type and instantiated for each type in the types list.
Such types list can be provided as:
- a variadic list of types separated by commas
- an instance of the tts::types template class
- an instance of a Type Generator, ie a type exposing a public
types_list type definition
Test cases performing no actual tests will be reported as invalid.
- Parameters
-
| ID | A literal string describing the scenario intents. |
| ... | Lists of types to generate the test case from. |
#define TTS_MAIN
#include <tts/tts.hpp>
#include <array>
TTS_CASE_TPL(
"Check types using variadic list",
char,
short,
int,
double,
void*)<
typename T>(
{
};
{
};
template<int N, typename Indexes = std::make_index_sequence<N>> struct sizes;
template<int N, std::size_t... I> struct sizes<N, std::index_sequence<I...>>
{
};
{
T x;
};
#define TTS_GREATER_EQUAL(LHS, RHS,...)
Performs greater-or-equal-than comparison between two expressions.
Definition relation.hpp:239
#define TTS_CASE_TPL(ID,...)
Introduces a template test case and registers it into the current test driver.
Definition case.hpp:170
Encapsulates a single type into a reusable type object.
Definition types.hpp:112
Encapsulates a variadic list of types into a reusable object.
Definition types.hpp:25
◆ TTS_CASE_WITH
| #define TTS_CASE_WITH |
( |
|
ID, |
|
|
|
TYPES, |
|
|
|
... |
|
) |
| |
#include <tts/engine/case.hpp>
Introduces a template test case providing dynamically generated data to the test code.
The following code block will contain tests parametrized by a template type of your choice passed as lambda function parameters and generated for each type in the types list.
Such types list can be provided as:
- a parenthesised list of types separated by comma.
- an instance of the tts::types template class.
- an instance of a Type Generator, ie a type exposing a public
types_list type definition
Test cases performing no actual tests will be reported as invalid.
- Parameters
-
| ID | A literal string describing the scenario intents. |
| TYPES | Lists of types to generate the test case from. |
| ... | Lists of generator function |
#define TTS_MAIN
#include <tts/tts.hpp>
(auto v, auto b, auto const& r)
{
};
#define TTS_LESS_EQUAL(LHS, RHS,...)
Performs less-or-equal-than comparison between two expressions.
Definition relation.hpp:218
#define TTS_CASE_WITH(ID, TYPES,...)
Introduces a template test case providing dynamically generated data to the test code.
Definition case.hpp:201
Defines a data generator that produce values between two bounds.
Definition generator.hpp:244
Random generator between two bounds using realistic_distribution.
Definition generator.hpp:281
Defines a data generator that always return the same value.
Definition generator.hpp:137
◆ TTS_WHEN
| #define TTS_WHEN |
( |
|
STORY | ) |
|
#include <tts/test/when.hpp>
Start a block of scoped environment.
Code in a scoped environment can contain:
- Normal expressions.
- scoped tests introduced by TTS_AND_THEN.
- See also
- TTS_AND_THEN
#define TTS_MAIN
#include <tts/tts.hpp>
#include <iostream>
TTS_CASE(
"Check test with sub-test") {
TTS_WHEN(
"We start some sub-test") {
int i = 99;
{
std::cout << ">> Sub-test 1: i = " << i << "\n";
i++;
}
{
std::cout << ">> Sub-test 2: i = " << i << "\n";
i--;
}
}
}
;