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

Various assertion macros (assertXxx()) are defined in this header. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define assertEqual(arg1, arg2)    assertOpInternal(arg1,aunit::internal::compareEqual,"==",arg2)
 Assert that arg1 is equal to arg2.
 
#define assertNotEqual(arg1, arg2)    assertOpInternal(arg1,aunit::internal::compareNotEqual,"!=",arg2)
 Assert that arg1 is not equal to arg2.
 
#define assertLess(arg1, arg2)    assertOpInternal(arg1,aunit::internal::compareLess,"<",arg2)
 Assert that arg1 is less than arg2.
 
#define assertMore(arg1, arg2)    assertOpInternal(arg1,aunit::internal::compareMore,">",arg2)
 Assert that arg1 is more than arg2.
 
#define assertLessOrEqual(arg1, arg2)    assertOpInternal(arg1,aunit::internal::compareLessOrEqual,"<=",arg2)
 Assert that arg1 is less than or equal to arg2.
 
#define assertMoreOrEqual(arg1, arg2)    assertOpInternal(arg1,aunit::internal::compareMoreOrEqual,">=",arg2)
 Assert that arg1 is more than or equal to arg2.
 
#define assertStringCaseEqual(arg1, arg2)    assertOpInternal(arg1,aunit::internal::compareStringCaseEqual,"==",arg2)
 Assert that string arg1 is equal to string arg2, case-insensitive.
 
#define assertStringCaseNotEqual(arg1, arg2)    assertOpInternal(arg1,aunit::internal::compareStringCaseNotEqual,"!=",arg2)
 Assert that string arg1 is not equal to string arg2, case-insensitive.
 
#define assertTrue(arg)   assertBoolInternal(arg,true)
 Assert that arg is true.
 
#define assertFalse(arg)   assertBoolInternal(arg,false)
 Assert that arg is false.
 
#define assertOpInternal(arg1, op, opName, arg2)
 Internal helper macro, shouldn't be called directly by users. More...
 
#define assertBoolInternal(arg, value)
 Internal helper macro, shouldn't be called directly by users. More...
 
#define assertNear(arg1, arg2, error)
 Assert that arg1 and arg2 are within error of each other. More...
 
#define assertNotNear(arg1, arg2, error)
 Assert that arg1 and arg2 are NOT within error of each other. More...
 
#define assertNoFatalFailure(statement)
 Assert that the inner 'statement' returns with no fatal assertions. More...
 

Detailed Description

Various assertion macros (assertXxx()) are defined in this header.

These macros can be used only in a subclass of TestOnce or TestAgain, which is true for all tests created by test(), testing(), testF() and testingF().

Definition in file AssertMacros.h.

Macro Definition Documentation

◆ assertBoolInternal

#define assertBoolInternal (   arg,
  value 
)
Value:
do {\
if (!assertionBool(__FILE__,__LINE__,(arg),(value)))\
return;\
} while (false)

Internal helper macro, shouldn't be called directly by users.

Definition at line 84 of file AssertMacros.h.

◆ assertNear

#define assertNear (   arg1,
  arg2,
  error 
)
Value:
do { \
if (!assertionNear(__FILE__, __LINE__, \
arg1, arg2, error, "<=", aunit::internal::compareNear)) \
return;\
} while (false)

Assert that arg1 and arg2 are within error of each other.

Definition at line 90 of file AssertMacros.h.

◆ assertNoFatalFailure

#define assertNoFatalFailure (   statement)
Value:
do { \
statement; \
if (isDone()) return; \
} while (false)

Assert that the inner 'statement' returns with no fatal assertions.

This is required because AUnit does not use exceptions, so we have to check the assertion state after calling an inner function. This macro is similar to the ASSERT_NO_FATAL_FAILURE(statement) in GoogleTest.

Definition at line 109 of file AssertMacros.h.

◆ assertNotNear

#define assertNotNear (   arg1,
  arg2,
  error 
)
Value:
do { \
if (!assertionNear(__FILE__, __LINE__, \
arg1, arg2, error, ">", aunit::internal::compareNotNear)) \
return;\
} while (false)

Assert that arg1 and arg2 are NOT within error of each other.

Definition at line 97 of file AssertMacros.h.

◆ assertOpInternal

#define assertOpInternal (   arg1,
  op,
  opName,
  arg2 
)
Value:
do {\
if (!assertion(__FILE__,__LINE__,(arg1),opName,op,(arg2)))\
return;\
} while (false)

Internal helper macro, shouldn't be called directly by users.

Definition at line 78 of file AssertMacros.h.