1.1 --- a/test/error_test.cc Tue Apr 08 22:51:26 2008 +0200
1.2 +++ b/test/error_test.cc Sat Apr 12 20:38:51 2008 +0100
1.3 @@ -39,165 +39,21 @@
1.4 LEMON_ASSERT(true, "This is a fault message");
1.5 }
1.6
1.7 -void no_assertion_exception_disable() {
1.8 - LEMON_ASSERT(true, Exception());
1.9 -}
1.10 -
1.11 void assertion_text_disable() {
1.12 LEMON_ASSERT(false, "This is a fault message");
1.13 }
1.14
1.15 -void assertion_exception_disable() {
1.16 - LEMON_ASSERT(false, Exception());
1.17 -}
1.18 -
1.19 void fixme_disable() {
1.20 LEMON_FIXME("fixme_disable() is fixme!");
1.21 }
1.22
1.23 void check_assertion_disable() {
1.24 no_assertion_text_disable();
1.25 - no_assertion_exception_disable();
1.26 - assertion_exception_disable();
1.27 assertion_text_disable();
1.28 fixme_disable();
1.29 }
1.30 #undef LEMON_DISABLE_ASSERTS
1.31
1.32 -
1.33 -#define LEMON_ASSERT_ERROR
1.34 -#include <lemon/assert.h>
1.35 -
1.36 -void no_assertion_text_error() {
1.37 - LEMON_ASSERT(true, "This is a fault message");
1.38 -}
1.39 -
1.40 -void no_assertion_exception_error() {
1.41 - LEMON_ASSERT(true, Exception());
1.42 -}
1.43 -
1.44 -void assertion_text_error() {
1.45 - LEMON_ASSERT(false, "This is a fault message");
1.46 -}
1.47 -
1.48 -void assertion_exception_error() {
1.49 - LEMON_ASSERT(false, Exception());
1.50 -}
1.51 -
1.52 -void fixme_error() {
1.53 - LEMON_FIXME("fixme_error() is fixme!");
1.54 -}
1.55 -
1.56 -void check_assertion_error() {
1.57 - no_assertion_text_error();
1.58 - no_assertion_exception_error();
1.59 - try {
1.60 - assertion_exception_error();
1.61 - check(false, "Assertion error");
1.62 - } catch (const AssertionFailedError& e) {
1.63 - }
1.64 -
1.65 - try {
1.66 - assertion_text_error();
1.67 - check(false, "Assertion error");
1.68 - } catch (const AssertionFailedError& e) {
1.69 - }
1.70 -
1.71 - try {
1.72 - fixme_error();
1.73 - check(false, "Assertion error");
1.74 - } catch (const AssertionFailedError& e) {
1.75 - }
1.76 -}
1.77 -#undef LEMON_ASSERT_ERROR
1.78 -
1.79 -#define LEMON_ASSERT_EXCEPTION
1.80 -#include <lemon/assert.h>
1.81 -
1.82 -void no_assertion_text_exception() {
1.83 - LEMON_ASSERT(true, "This is a fault message");
1.84 -}
1.85 -
1.86 -void no_assertion_exception_exception() {
1.87 - LEMON_ASSERT(true, Exception());
1.88 -}
1.89 -
1.90 -void assertion_text_exception() {
1.91 - LEMON_ASSERT(false, "This is a fault message");
1.92 -}
1.93 -
1.94 -void assertion_exception_exception() {
1.95 - LEMON_ASSERT(false, Exception());
1.96 -}
1.97 -
1.98 -void fixme_exception() {
1.99 - LEMON_FIXME("fixme_exception() is fixme!");
1.100 -}
1.101 -
1.102 -void check_assertion_exception() {
1.103 - no_assertion_text_exception();
1.104 - no_assertion_exception_exception();
1.105 - try {
1.106 - assertion_exception_exception();
1.107 - check(false, "Assertion error");
1.108 - } catch (const Exception& e) {
1.109 - }
1.110 -
1.111 - try {
1.112 - assertion_text_exception();
1.113 - check(false, "Assertion error");
1.114 - } catch (const AssertionFailedError& e) {
1.115 - }
1.116 -
1.117 - try {
1.118 - assertion_text_exception();
1.119 - check(false, "Assertion error");
1.120 - } catch (const AssertionFailedError& e) {
1.121 - }
1.122 -
1.123 - try {
1.124 - fixme_exception();
1.125 - check(false, "Assertion error");
1.126 - } catch (const AssertionFailedError& e) {
1.127 - }
1.128 -}
1.129 -#undef LEMON_ASSERT_EXCEPTION
1.130 -
1.131 -#define LEMON_ASSERT_LOG
1.132 -
1.133 -#include <lemon/assert.h>
1.134 -
1.135 -void no_assertion_text_log() {
1.136 - LEMON_ASSERT(true, "This is a fault message");
1.137 -}
1.138 -
1.139 -void no_assertion_exception_log() {
1.140 - LEMON_ASSERT(true, Exception());
1.141 -}
1.142 -
1.143 -void assertion_text_log() {
1.144 - LEMON_ASSERT(false, "This is a fault message");
1.145 -}
1.146 -
1.147 -void assertion_exception_log() {
1.148 - LEMON_ASSERT(false, Exception());
1.149 -}
1.150 -
1.151 -void fixme_log() {
1.152 - LEMON_FIXME("fixme_log() is fixme!");
1.153 -}
1.154 -
1.155 -void check_assertion_log() {
1.156 - no_assertion_text_log();
1.157 - no_assertion_exception_log();
1.158 - std::cerr << "The next 3 failure messages are expected: " << std::endl;
1.159 - assertion_exception_log();
1.160 - assertion_text_log();
1.161 - fixme_log();
1.162 - std::cerr << "End of expected error messages" << std::endl;
1.163 -}
1.164 -#undef LEMON_ASSERT_LOG
1.165 -
1.166 #define LEMON_ASSERT_CUSTOM
1.167
1.168 static int cnt = 0;
1.169 @@ -206,17 +62,6 @@
1.170 ++cnt;
1.171 }
1.172
1.173 -void my_assert_handler(const char*, int, const char*,
1.174 - const std::exception&, const char*) {
1.175 - ++cnt;
1.176 -}
1.177 -
1.178 -void my_assert_handler(const char*, int, const char*,
1.179 - const std::string&, const char*) {
1.180 - ++cnt;
1.181 -}
1.182 -
1.183 -
1.184 #define LEMON_CUSTOM_ASSERT_HANDLER my_assert_handler
1.185 #include <lemon/assert.h>
1.186
1.187 @@ -224,29 +69,19 @@
1.188 LEMON_ASSERT(true, "This is a fault message");
1.189 }
1.190
1.191 -void no_assertion_exception_custom() {
1.192 - LEMON_ASSERT(true, Exception());
1.193 -}
1.194 -
1.195 void assertion_text_custom() {
1.196 LEMON_ASSERT(false, "This is a fault message");
1.197 }
1.198
1.199 -void assertion_exception_custom() {
1.200 - LEMON_ASSERT(false, Exception());
1.201 -}
1.202 -
1.203 void fixme_custom() {
1.204 LEMON_FIXME("fixme_custom() is fixme!");
1.205 }
1.206
1.207 void check_assertion_custom() {
1.208 no_assertion_text_custom();
1.209 - no_assertion_exception_custom();
1.210 - assertion_exception_custom();
1.211 assertion_text_custom();
1.212 fixme_custom();
1.213 - check(cnt == 3, "The custom assert handler does not work");
1.214 + check(cnt == 2, "The custom assert handler does not work");
1.215 }
1.216
1.217 #undef LEMON_ASSERT_CUSTOM
1.218 @@ -254,9 +89,6 @@
1.219
1.220 int main() {
1.221 check_assertion_disable();
1.222 - check_assertion_error();
1.223 - check_assertion_exception();
1.224 - check_assertion_log();
1.225 check_assertion_custom();
1.226
1.227 return 0;