RobotTestingFramework
2.0.1
Robot Testing Framework
src
robottestingframework
include
robottestingframework
TestAssert.h
Go to the documentation of this file.
1
/*
2
* Robot Testing Framework
3
*
4
* Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
22
#ifndef ROBOTTESTINGFRAMEWORK_TESTASSERT_H
23
#define ROBOTTESTINGFRAMEWORK_TESTASSERT_H
24
25
26
#if defined(_MSC_VER)
27
// see https://support.microsoft.com/kb/155196/en-us
28
# define __ROBOTTESTINGFRAMEWORK_STR2(x) # x
29
# define __ROBOTTESTINGFRAMEWORK_STR1(x) __ROBOTTESTINGFRAMEWORK_STR2(x)
30
# define __ROBOTTESTINGFRAMEWORK_LOC __FILE__ "("__STR1__(__LINE__) ")"
31
# define ROBOTTESTINGFRAMEWORK_COMPILER_MESSAGE(x) __pragma(message(__LOC__ " : msg" # x))
32
# define ROBOTTESTINGFRAMEWORK_COMPILER_WARNING(x) __pragma(message(__LOC__ " : warning msg" # x))
33
# define ROBOTTESTINGFRAMEWORK_COMPILER_ERROR(x) __pragma(message(__LOC__ " : error msg" # x))
34
#elif defined(__GNUC__)
35
// see https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
36
# define __ROBOTTESTINGFRAMEWORK_DO_PRAGMA(x) _Pragma(# x)
37
# define ROBOTTESTINGFRAMEWORK_COMPILER_MESSAGE(x) __ROBOTTESTINGFRAMEWORK_DO_PRAGMA(message # x)
38
# define ROBOTTESTINGFRAMEWORK_COMPILER_WARNING(x) __ROBOTTESTINGFRAMEWORK_DO_PRAGMA(GCC warning # x)
39
# define ROBOTTESTINGFRAMEWORK_COMPILER_ERROR(x) __ROBOTTESTINGFRAMEWORK_DO_PRAGMA(GCC error # x)
40
#else
41
# define ROBOTTESTINGFRAMEWORK_COMPILER_MESSAGE(x)
42
# define ROBOTTESTINGFRAMEWORK_COMPILER_WARNING(x)
43
# define ROBOTTESTINGFRAMEWORK_COMPILER_ERROR(x)
44
#endif
45
46
47
#include <
robottestingframework/Asserter.h
>
48
49
54
#define ROBOTTESTINGFRAMEWORK_ASSERT_FAIL(message) \
55
(::robottestingframework::Asserter::fail(::robottestingframework::TestMessage("asserts failure with exception", \
56
message, \
57
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
58
ROBOTTESTINGFRAMEWORK_SOURCELINE())))
59
66
#define ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_TRUE(condition, message) \
67
(::robottestingframework::Asserter::fail(!condition, \
68
::robottestingframework::TestMessage(std::string("asserts failure on (") + std::string(#condition) + ") with exception", \
69
message, \
70
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
71
ROBOTTESTINGFRAMEWORK_SOURCELINE())))
72
79
#define ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_FALSE(condition, message) \
80
(::robottestingframework::Asserter::fail(condition, \
81
::robottestingframework::TestMessage(std::string("asserts failure on (") + std::string(#condition) + ") with exception", \
82
message, \
83
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
84
ROBOTTESTINGFRAMEWORK_SOURCELINE())))
85
90
#define ROBOTTESTINGFRAMEWORK_ASSERT_ERROR(message) \
91
(::robottestingframework::Asserter::error(::robottestingframework::TestMessage("asserts error with exception", \
92
message, \
93
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
94
ROBOTTESTINGFRAMEWORK_SOURCELINE())))
95
102
#define ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_TRUE(condition, message) \
103
(::robottestingframework::Asserter::error(!condition, \
104
::robottestingframework::TestMessage(std::string("asserts error on (") + std::string(#condition) + ") with exception", \
105
message, \
106
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
107
ROBOTTESTINGFRAMEWORK_SOURCELINE())))
108
115
#define ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(condition, message) \
116
(::robottestingframework::Asserter::error(condition, \
117
::robottestingframework::TestMessage(std::string("asserts error on (") + std::string(#condition) + ") with exception", \
118
message, \
119
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
120
ROBOTTESTINGFRAMEWORK_SOURCELINE())))
121
131
#define ROBOTTESTINGFRAMEWORK_TEST_REPORT(message) \
132
(::robottestingframework::Asserter::report(::robottestingframework::TestMessage("reports", \
133
message, \
134
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
135
ROBOTTESTINGFRAMEWORK_SOURCELINE()), \
136
dynamic_cast<::robottestingframework::TestCase*>(this)))
137
149
#define ROBOTTESTINGFRAMEWORK_TEST_FAIL_IF_FALSE(condition, message) \
150
(::robottestingframework::Asserter::testFail(condition, \
151
::robottestingframework::TestMessage(std::string("checking (") + std::string(#condition) + ")", \
152
message, \
153
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
154
ROBOTTESTINGFRAMEWORK_SOURCELINE()), \
155
dynamic_cast<::robottestingframework::TestCase*>(this)))
156
168
#define ROBOTTESTINGFRAMEWORK_TEST_FAIL_IF_TRUE(condition, message) \
169
(::robottestingframework::Asserter::testFail(!condition, \
170
::robottestingframework::TestMessage(std::string("checking (") + std::string(#condition) + ")", \
171
message, \
172
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
173
ROBOTTESTINGFRAMEWORK_SOURCELINE()), \
174
dynamic_cast<::robottestingframework::TestCase*>(this)))
175
188
#define ROBOTTESTINGFRAMEWORK_TEST_CHECK(condition, message) \
189
(::robottestingframework::Asserter::testCheck(condition, \
190
::robottestingframework::TestMessage("checks", \
191
message, \
192
ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
193
ROBOTTESTINGFRAMEWORK_SOURCELINE()), \
194
dynamic_cast<::robottestingframework::TestCase*>(this)))
195
196
#endif // ROBOTTESTINGFRAMEWORK_TESTASSERT_H
Asserter.h
Generated on Tue Nov 3 2020 02:17:26 for RobotTestingFramework by
1.8.13