AUnit
0.4.1
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
|
An Assertion class is a subclass of Test and provides various overloaded assertion() functions. More...
#include <Assertion.h>
Protected Member Functions | |
Assertion () | |
Empty constructor. More... | |
bool | isOutputEnabled (bool ok) |
Returns true if an assertion message should be printed. More... | |
bool | assertion (const char *file, uint16_t line, bool lhs, const char *opName, bool(*op)(bool lhs, bool rhs), bool rhs) |
bool | assertion (const char *file, uint16_t line, char lhs, const char *opName, bool(*op)(char lhs, char rhs), char rhs) |
bool | assertion (const char *file, uint16_t line, int lhs, const char *opName, bool(*op)(int lhs, int rhs), int rhs) |
bool | assertion (const char *file, uint16_t line, unsigned int lhs, const char *opName, bool(*op)(unsigned int lhs, unsigned int rhs), unsigned int rhs) |
bool | assertion (const char *file, uint16_t line, long lhs, const char *opName, bool(*op)(long lhs, long rhs), long rhs) |
bool | assertion (const char *file, uint16_t line, unsigned long lhs, const char *opName, bool(*op)(unsigned long lhs, unsigned long rhs), unsigned long rhs) |
bool | assertion (const char *file, uint16_t line, double lhs, const char *opName, bool(*op)(double lhs, double rhs), double rhs) |
bool | assertion (const char *file, uint16_t line, const char *lhs, const char *opName, bool(*op)(const char *lhs, const char *rhs), const char *rhs) |
bool | assertion (const char *file, uint16_t line, const char *lhs, const char *opName, bool(*op)(const char *lhs, const String &rhs), const String &rhs) |
bool | assertion (const char *file, uint16_t line, const char *lhs, const char *opName, bool(*op)(const char *lhs, const __FlashStringHelper *rhs), const __FlashStringHelper *rhs) |
bool | assertion (const char *file, uint16_t line, const String &lhs, const char *opName, bool(*op)(const String &lhs, const char *rhs), const char *rhs) |
bool | assertion (const char *file, uint16_t line, const String &lhs, const char *opName, bool(*op)(const String &lhs, const String &rhs), const String &rhs) |
bool | assertion (const char *file, uint16_t line, const String &lhs, const char *opName, bool(*op)(const String &lhs, const __FlashStringHelper *rhs), const __FlashStringHelper *rhs) |
bool | assertion (const char *file, uint16_t line, const __FlashStringHelper *lhs, const char *opName, bool(*op)(const __FlashStringHelper *lhs, const char *rhs), const char *rhs) |
bool | assertion (const char *file, uint16_t line, const __FlashStringHelper *lhs, const char *opName, bool(*op)(const __FlashStringHelper *lhs, const String &rhs), const String &rhs) |
bool | assertion (const char *file, uint16_t line, const __FlashStringHelper *lhs, const char *opName, bool(*op)(const __FlashStringHelper *lhs, const __FlashStringHelper *rhs), const __FlashStringHelper *rhs) |
![]() | |
void | fail () |
Mark the test as failed. More... | |
void | pass () |
Mark the test as passed. More... | |
void | init (const char *name) |
void | init (const __FlashStringHelper *name) |
bool | isVerbosity (uint8_t verbosity) |
Determine if any of the given verbosity is enabled. More... | |
uint8_t | getVerbosity () |
Get the verbosity. More... | |
Additional Inherited Members | |
![]() | |
Test () | |
Empty constructor. More... | |
virtual void | setup () |
Optional method that performs any initialization. More... | |
virtual void | teardown () |
Optional method that performs any clean up after the test ends for any reasons, either passing or otherwise. More... | |
virtual void | loop ()=0 |
The user-provided test case function. More... | |
void | resolve () |
Print out the summary of the current test. More... | |
const FCString & | getName () |
Get the name of the test. More... | |
uint8_t | getStatus () |
Get the status of the test. More... | |
void | setStatus (uint8_t status) |
Set the status of the test. More... | |
void | setPassOrFail (bool ok) |
Set the status to Passed or Failed depending on ok. More... | |
Test ** | getNext () |
Return the next pointer as a pointer to the pointer, similar to getRoot(). More... | |
bool | isDone () |
Return true if test is done (passed, failed, skipped, expired). More... | |
bool | isNotDone () |
Return true if test is done (passed, failed, skipped, expired). More... | |
bool | isPassed () |
Return true if test is passed. More... | |
bool | isNotPassed () |
Return true if test is passed. More... | |
bool | isFailed () |
Return true if test is failed. More... | |
bool | isNotFailed () |
Return true if test is failed. More... | |
bool | isSkipped () |
Return true if test isNot skipped. More... | |
bool | isNotSkipped () |
Return true if test isNot skipped. More... | |
bool | isExpired () |
Return true if test is expired. More... | |
bool | isNotExpired () |
Return true if test is expired. More... | |
void | skip () |
Mark the test as skipped. More... | |
void | expire () |
Mark the test as expired (i.e. More... | |
void | enableVerbosity (uint8_t verbosity) |
Enable the given verbosity of the current test. More... | |
void | disableVerbosity (uint8_t verbosity) |
Disable the given verbosity of the current test. More... | |
![]() | |
static Test ** | getRoot () |
Get the pointer to the root pointer. More... | |
![]() | |
static const uint8_t | kStatusNew = 0 |
Test is new, needs to be setup. More... | |
static const uint8_t | kStatusSetup = 1 |
Test is set up. More... | |
static const uint8_t | kStatusPassed = 2 |
Test has passed, or pass() was called. More... | |
static const uint8_t | kStatusFailed = 3 |
Test has failed, or failed() was called. More... | |
static const uint8_t | kStatusSkipped = 4 |
Test is skipped, through the exclude() method or skip() was called. More... | |
static const uint8_t | kStatusExpired = 5 |
Test has timed out, or expire() called. More... | |
An Assertion class is a subclass of Test and provides various overloaded assertion() functions.
Having this class inherit from Test allows it to have access to the mVerbosity setting, as well as the test's current mStatus. (An earlier implementation inverted the class hierarchy between Assertion and Test). That allows every assertion() method to bail out early if it detects the result of a previous assertion() in mStatus. This delayed bailout may happen if the assertXxx() macro was called from inside a helper method of a fixture class used by testF() or testingF() macros.
For the same reason as the compareXxx() methods, we use explicit overloaded functions, instead of using template specialization. And just as before, I was unable to use a template function for primitive integer types, because it interfered with the resolution of assertion(char*, char*). The wrong function would be called.
The assertion() methods are internal helpers, they should not be called directly by users.
Definition at line 98 of file Assertion.h.
|
inlineprotected |
Empty constructor.
Definition at line 101 of file Assertion.h.
|
protected |
Returns true if an assertion message should be printed.
Definition at line 67 of file Assertion.cpp.