ZeroErr
unittest.h File Reference
#include "zeroerr/internal/config.h"
#include <functional>
#include <string>
#include <vector>
Include dependency graph for unittest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  zeroerr::TestContext
 TestContext is a class that holds the test results and reporter context. There are 8 different matrices that are used to store the test results. More...
 
struct  zeroerr::UnitTest
 UnitTest is a class that holds the test configuration. There are several options that can be set to configure the test. More...
 
struct  zeroerr::TestCase
 TestCase is a class that holds the test case information. There are several fields that are used to store the test case information. More...
 
struct  zeroerr::SubCase
 SubCase is a class that holds the subcase information. More...
 
struct  zeroerr::TestedObjects< T >
 
class  zeroerr::IReporter
 IReporter is an interface that is used to report the test results. You can create a new reporter by inheriting this class and implementing the virtual functions. The following events will be called once it happens during testing. More...
 
struct  zeroerr::detail::regTest
 regTest is a class that is used to register the test case. It will be used as global variables and the constructor will be called to register the test case. More...
 
struct  zeroerr::detail::regReporter
 regReporter is a class that is used to register the reporter. It will be used as global variables and the constructor will be called to register the reporter. More...
 
class  zeroerr::CombinationalTest
 CombinationalTest is a class that is used to cross test a few lists of arguments. One example. More...
 
class  zeroerr::TestArgs< T >
 TestArgs is a class that is used to store the test arguments. More...
 

Namespaces

 zeroerr
 
 zeroerr::detail
 

Macros

#define ZEROERR_CREATE_TEST_FUNC(function, name)
 
#define TEST_CASE(name)   ZEROERR_CREATE_TEST_FUNC(ZEROERR_NAMEGEN(_zeroerr_testcase), name)
 
#define SUB_CASE(name)
 
#define ZEROERR_CREATE_TEST_CLASS(fixture, classname, funcname, name)
 
#define TEST_CASE_FIXTURE(fixture, name)
 
#define ZEROERR_HAVE_SAME_OUTPUT   _ZEROERR_TEST_CONTEXT->save_output();
 
#define SCENARIO(...)   TEST_CASE("Scenario: " __VA_ARGS__)
 
#define GIVEN(...)   SUB_CASE("given: " __VA_ARGS__)
 
#define WHEN(...)   SUB_CASE("when: " __VA_ARGS__)
 
#define THEN(...)   SUB_CASE("then: " __VA_ARGS__)
 

Enumerations

enum  zeroerr::TestType { zeroerr::test_case = 1 , zeroerr::sub_case = 1 << 1 , zeroerr::bench = 1 << 2 , zeroerr::fuzz_test = 1 << 3 }
 TestType is a enum describe the type of the test case. More...
 

Macro Definition Documentation

◆ GIVEN

#define GIVEN (   ...)    SUB_CASE("given: " __VA_ARGS__)

◆ SCENARIO

#define SCENARIO (   ...)    TEST_CASE("Scenario: " __VA_ARGS__)

◆ SUB_CASE

#define SUB_CASE (   name)
Value:
zeroerr::SubCase(name, __FILE__, __LINE__, _ZEROERR_TEST_CONTEXT) \
TestContext is a class that holds the test results and reporter context. There are 8 different matric...
Definition: unittest.h:67
#define ZEROERR_UNUSED(x)
Definition: config.h:324
constexpr bool _ZEROERR_TEST_CONTEXT
Definition: assert.h:209
SubCase is a class that holds the subcase information.
Definition: unittest.h:196

◆ TEST_CASE

#define TEST_CASE (   name)    ZEROERR_CREATE_TEST_FUNC(ZEROERR_NAMEGEN(_zeroerr_testcase), name)

◆ TEST_CASE_FIXTURE

#define TEST_CASE_FIXTURE (   fixture,
  name 
)
Value:
ZEROERR_CREATE_TEST_CLASS(fixture, ZEROERR_NAMEGEN(_zeroerr_class), \
ZEROERR_NAMEGEN(_zeroerr_test_method), name)
#define ZEROERR_NAMEGEN(x)
Definition: config.h:104
#define ZEROERR_CREATE_TEST_CLASS(fixture, classname, funcname, name)
Definition: unittest.h:23

◆ THEN

#define THEN (   ...)    SUB_CASE("then: " __VA_ARGS__)

◆ WHEN

#define WHEN (   ...)    SUB_CASE("when: " __VA_ARGS__)

◆ ZEROERR_CREATE_TEST_CLASS

#define ZEROERR_CREATE_TEST_CLASS (   fixture,
  classname,
  funcname,
  name 
)
Value:
class classname : public fixture { \
public: \
void funcname(zeroerr::TestContext*); \
}; \
static void ZEROERR_CAT(call_, funcname)(zeroerr::TestContext * _ZEROERR_TEST_CONTEXT) { \
classname instance; \
instance.funcname(_ZEROERR_TEST_CONTEXT); \
} \
static zeroerr::detail::regTest ZEROERR_NAMEGEN(_zeroerr_reg)( \
{name, __FILE__, __LINE__, ZEROERR_CAT(call_, funcname)}); \
inline void classname::funcname(ZEROERR_UNUSED(zeroerr::TestContext* _ZEROERR_TEST_CONTEXT))
#define ZEROERR_CAT(x, s)
Definition: config.h:76
regTest is a class that is used to register the test case. It will be used as global variables and th...
Definition: unittest.h:262

◆ ZEROERR_CREATE_TEST_FUNC

#define ZEROERR_CREATE_TEST_FUNC (   function,
  name 
)
Value:
static void function(zeroerr::TestContext*); \
static zeroerr::detail::regTest ZEROERR_NAMEGEN(_zeroerr_reg)( \
{name, __FILE__, __LINE__, function}); \

◆ ZEROERR_HAVE_SAME_OUTPUT

#define ZEROERR_HAVE_SAME_OUTPUT   _ZEROERR_TEST_CONTEXT->save_output();