AUnit  1.7.1
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
Macros
TestMacros.h File Reference

Various macros (test(), testF(), testing(), testingF(), externTest(), externTestF(), externTesting(), externTestingF()) are defined in this header. More...

#include <stdint.h>
#include <Arduino.h>
#include "Flash.h"
#include "FCString.h"
#include "TestOnce.h"
#include "TestAgain.h"
Include dependency graph for TestMacros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define test(...)    GET_TEST(__VA_ARGS__, TEST2, TEST1)(__VA_ARGS__)
 Macro to define a test that will be run only once. More...
 
#define GET_TEST(_1, _2, NAME, ...)   NAME
 
#define TEST1(name)
 
#define TEST2(suiteName, name)
 
#define testing(...)    GET_TESTING(__VA_ARGS__, TESTING2, TESTING1)(__VA_ARGS__)
 Macro to define a test that will run repeatly upon each iteration of the global loop() method, stopping when the something calls Test::pass(), Test::fail() or Test::skip(). More...
 
#define GET_TESTING(_1, _2, NAME, ...)   NAME
 
#define TESTING1(name)
 
#define TESTING2(suiteName, name)
 
#define externTest(...)    GET_EXTERN_TEST(__VA_ARGS__, EXTERN_TEST2, EXTERN_TEST1)(__VA_ARGS__)
 Create an extern reference to a test() test case object defined elsewhere. More...
 
#define GET_EXTERN_TEST(_1, _2, NAME, ...)   NAME
 
#define EXTERN_TEST1(name)
 
#define EXTERN_TEST2(suiteName, name)
 
#define externTesting(...)    GET_EXTERN_TESTING(__VA_ARGS__, EXTERN_TESTING2, EXTERN_TESTING1)(__VA_ARGS__)
 Create an extern reference to a testing() test case object defined elsewhere. More...
 
#define GET_EXTERN_TESTING(_1, _2, NAME, ...)   NAME
 
#define EXTERN_TESTING1(name)
 
#define EXTERN_TESTING2(suiteName, name)
 
#define testF(testClass, name)
 Create a test that is derived from a custom TestOnce class. More...
 
#define testingF(testClass, name)
 Create a test that is derived from a custom TestAgain class. More...
 
#define externTestF(testClass, name)
 Create an extern reference to a testF() test case object defined elsewhere. More...
 
#define externTestingF(testClass, name)
 Create an extern reference to a testingF() test case object defined elsewhere. More...
 

Detailed Description

Various macros (test(), testF(), testing(), testingF(), externTest(), externTestF(), externTesting(), externTestingF()) are defined in this header.

Definition in file TestMacros.h.

Macro Definition Documentation

◆ EXTERN_TEST1

#define EXTERN_TEST1 (   name)
Value:
class test_##name : public aunit::TestOnce {\
public:\
test_##name();\
void once();\
};\
extern test_##name test_##name##_instance
Similar to TestAgain but performs user-defined test only once.
Definition: TestOnce.h:40
virtual void once()=0
User-provided test case.

Definition at line 130 of file TestMacros.h.

◆ EXTERN_TEST2

#define EXTERN_TEST2 (   suiteName,
  name 
)
Value:
class suiteName##_##name : public aunit::TestOnce {\
public:\
suiteName##_##name();\
void once();\
};\
extern suiteName##_##name suiteName##_##name##_instance

Definition at line 138 of file TestMacros.h.

◆ EXTERN_TESTING1

#define EXTERN_TESTING1 (   name)
Value:
class test_ ## name : public aunit::TestAgain {\
public:\
test_ ## name();\
void again();\
};\
extern test_##name test_##name##_instance
Similar to TestOnce but performs the user-defined test multiple times.
Definition: TestAgain.h:37
virtual void again()=0
User-provided test case.

Definition at line 160 of file TestMacros.h.

◆ EXTERN_TESTING2

#define EXTERN_TESTING2 (   suiteName,
  name 
)
Value:
class suiteName##_ ## name : public aunit::TestAgain {\
public:\
suiteName##_ ## name();\
void again();\
};\
extern suiteName##_##name suiteName##_##name##_instance

Definition at line 168 of file TestMacros.h.

◆ externTest

#define externTest (   ...)     GET_EXTERN_TEST(__VA_ARGS__, EXTERN_TEST2, EXTERN_TEST1)(__VA_ARGS__)

Create an extern reference to a test() test case object defined elsewhere.

This is only necessary if you use assertTestXxx() or checkTestXxx() when the test is in another file (or defined after the assertion on it).

Two versions are supported: externTest(name) and externTest(suiteName, name). The 2-argument externTest(suiteName, name) is a convenience macro which is identical to externTest(suiteName_name).

Definition at line 125 of file TestMacros.h.

◆ externTestF

#define externTestF (   testClass,
  name 
)
Value:
class testClass ## _ ## name : public testClass {\
public:\
testClass ## _ ## name();\
void once() override;\
};\
extern testClass ## _ ## name testClass##_##name##_instance

