-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathet.h
More file actions
92 lines (77 loc) · 3.06 KB
/
et.h
File metadata and controls
92 lines (77 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//============================================================================
// ET: embedded test (super-simple embedded testing framework)
// GitHub: https://github.com/QuantumLeaps/Embedded-Test
//
// Q u a n t u m L e a P s
// ------------------------
// Modern Embedded Software
//
// Copyright (C) 2005 Quantum Leaps, <state-machine.com>.
//
// SPDX-License-Identifier: MIT
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//============================================================================
#ifndef ET_H_
#define ET_H_
// Embedded Test (ET) version
#define ET_VERSION "2.1.0"
//! macro to define a test group
#define TEST_GROUP(name_) \
char const ET_group_[] = name_; \
void ET_run_(void)
// macro to start a new test
#define TEST(title_) \
if (ET_test_(title_, 0))
// macro to skip a test
#define SKIP_TEST(title_) \
if (ET_test_(title_, 1))
//! macro to verify a test expectation
#define VERIFY(cond_) \
((cond_) ? (void)0 : ET_fail(#cond_, &ET_group_[0], __LINE__))
#define VERIFY_ASSERT(module_, label_) \
ET_verify_assert_((module_), (label_))
//! macro to force a failure of a test
#define FAIL(note_) \
(ET_fail(note_, &ET_group_[0], __LINE__))
#ifndef ARRAY_NELEM
//! convenience macro to provide the number of elements in the array a_
#define ARRAY_NELEM(a_) (sizeof(a_) / sizeof((a_)[0]))
#endif // ARRAY_NELEM
#ifdef __cplusplus
extern "C" {
#endif
void setup(void); //!< called right before each test
void teardown(void); //!< called right after each test
// callback functions to be implemented in the ET board support packages
void ET_onInit(int argc, char *argv[]);
void ET_onPrintChar(char const ch);
void ET_onExit(int err);
// public helpers
void ET_fail(char const *cond, char const *group, int line);
void ET_expect_assert(char const *module, int label);
void ET_verify_assert_(char const *module, int label);
// private helpers
void ET_run_(void);
int ET_test_(char const *title, int skip);
extern char const ET_group_[];
#ifdef __cplusplus
}
#endif
#endif // ET_H_