Removing fixme an log assert handler from assertion system
author"Balazs Dezso <deba@inf.elte.hu>"
Mon, 22 Sep 2008 10:56:01 +0200
changeset 2777abfb55f1ecc
parent 276 b4784a66a8e6
child 279 6307bbbf285b
child 280 e7f8647ce760
Removing fixme an log assert handler from assertion system
lemon/assert.h
test/error_test.cc
     1.1 --- a/lemon/assert.h	Mon Sep 22 08:37:23 2008 +0100
     1.2 +++ b/lemon/assert.h	Mon Sep 22 10:56:01 2008 +0200
     1.3 @@ -27,8 +27,9 @@
     1.4  
     1.5  namespace lemon {
     1.6  
     1.7 -  inline void assert_fail_log(const char *file, int line, const char *function,
     1.8 -                              const char *message, const char *assertion)
     1.9 +  inline void assert_fail_abort(const char *file, int line,
    1.10 +                                const char *function, const char* message,
    1.11 +                                const char *assertion)
    1.12    {
    1.13      std::cerr << file << ":" << line << ": ";
    1.14      if (function)
    1.15 @@ -37,13 +38,6 @@
    1.16      if (assertion)
    1.17        std::cerr << " (assertion '" << assertion << "' failed)";
    1.18      std::cerr << std::endl;
    1.19 -  }
    1.20 -
    1.21 -  inline void assert_fail_abort(const char *file, int line,
    1.22 -                                const char *function, const char* message,
    1.23 -                                const char *assertion)
    1.24 -  {
    1.25 -    assert_fail_log(file, line, function, message, assertion);
    1.26      std::abort();
    1.27    }
    1.28  
    1.29 @@ -63,17 +57,14 @@
    1.30  #endif // LEMON_ASSERT_H
    1.31  
    1.32  #undef LEMON_ASSERT
    1.33 -#undef LEMON_FIXME
    1.34  #undef LEMON_DEBUG
    1.35  
    1.36 -#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +               \
    1.37 -  (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
    1.38 +#if (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
    1.39    (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
    1.40  #error "LEMON assertion system is not set properly"
    1.41  #endif
    1.42  
    1.43 -#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +              \
    1.44 -     (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
    1.45 +#if ((defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
    1.46       (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||     \
    1.47       defined(LEMON_ENABLE_ASSERTS)) &&                  \
    1.48    (defined(LEMON_DISABLE_ASSERTS) ||                    \
    1.49 @@ -82,10 +73,7 @@
    1.50  #endif
    1.51  
    1.52  
    1.53 -#if defined LEMON_ASSERT_LOG
    1.54 -#  undef LEMON_ASSERT_HANDLER
    1.55 -#  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_log
    1.56 -#elif defined LEMON_ASSERT_ABORT
    1.57 +#if defined LEMON_ASSERT_ABORT
    1.58  #  undef LEMON_ASSERT_HANDLER
    1.59  #  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort
    1.60  #elif defined LEMON_ASSERT_CUSTOM
    1.61 @@ -120,12 +108,12 @@
    1.62  ///
    1.63  /// \brief Macro for assertion with customizable message
    1.64  ///
    1.65 -/// Macro for assertion with customizable message.  \param exp An
    1.66 -/// expression that must be convertible to \c bool.  If it is \c
    1.67 -/// false, then an assertion is raised. The concrete behaviour depends
    1.68 -/// on the settings of the assertion system.  \param msg A <tt>const
    1.69 -/// char*</tt> parameter, which can be used to provide information
    1.70 -/// about the circumstances of the failed assertion.
    1.71 +/// Macro for assertion with customizable message.  
    1.72 +/// \param exp An expression that must be convertible to \c bool.  If it is \c
    1.73 +/// false, then an assertion is raised. The concrete behaviour depends on the
    1.74 +/// settings of the assertion system.
    1.75 +/// \param msg A <tt>const char*</tt> parameter, which can be used to provide
    1.76 +/// information about the circumstances of the failed assertion.
    1.77  ///
    1.78  /// The assertions are enabled in the default behaviour.
    1.79  /// You can disable them with the following code:
    1.80 @@ -139,17 +127,12 @@
    1.81  /// \endcode
    1.82  /// The checking is also disabled when the standard macro \c NDEBUG is defined.
    1.83  ///
    1.84 -/// The LEMON assertion system has a wide range of customization
    1.85 -/// properties. As a default behaviour the failed assertion prints a
    1.86 -/// short log message to the standard error and aborts the execution.
    1.87 +/// As a default behaviour the failed assertion prints a short log message to
    1.88 +/// the standard error and aborts the execution.
    1.89  ///
    1.90 -/// The following modes can be used in the assertion system:
    1.91 -///
    1.92 -/// - \c LEMON_ASSERT_LOG The failed assertion prints a short log
    1.93 -///   message to the standard error and continues the execution.
    1.94 -/// - \c LEMON_ASSERT_ABORT This mode is similar to the \c
    1.95 -///   LEMON_ASSERT_LOG, but it aborts the program. It is the default
    1.96 -///   behaviour.
    1.97 +/// However, the following modes can be used in the assertion system:
    1.98 +/// - \c LEMON_ASSERT_ABORT The failed assertion prints a short log message to
    1.99 +///   the standard error and aborts the program. It is the default behaviour.
   1.100  /// - \c LEMON_ASSERT_CUSTOM The user can define own assertion handler
   1.101  ///   function.
   1.102  ///   \code
   1.103 @@ -177,22 +160,6 @@
   1.104  
   1.105  /// \ingroup exceptions
   1.106  ///
   1.107 -/// \brief Macro for mark not yet implemented features.
   1.108 -///
   1.109 -/// Macro for mark not yet implemented features and outstanding bugs.
   1.110 -/// It is close to be the shortcut of the following code:
   1.111 -/// \code
   1.112 -///   LEMON_ASSERT(false, msg);
   1.113 -/// \endcode
   1.114 -///
   1.115 -/// \see LEMON_ASSERT
   1.116 -#  define LEMON_FIXME(msg)                                              \
   1.117 -  (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
   1.118 -                        ::lemon::_assert_bits::cstringify(msg),         \
   1.119 -                        static_cast<const char*>(0)))
   1.120 -
   1.121 -/// \ingroup exceptions
   1.122 -///
   1.123  /// \brief Macro for internal assertions
   1.124  ///
   1.125  /// Macro for internal assertions, it is used in the library to check
   1.126 @@ -224,7 +191,6 @@
   1.127  
   1.128  #  ifndef LEMON_ASSERT_HANDLER
   1.129  #    define LEMON_ASSERT(exp, msg)  (static_cast<void>(0))
   1.130 -#    define LEMON_FIXME(msg) (static_cast<void>(0))
   1.131  #    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
   1.132  #  else
   1.133  #    define LEMON_ASSERT(exp, msg)                                      \
   1.134 @@ -233,11 +199,6 @@
   1.135                               LEMON_FUNCTION_NAME,                       \
   1.136                               ::lemon::_assert_bits::cstringify(msg),    \
   1.137                               #exp), 0)))
   1.138 -#    define LEMON_FIXME(msg)                                            \
   1.139 -       (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,   \
   1.140 -                             ::lemon::_assert_bits::cstringify(msg),    \
   1.141 -                             static_cast<const char*>(0)))
   1.142 -
   1.143  #    if LEMON_ENABLE_DEBUG
   1.144  #      define LEMON_DEBUG(exp, msg)                                     \
   1.145           (static_cast<void> (!!(exp) ? 0 : (                            \
     2.1 --- a/test/error_test.cc	Mon Sep 22 08:37:23 2008 +0100
     2.2 +++ b/test/error_test.cc	Mon Sep 22 10:56:01 2008 +0200
     2.3 @@ -47,14 +47,9 @@
     2.4    LEMON_ASSERT(false, "This is a fault message");
     2.5  }
     2.6  
     2.7 -void fixme_disable() {
     2.8 -  LEMON_FIXME("fixme_disable() is fixme!");
     2.9 -}
    2.10 -
    2.11  void check_assertion_disable() {
    2.12    no_assertion_text_disable();
    2.13    assertion_text_disable();
    2.14 -  fixme_disable();
    2.15  }
    2.16  #undef LEMON_DISABLE_ASSERTS
    2.17  
    2.18 @@ -78,15 +73,10 @@
    2.19    LEMON_ASSERT(false, "This is a fault message");
    2.20  }
    2.21  
    2.22 -void fixme_custom() {
    2.23 -  LEMON_FIXME("fixme_custom() is fixme!");
    2.24 -}
    2.25 -
    2.26  void check_assertion_custom() {
    2.27    no_assertion_text_custom();
    2.28    assertion_text_custom();
    2.29 -  fixme_custom();
    2.30 -  check(cnt == 2, "The custom assert handler does not work");
    2.31 +  check(cnt == 1, "The custom assert handler does not work");
    2.32  }
    2.33  
    2.34  #undef LEMON_ASSERT_CUSTOM