Create an extern reference to a testF() test case object defined elsewhere.

This is only necessary if you use assertTestXxx() or checkTestXxx() when the test is in another file (or defined after the assertion on it).

Definition at line 216 of file TestMacros.h.

◆ externTesting

#define externTesting (   ...)     GET_EXTERN_TESTING(__VA_ARGS__, EXTERN_TESTING2, EXTERN_TESTING1)(__VA_ARGS__)

Create an extern reference to a testing() test case object defined elsewhere.

This is only necessary if you use assertTestXxx() or checkTestXxx() when the test is in another file (or defined after the assertion on it).

Two versions are supported: externTesting(name) and externTesting(suiteName, name).

Definition at line 155 of file TestMacros.h.

◆ externTestingF

#define externTestingF (   testClass,
  name 
)
Value:
class testClass ## _ ## name : public testClass {\
public:\
testClass ## _ ## name();\
void again() override;\
};\
extern testClass ## _ ## name testClass##_##name##_instance

Create an extern reference to a testingF() test case object defined elsewhere.

This is only necessary if you use assertTestXxx() or checkTestXxx() when the test is in another file (or defined after the assertion on it).

Definition at line 230 of file TestMacros.h.

◆ test

#define test (   ...)     GET_TEST(__VA_ARGS__, TEST2, TEST1)(__VA_ARGS__)

Macro to define a test that will be run only once.

Two versions are supported: test(name) and test(suiteName, name). The 2-argument test(suiteName, name) is a convenience macro which is identical to test(suiteName_name).

Definition at line 53 of file TestMacros.h.

◆ TEST1

#define TEST1 (   name)
Value:
class test_##name : public aunit::TestOnce {\
public:\
test_##name();\
void once() override;\
} test_##name##_instance;\
test_##name :: test_##name() {\
init(AUNIT_F(#name)); \
}\
void test_##name :: once()

Definition at line 58 of file TestMacros.h.

◆ TEST2

#define TEST2 (   suiteName,
  name 
)
Value:
class suiteName##_##name : public aunit::TestOnce {\
public:\
suiteName##_##name();\
void once() override;\
} suiteName##_##name##_instance;\
suiteName##_##name :: suiteName##_##name() {\
init(AUNIT_F(#suiteName "_" #name)); \
}\
void suiteName##_##name :: once()

Definition at line 69 of file TestMacros.h.

◆ testF

#define testF (   testClass,
  name 
)
Value:
class testClass ## _ ## name : public testClass {\
public:\
testClass ## _ ## name();\
void once() override;\
} testClass ## _ ## name ## _instance;\
testClass ## _ ## name :: testClass ## _ ## name() {\
init(AUNIT_F(#testClass "_" #name));\
}\
void testClass ## _ ## name :: once()

Create a test that is derived from a custom TestOnce class.

The name of the instance is prefixed by '{testClass}_' to avoid name collisions with similarly named tests using other fixtures.

Definition at line 181 of file TestMacros.h.

◆ testing

#define testing (   ...)     GET_TESTING(__VA_ARGS__, TESTING2, TESTING1)(__VA_ARGS__)

Macro to define a test that will run repeatly upon each iteration of the global loop() method, stopping when the something calls Test::pass(), Test::fail() or Test::skip().

Two versions are supported: testing(name) and testing(suiteName, name). The 2-argument testing(suiteName, name) is a convenience macro which is identical to testing(suiteName_name).

Definition at line 89 of file TestMacros.h.

◆ TESTING1

#define TESTING1 (   name)
Value:
class test_##name : public aunit::TestAgain {\
public:\
test_##name();\
void again() override;\
} test_##name##_instance;\
test_##name :: test_##name() {\
init(AUNIT_F(#name));\
}\
void test_##name :: again()

Definition at line 94 of file TestMacros.h.

◆ TESTING2

#define TESTING2 (   suiteName,
  name 
)
Value:
class suiteName##_##name : public aunit::TestAgain {\
public:\
suiteName##_##name();\
void again() override;\
} suiteName##_##name##_instance;\
suiteName##_##name :: suiteName##_##name() {\
init(AUNIT_F(#suiteName "_" #name));\
}\
void suiteName##_##name :: again()

Definition at line 105 of file TestMacros.h.

◆ testingF

#define testingF (   testClass,
  name 
)
Value:
class testClass ## _ ## name : public testClass {\
public:\
testClass ## _ ## name();\
void again() override;\
} testClass ## _ ## name ## _instance;\
testClass ## _ ## name :: testClass ## _ ## name() {\
init(AUNIT_F(#testClass "_" #name));\
}\
void testClass ## _ ## name :: again()

Create a test that is derived from a custom TestAgain class.

The name of the instance is prefixed by '{testClass}_' to avoid name collisions with similarly named tests using other fixtures.

Note that test(suiteName, name) is different than testF(className, name), but there will be a name collision if suiteName is the same as className.

Definition at line 200 of file TestMacros.h.