gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Removing fixme an log assert handler from assertion system
0 2 0
default
2 files changed with 18 insertions and 67 deletions:
↑ Collapse diff ↑
Ignore white space 4 line context
... ...
@@ -28,6 +28,7 @@
28 28
namespace lemon {
29 29

	
30
  inline void assert_fail_log(const char *file, int line, const char *function,
31
                              const char *message, const char *assertion)
30
  inline void assert_fail_abort(const char *file, int line,
31
                                const char *function, const char* message,
32
                                const char *assertion)
32 33
  {
33 34
    std::cerr << file << ":" << line << ": ";
... ...
@@ -38,11 +39,4 @@
38 39
      std::cerr << " (assertion '" << assertion << "' failed)";
39 40
    std::cerr << std::endl;
40
  }
41

	
42
  inline void assert_fail_abort(const char *file, int line,
43
                                const char *function, const char* message,
44
                                const char *assertion)
45
  {
46
    assert_fail_log(file, line, function, message, assertion);
47 41
    std::abort();
48 42
  }
... ...
@@ -64,15 +58,12 @@
64 58

	
65 59
#undef LEMON_ASSERT
66
#undef LEMON_FIXME
67 60
#undef LEMON_DEBUG
68 61

	
69
#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +               \
70
  (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
62
#if (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
71 63
  (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
72 64
#error "LEMON assertion system is not set properly"
73 65
#endif
74 66

	
75
#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +              \
76
     (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
67
#if ((defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
77 68
     (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||     \
78 69
     defined(LEMON_ENABLE_ASSERTS)) &&                  \
... ...
@@ -83,8 +74,5 @@
83 74

	
84 75

	
85
#if defined LEMON_ASSERT_LOG
86
#  undef LEMON_ASSERT_HANDLER
87
#  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_log
88
#elif defined LEMON_ASSERT_ABORT
76
#if defined LEMON_ASSERT_ABORT
89 77
#  undef LEMON_ASSERT_HANDLER
90 78
#  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort
... ...
@@ -121,10 +109,10 @@
121 109
/// \brief Macro for assertion with customizable message
122 110
///
123
/// Macro for assertion with customizable message.  \param exp An
124
/// expression that must be convertible to \c bool.  If it is \c
125
/// false, then an assertion is raised. The concrete behaviour depends
126
/// on the settings of the assertion system.  \param msg A <tt>const
127
/// char*</tt> parameter, which can be used to provide information
128
/// about the circumstances of the failed assertion.
111
/// Macro for assertion with customizable message.  
112
/// \param exp An expression that must be convertible to \c bool.  If it is \c
113
/// false, then an assertion is raised. The concrete behaviour depends on the
114
/// settings of the assertion system.
115
/// \param msg A <tt>const char*</tt> parameter, which can be used to provide
116
/// information about the circumstances of the failed assertion.
129 117
///
130 118
/// The assertions are enabled in the default behaviour.
... ...
@@ -140,15 +128,10 @@
140 128
/// The checking is also disabled when the standard macro \c NDEBUG is defined.
141 129
///
142
/// The LEMON assertion system has a wide range of customization
143
/// properties. As a default behaviour the failed assertion prints a
144
/// short log message to the standard error and aborts the execution.
130
/// As a default behaviour the failed assertion prints a short log message to
131
/// the standard error and aborts the execution.
145 132
///
146
/// The following modes can be used in the assertion system:
147
///
148
/// - \c LEMON_ASSERT_LOG The failed assertion prints a short log
149
///   message to the standard error and continues the execution.
150
/// - \c LEMON_ASSERT_ABORT This mode is similar to the \c
151
///   LEMON_ASSERT_LOG, but it aborts the program. It is the default
152
///   behaviour.
133
/// However, the following modes can be used in the assertion system:
134
/// - \c LEMON_ASSERT_ABORT The failed assertion prints a short log message to
135
///   the standard error and aborts the program. It is the default behaviour.
153 136
/// - \c LEMON_ASSERT_CUSTOM The user can define own assertion handler
154 137
///   function.
... ...
@@ -178,20 +161,4 @@
178 161
/// \ingroup exceptions
179 162
///
180
/// \brief Macro for mark not yet implemented features.
181
///
182
/// Macro for mark not yet implemented features and outstanding bugs.
183
/// It is close to be the shortcut of the following code:
184
/// \code
185
///   LEMON_ASSERT(false, msg);
186
/// \endcode
187
///
188
/// \see LEMON_ASSERT
189
#  define LEMON_FIXME(msg)                                              \
190
  (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
191
                        ::lemon::_assert_bits::cstringify(msg),         \
192
                        static_cast<const char*>(0)))
193

	
194
/// \ingroup exceptions
195
///
196 163
/// \brief Macro for internal assertions
197 164
///
... ...
@@ -225,5 +192,4 @@
225 192
#  ifndef LEMON_ASSERT_HANDLER
226 193
#    define LEMON_ASSERT(exp, msg)  (static_cast<void>(0))
227
#    define LEMON_FIXME(msg) (static_cast<void>(0))
228 194
#    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
229 195
#  else
... ...
@@ -234,9 +200,4 @@
234 200
                             ::lemon::_assert_bits::cstringify(msg),    \
235 201
                             #exp), 0)))
236
#    define LEMON_FIXME(msg)                                            \
237
       (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,   \
238
                             ::lemon::_assert_bits::cstringify(msg),    \
239
                             static_cast<const char*>(0)))
240

	
241 202
#    if LEMON_ENABLE_DEBUG
242 203
#      define LEMON_DEBUG(exp, msg)                                     \
Ignore white space 4 line context
... ...
@@ -48,12 +48,7 @@
48 48
}
49 49

	
50
void fixme_disable() {
51
  LEMON_FIXME("fixme_disable() is fixme!");
52
}
53

	
54 50
void check_assertion_disable() {
55 51
  no_assertion_text_disable();
56 52
  assertion_text_disable();
57
  fixme_disable();
58 53
}
59 54
#undef LEMON_DISABLE_ASSERTS
... ...
@@ -79,13 +74,8 @@
79 74
}
80 75

	
81
void fixme_custom() {
82
  LEMON_FIXME("fixme_custom() is fixme!");
83
}
84

	
85 76
void check_assertion_custom() {
86 77
  no_assertion_text_custom();
87 78
  assertion_text_custom();
88
  fixme_custom();
89
  check(cnt == 2, "The custom assert handler does not work");
79
  check(cnt == 1, "The custom assert handler does not work");
90 80
}
91 81

	
0 comments (0 inline)