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

Macros for performing checks related to exceptions handling. More...

Macros

#define TTS_NO_THROW(EXPR, ...)
 Checks if a given expression throws no exception.
 
#define TTS_THROW(EXPR, EXCEPTION, ...)
 Checks if a given expression throws an exception of a given type.
 

Macro Definition Documentation

◆ TTS_NO_THROW

#define TTS_NO_THROW (   EXPR,
  ... 
)

#include <tts/test/exceptions.hpp>

Checks if a given expression throws no exception.

Parameters
EXPRExpression to evaluate.
...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>
void bar() {}
TTS_CASE("Check that nothrow function are detected as such") { TTS_NO_THROW(bar()); };
#define TTS_NO_THROW(EXPR,...)
Checks if a given expression throws no exception.
Definition exceptions.hpp:123
#define TTS_CASE(ID)
Introduces a new test scenario and registers it into the current test driver.
Definition case.hpp:139

◆ TTS_THROW

#define TTS_THROW (   EXPR,
  EXCEPTION,
  ... 
)

#include <tts/test/exceptions.hpp>

Checks if a given expression throws an exception of a given type.

Parameters
EXPRExpression to evaluate.
EXCEPTIONExpected exception type to be thrown.
...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>
struct some_exception_type
{
};
void foo() { throw some_exception_type(); }
TTS_CASE("Check that we can capture thrown exceptions") { TTS_THROW(foo(), some_exception_type); };
#define TTS_THROW(EXPR, EXCEPTION,...)
Checks if a given expression throws an exception of a given type.
Definition exceptions.hpp:73