|
TTS v4.1.0
The Tiny Test System
|
Macros for defining tests scenarios. More...
Variables | |
| constexpr tts_implementation_defined | tts::constant = {} |
| Context running a case body in a constant evaluation. | |
| constexpr tts_implementation_defined | tts::runtime = {} |
| Context running a case body as ordinary code. | |
Scenarios Definitions | |
| #define | TTS_CASE(ID) |
| Defines a test case and registers it with the test driver. | |
| #define | TTS_CONTEXT(...) |
| Declares the parameter of a TTS_CASE_TPL body run in a named context. | |
| #define | TTS_CASE_IN(ID, ...) |
| Defines a test case run in each of the given contexts, and registers it with the test driver. | |
| #define | TTS_CASE_TPL_IN(ID, TYPES, ...) |
| Defines a test case run for each type of a list, in each of the given contexts, and registers it with the test driver. | |
| #define | TTS_CONSTEXPR(ID) |
| Runs a test case as ordinary code and in constant evaluation. | |
| #define | TTS_CONSTEVAL(ID) |
| Runs a test case in constant evaluation alone. | |
| #define | TTS_CASE_TPL(ID, ...) |
| Defines a test case run for each type of a list, and registers it with the test driver. | |
| #define | TTS_CASE_WITH(ID, TYPES, ...) |
| Defines a test case run for each type of a list on generated values, and registers it with the test driver. | |
| #define | TTS_XFAIL(ID) |
| Marks a test case as expected to fail. | |
| #define | TTS_MAYFAIL(ID) |
| Marks a test case as allowed to fail. | |
| #define | TTS_XINVALID(ID) |
| Marks a test case as expected to run no check. | |
| #define | TTS_TIMEOUT(MS, ID) |
| Gives a test case a deadline of its own. | |
Scoped scenarios | |
| #define | TTS_WHEN(STORY) |
| Starts a block whose code runs again before each of its sections. | |
| #define | TTS_AND_THEN(MESSAGE) |
| Adds a section to a TTS_WHEN block. | |
| #define TTS_AND_THEN | ( | MESSAGE | ) |
#include <tts/test/when.hpp>
Adds a section to a TTS_WHEN block.
A change that a section makes to a variable of the block does not reach the next section.
| MESSAGE | Text printed under --verbose when the section starts. |
| #define TTS_CASE | ( | ID | ) |
#include <tts/engine/case.hpp>
Defines a test case and registers it with the test driver.
The block after the macro is the body of the case. A case that runs no check is reported as invalid.
The case runs in tts::runtime when its title names no context. A title wrapped by TTS_CONSTEXPR or TTS_CONSTEVAL names the contexts the case runs in, and TTS_CASE_IN names any list of them.
| ID | Title of the case, or a title wrapped by a tag. |
| #define TTS_CASE_IN | ( | ID, | |
| ... ) |
#include <tts/engine/case.hpp>
Defines a test case run in each of the given contexts, and registers it with the test driver.
The contexts follow the title, among tts::runtime and tts::constant. The body runs once in each, in the order they are given.
A TTS_CASE whose title is wrapped by TTS_CONSTEXPR runs in both contexts, and one wrapped by TTS_CONSTEVAL in tts::constant alone.
| ID | Title of the case, or a title wrapped by TTS_XFAIL, TTS_MAYFAIL, TTS_XINVALID, or TTS_TIMEOUT. |
| ... | The contexts. |
| #define TTS_CASE_TPL | ( | ID, | |
| ... ) |
#include <tts/engine/case.hpp>
Defines a test case run for each type of a list, and registers it with the test driver.
The block after the macro is a generic lambda, <typename T>(tts::type<T>) { ... }, run once per type. The types are given as:
A case that runs no check is reported as invalid.
A title wrapped by TTS_CONSTEXPR or TTS_CONSTEVAL names the contexts each type runs in, and TTS_CASE_TPL_IN names any list of them. The body then declares its type through TTS_CONTEXT, as in <typename T>(TTS_CONTEXT(tts::type<T>)).
| ID | Title of the case, or a title wrapped by a tag. |
| ... | Types to run the case for. |
| #define TTS_CASE_TPL_IN | ( | ID, | |
| TYPES, | |||
| ... ) |
#include <tts/engine/case.hpp>
Defines a test case run for each type of a list, in each of the given contexts, and registers it with the test driver.
The types follow the title, between parentheses, in any form TTS_CASE_TPL accepts. The contexts come last, among tts::runtime and tts::constant. For each type, the body runs once in each context, in the order they are given.
The body declares its type with TTS_CONTEXT, as in <typename T>(TTS_CONTEXT(tts::type<T>)).
A TTS_CASE_TPL whose title is wrapped by TTS_CONSTEXPR runs in both contexts, and one wrapped by TTS_CONSTEVAL in tts::constant alone.
| ID | Title of the case, or a title wrapped by TTS_XFAIL, TTS_MAYFAIL, TTS_XINVALID, or TTS_TIMEOUT. |
| TYPES | Types to run the case for, between parentheses. |
| ... | The contexts. |
| #define TTS_CASE_WITH | ( | ID, | |
| TYPES, | |||
| ... ) |
#include <tts/engine/case.hpp>
Defines a test case run for each type of a list on generated values, and registers it with the test driver.
The block after the macro is a generic lambda with one argument per generator. The lambda runs once per type of the list, each generator building its argument for that type. The types are given as:
A case that runs no check is reported as invalid.
The case runs at run time alone, where its generators produce their values, so a title wrapped by TTS_CONSTEXPR or TTS_CONSTEVAL does not compile.
| ID | Title of the case, a string literal. |
| TYPES | Types to run the case for. |
| ... | Generators, one per argument of the body. |
| #define TTS_CONSTEVAL | ( | ID | ) |
#include <tts/engine/case.hpp>
Runs a test case in constant evaluation alone.
Wraps the title of a TTS_CASE or a TTS_CASE_TPL and names the context tts::constant. The body runs as a constant expression, and its checks are reported after the evaluation, each failure with its expression and its position. A body that calls a consteval function needs this tag, since such a function is callable in constant evaluation alone.
| ID | Title of the case, or a title already wrapped by TTS_XFAIL, TTS_MAYFAIL, TTS_XINVALID, or TTS_TIMEOUT. |
| #define TTS_CONSTEXPR | ( | ID | ) |
#include <tts/engine/case.hpp>
Runs a test case as ordinary code and in constant evaluation.
Wraps the title of a TTS_CASE or a TTS_CASE_TPL and names the contexts tts::runtime and tts::constant. The body runs as ordinary code, then as a constant expression, and the checks of both runs are counted and reported.
The body uses the ordinary checks. In constant evaluation, a failure is reported with its expression, its position, and the values the check compares at run time. A body that calls a function the language refuses in a constant expression does not compile.
| ID | Title of the case, or a title already wrapped by TTS_XFAIL, TTS_MAYFAIL, TTS_XINVALID, or TTS_TIMEOUT. |
| #define TTS_CONTEXT | ( | ... | ) |
#include <tts/engine/case.hpp>
Declares the parameter of a TTS_CASE_TPL body run in a named context.
Wraps the parameter that declares the type, TTS_CONTEXT(tts::type<T>), and adds the context in front of it. A TTS_CASE body declares no parameter, and needs no wrapper.
| ... | The parameter the body declares. |
| #define TTS_MAYFAIL | ( | ID | ) |
#include <tts/engine/case.hpp>
Marks a test case as allowed to fail.
Wraps the title of a TTS_CASE, a TTS_CASE_TPL, or a TTS_CASE_WITH. Nests with TTS_TIMEOUT, TTS_CONSTEXPR, and TTS_CONSTEVAL in either order.
The case is accepted whether its checks pass or fail, and neither outcome is reported as a failure.
A case that runs no check is still reported as invalid, as for a case without the tag.
| ID | Title of the case, a string literal. |
| #define TTS_TIMEOUT | ( | MS, | |
| ID ) |
#include <tts/engine/case.hpp>
Gives a test case a deadline of its own.
Wraps the title of a TTS_CASE, a TTS_CASE_TPL, or a TTS_CASE_WITH. Kills the case once it has run for MS milliseconds, and ends the run there. 0 removes, for that case, the deadline --timeout sets.
Nests with TTS_XFAIL, TTS_MAYFAIL, TTS_XINVALID, TTS_CONSTEXPR, and TTS_CONSTEVAL in either order.
| MS | Deadline in milliseconds. |
| ID | Title of the case, a string literal. |
| #define TTS_WHEN | ( | STORY | ) |
#include <tts/test/when.hpp>
Starts a block whose code runs again before each of its sections.
A section is a TTS_AND_THEN block inside it.
| STORY | Text printed under --verbose when the block starts. |
| #define TTS_XFAIL | ( | ID | ) |
#include <tts/engine/case.hpp>
Marks a test case as expected to fail.
Wraps the title of a TTS_CASE, a TTS_CASE_TPL, or a TTS_CASE_WITH, as in TTS_CASE(TTS_XFAIL("...")). Nests with TTS_TIMEOUT, TTS_CONSTEXPR, and TTS_CONSTEVAL in either order.
The case passes when at least one of its checks fails, and fails when every check passes.
A case that runs no check fails too. TTS_XINVALID marks a case expected to run none.
| ID | Title of the case, a string literal. |
| #define TTS_XINVALID | ( | ID | ) |
#include <tts/engine/case.hpp>
Marks a test case as expected to run no check.
Wraps the title of a TTS_CASE, a TTS_CASE_TPL, or a TTS_CASE_WITH. Nests with TTS_TIMEOUT, TTS_CONSTEXPR, and TTS_CONSTEVAL in either order.
The case fails when it runs any check, passing or failing.
| ID | Title of the case, a string literal. |
|
inlineconstexpr |
#include <tts/engine/context.hpp>
Context running a case body in a constant evaluation.
TTS_CASE_IN names the context, alone or with tts::runtime, and TTS_CONSTEXPR or TTS_CONSTEVAL on the title of a case does the same. The body is evaluated in one constant expression. The checks are reported afterward: each pass counts, each failure names its file, its line, and its expression. If the case runs in tts::runtime too, the body runs once more, silently, so that the message adds the values the failed check compares at run time. A body that calls a function the language refuses in a constant expression does not compile. The diagnostic names the call.
The checks accepted in this context:
The precision, sequence, range, and exception checks run at run time alone, and so does a TTS_CASE_WITH, whose values the generators produce at run time.
|
inlineconstexpr |
#include <tts/engine/context.hpp>
Context running a case body as ordinary code.
A plain TTS_CASE runs in this context. TTS_CASE_IN names the context, alone or with tts::constant. The body is called like a function. The checks of the body count and report like those of a plain case.