AUnit
1.7.1
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
src
aunit
AssertVerboseMacros.h
Go to the documentation of this file.
1
/*
2
MIT License
3
4
Copyright (c) 2018 Brian T. Park
5
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
of this software and associated documentation files (the "Software"), to deal
8
in the Software without restriction, including without limitation the rights
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
copies of the Software, and to permit persons to whom the Software is
11
furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in all
14
copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
SOFTWARE.
23
*/
24
25
// Significant portions of the design and implementation of this file came from
26
// https://github.com/mmurdoch/arduinounit/blob/master/src/ArduinoUnit.h
27
36
#ifndef AUNIT_ASSERT_VERBOSE_MACROS_H
37
#define AUNIT_ASSERT_VERBOSE_MACROS_H
38
40
#define assertEqual(arg1,arg2) \
41
assertOpVerboseInternal(arg1,aunit::internal::compareEqual,"=="
,arg2)
42
44
#define assertNotEqual(arg1,arg2) \
45
assertOpVerboseInternal(arg1,aunit::internal::compareNotEqual,"!="
,arg2)
46
48
#define assertLess(arg1,arg2) \
49
assertOpVerboseInternal(arg1,aunit::internal::compareLess,"<"
,arg2)
50
52
#define assertMore(arg1,arg2) \
53
assertOpVerboseInternal(arg1,aunit::internal::compareMore,">"
,arg2)
54
56
#define assertLessOrEqual(arg1,arg2) \
57
assertOpVerboseInternal(arg1,aunit::internal::compareLessOrEqual,"<="
,arg2)
58
60
#define assertMoreOrEqual(arg1,arg2) \
61
assertOpVerboseInternal(arg1,aunit::internal::compareMoreOrEqual,">="
,arg2)
62
64
#define assertStringCaseEqual(arg1,arg2) \
65
assertOpVerboseInternal(arg1,aunit::internal::compareStringCaseEqual,\
66
"=="
,arg2)
67
69
#define assertStringCaseNotEqual(arg1,arg2) \
70
assertOpVerboseInternal(arg1,aunit::internal::compareStringCaseNotEqual,\
71
"!="
,arg2)
72
74
#define assertTrue(arg) assertBoolVerboseInternal(arg,true)
75
77
#define assertFalse(arg) assertBoolVerboseInternal(arg,false)
78
80
#define assertOpVerboseInternal(arg1,op,opName,arg2) do {\
81
if (!assertionVerbose(__FILE__,__LINE__,\
82
(arg1),AUNIT_F(#arg1),opName,op,(arg2),AUNIT_F(#arg2)))\
83
return;\
84
} while (false)
85
87
#define assertBoolVerboseInternal(arg,value) do {\
88
if (!assertionBoolVerbose(__FILE__,__LINE__,(arg),AUNIT_F(#arg),(value)))\
89
return;\
90
} while (false)
91
93
#define assertNear(arg1, arg2, error) do { \
94
if (!assertionNearVerbose(__FILE__, __LINE__, \
95
arg1, AUNIT_F(#arg1), arg2, AUNIT_F(#arg2), error, AUNIT_F(#error), \
96
"<="
, aunit::internal::compareNear)) \
97
return;\
98
} while (false)
99
101
#define assertNotNear(arg1, arg2, error) do { \
102
if (!assertionNearVerbose(__FILE__, __LINE__, \
103
arg1, AUNIT_F(#arg1), arg2, AUNIT_F(#arg2), error, AUNIT_F(#error), \
104
">"
, aunit::internal::compareNotNear)) \
105
return;\
106
} while (false)
107
114
#define assertNoFatalFailure(statement) do { \
115
statement; \
116
if (isDone()) return; \
117
} while (false)
118
119
#endif
Generated by
1.9.1