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

◆ TTS_CASE_WITH

#define TTS_CASE_WITH (   ID,
  TYPES,
  GENERATOR 
)
Value:
[[maybe_unused]] static bool const TTS_CAT(case_,TTS_FUNCTION) \
= ::tts::detail::test_generators{ID,GENERATOR,TYPES{}} << TTS_PROTOTYPE() \

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:

  • an instance of the tts::types template class
  • an instance of a Type Generator, ie a type exposing a public types_list type definition

Data are passed using the tts::generate function to aggregate data generator. Test cases performing no actual tests will be reported as invalid.

Parameters
IDA literal string describing the scenario intents.
TYPESLists of types to generate the test case from.
GENERATORA generator function

Example

#define TTS_MAIN
#include <tts/tts.hpp>
TTS_CASE_WITH ( "Check behavior for scalar types"
, tts::generate(tts::value{37}, tts::between{0,100}, tts::randoms{0.,10.})
)
(auto v, auto b, auto const& r)
{
TTS_EQUAL(v, 37);
TTS_LESS_EQUAL (b, 100);
TTS_LESS_EQUAL (r, 10);
};
#define TTS_CASE_WITH(ID, TYPES, GENERATOR)
Introduces a template test case providing dynamically generated data to the test code.
Definition: case.hpp:258
auto generate(G... g)
Build a data generator.
Definition: generator.hpp:76
#define TTS_LESS_EQUAL(LHS, RHS,...)
Performs less-or-equal-than comparison between two expressions.
Definition: relation.hpp:224
#define TTS_GREATER_EQUAL(LHS, RHS,...)
Performs greater-or-equal-than comparison between two expressions.
Definition: relation.hpp:260
#define TTS_EQUAL(LHS, RHS,...)
Performs equality comparison between two expressions.
Definition: relation.hpp:90
Defines a data generator that produce value within an interval.
Definition: generator.hpp:233
Type list structure.
Definition: types.hpp:22
Defines a data generator that always return the same value.
Definition: generator.hpp:105