22 #ifndef ROBOTTESTINGFRAMEWORK_TESTASSERT_H
23 #define ROBOTTESTINGFRAMEWORK_TESTASSERT_H
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__)
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)
41 # define ROBOTTESTINGFRAMEWORK_COMPILER_MESSAGE(x)
42 # define ROBOTTESTINGFRAMEWORK_COMPILER_WARNING(x)
43 # define ROBOTTESTINGFRAMEWORK_COMPILER_ERROR(x)
54 #define ROBOTTESTINGFRAMEWORK_ASSERT_FAIL(message) \
55 (::robottestingframework::Asserter::fail(::robottestingframework::TestMessage("asserts failure with exception", \
57 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
58 ROBOTTESTINGFRAMEWORK_SOURCELINE())))
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", \
70 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
71 ROBOTTESTINGFRAMEWORK_SOURCELINE())))
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", \
83 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
84 ROBOTTESTINGFRAMEWORK_SOURCELINE())))
90 #define ROBOTTESTINGFRAMEWORK_ASSERT_ERROR(message) \
91 (::robottestingframework::Asserter::error(::robottestingframework::TestMessage("asserts error with exception", \
93 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
94 ROBOTTESTINGFRAMEWORK_SOURCELINE())))
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", \
106 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
107 ROBOTTESTINGFRAMEWORK_SOURCELINE())))
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", \
119 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
120 ROBOTTESTINGFRAMEWORK_SOURCELINE())))
131 #define ROBOTTESTINGFRAMEWORK_TEST_REPORT(message) \
132 (::robottestingframework::Asserter::report(::robottestingframework::TestMessage("reports", \
134 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
135 ROBOTTESTINGFRAMEWORK_SOURCELINE()), \
136 dynamic_cast<::robottestingframework::TestCase*>(this)))
149 #define ROBOTTESTINGFRAMEWORK_TEST_FAIL_IF_FALSE(condition, message) \
150 (::robottestingframework::Asserter::testFail(condition, \
151 ::robottestingframework::TestMessage(std::string("checking (") + std::string(#condition) + ")", \
153 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
154 ROBOTTESTINGFRAMEWORK_SOURCELINE()), \
155 dynamic_cast<::robottestingframework::TestCase*>(this)))
168 #define ROBOTTESTINGFRAMEWORK_TEST_FAIL_IF_TRUE(condition, message) \
169 (::robottestingframework::Asserter::testFail(!condition, \
170 ::robottestingframework::TestMessage(std::string("checking (") + std::string(#condition) + ")", \
172 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
173 ROBOTTESTINGFRAMEWORK_SOURCELINE()), \
174 dynamic_cast<::robottestingframework::TestCase*>(this)))
188 #define ROBOTTESTINGFRAMEWORK_TEST_CHECK(condition, message) \
189 (::robottestingframework::Asserter::testCheck(condition, \
190 ::robottestingframework::TestMessage("checks", \
192 ROBOTTESTINGFRAMEWORK_SOURCEFILE(), \
193 ROBOTTESTINGFRAMEWORK_SOURCELINE()), \
194 dynamic_cast<::robottestingframework::TestCase*>(this)))