AUnit
0.3.1
Unit testing framework for Arduino platforms inspired by ArduinoUnit.
src
aunit
MetaAssertion.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
34
#ifndef AUNIT_META_ASSERTION_H
35
#define AUNIT_META_ASSERTION_H
36
37
#include <Arduino.h>
// definition of Print
38
#include "Printer.h"
39
#include "TestRunner.h"
40
41
// Meta tests, same syntax as ArduinoUnit for compatibility.
42
// The checkTestXxx() macros return a boolean, and execution continues.
43
45
#define checkTestDone(name) (test_##name##_instance.isDone())
46
48
#define checkTestNotDone(name) (test_##name##_instance.isNotDone())
49
51
#define checkTestPass(name) (test_##name##_instance.isPassed())
52
54
#define checkTestNotPass(name) (test_##name##_instance.isNotPassed())
55
57
#define checkTestFail(name) (test_##name##_instance.isFailed())
58
60
#define checkTestNotFail(name) (test_##name##_instance.isNotFailed())
61
63
#define checkTestSkip(name) (test_##name##_instance.isSkipped())
64
66
#define checkTestNotSkip(name) (test_##name##_instance.isNotSkipped())
67
69
#define checkTestExpire(name) (test_##name##_instance.isExpired())
70
72
#define checkTestNotExpire(name) (test_##name##_instance.isNotExpired())
73
74
// If the assertTestXxx() macros fail, they generate an optional output, calls
75
// fail(), and returns from the current test case.
76
78
#define assertTestDone(name) assertTestStatus(name, isDone)
79
81
#define assertTestNotDone(name) assertTestStatus(name, isNotDone)
82
84
#define assertTestPass(name) assertTestStatus(name, isPassed)
85
87
#define assertTestNotPass(name) assertTestStatus(name, isNotPassed)
88
90
#define assertTestFail(name) assertTestStatus(name, isFailed)
91
93
#define assertTestNotFail(name) assertTestStatus(name, isNotFailed)
94
96
#define assertTestSkip(name) assertTestStatus(name, isSkipped)
97
99
#define assertTestNotSkip(name) assertTestStatus(name, isNotSkipped)
100
102
#define assertTestExpire(name) assertTestStatus(name, isExpired)
103
105
#define assertTestNotExpire(name) assertTestStatus(name, isNotExpired)
106
108
#define assertTestStatus(name,method) do {\
109
if (!aunit::assertionTestStatus(\
110
__FILE__,__LINE__,#name,#method,test_##name##_instance.method()))\
111
return;\
112
} while (false)
113
114
namespace
aunit
{
115
120
bool
assertionTestStatus(
const
char
* file, uint16_t line,
121
const
char
* testName,
const
char
* statusName,
bool
ok);
122
123
}
124
125
#endif
aunit
Definition:
Assertion.cpp:27
Generated by
1.8.14