TTS v3.0.0
The Tiny Test System
Loading...
Searching...
No Matches
Type Tests Macros

Macros for performing checks on types and their properties. More...

Macros

#define TTS_EXPECT_COMPILES(Symbols, Expression, ...)
 Checks if an Expression based on a list of Symbols will compile properly in a SFINAE context.
#define TTS_EXPECT_NOT_COMPILES(Symbols..., Expression, ...)
 Checks if an Expression based on a list of Symbols will not compile properly in a SFINAE context.
#define TTS_EXPR_IS(EXPR, TYPE, ...)
 Checks if an Expression evaluates to a value of a given Type.
#define TTS_TYPE_IS(TYPE, REF, ...)
 Checks if two types satisfy std::is_same_v<Type,Target> == true.

Macro Definition Documentation

◆ TTS_EXPECT_COMPILES

#define TTS_EXPECT_COMPILES ( Symbols,
Expression,
... )

#include <tts/test/types.hpp>

Checks if an Expression based on a list of Symbols will compile properly in a SFINAE context.

Parameters
SymbolsVariadic lists of symbols used in the tests
ExpressionBrace-enclosed expression to validate.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check that expression can compile properly")
{
double d, e;
TTS_EXPECT_COMPILES(d, e, { d += 4. * e; });
};

◆ TTS_EXPECT_NOT_COMPILES

#define TTS_EXPECT_NOT_COMPILES ( Symbols...,
Expression,
... )

#include <tts/test/types.hpp>

Checks if an Expression based on a list of Symbols will not compile properly in a SFINAE context.

Parameters
SymbolsVariadic lists of symbols used in the tests
ExpressionBrace-enclosed expression to validate.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check that expression cannot compile properly")
{
double d, e;
TTS_EXPECT_NOT_COMPILES(d, e, { d.foo(e); });
};

◆ TTS_EXPR_IS

#define TTS_EXPR_IS ( EXPR,
TYPE,
... )

#include <tts/test/types.hpp>

Checks if an Expression evaluates to a value of a given Type.

Parameters
EXPRExpression to evaluate.
TYPEExpected type.
...Optional tag. If equals to REQUIRED, this test will stop the program if it fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check that expression types can be tested for equality")
{
[[maybe_unused]] double d;
TTS_EXPR_IS(&d + 5, double*);
TTS_EXPR_IS(std::move(d), double&&);
TTS_EXPR_IS(std::swap(d, d), void);
};

◆ TTS_TYPE_IS

#define TTS_TYPE_IS ( TYPE,
REF,
... )

#include <tts/test/types.hpp>

Checks if two types satisfy std::is_same_v<Type,Target> == true.

Parameters
TYPEType to compare.
REFExpected type.
...Optional tag. If equals to REQUIRED, this test will stop the program if it fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <type_traits>
TTS_CASE("Check that types can be tested for equivalence")
{
TTS_TYPE_IS(std::add_pointer<float const>::type, float const*);
};