COIN-OR::LEMON - Graph Library

Ticket #17: 7abfb55f1ecc.patch

File 7abfb55f1ecc.patch, 7.2 KB (added by Balazs Dezso, 11 years ago)

removing fixme and log

  • lemon/assert.h

    # HG changeset patch
    # User "Balazs Dezso <deba@inf.elte.hu>"
    # Date 1222073761 -7200
    # Node ID 7abfb55f1ecc813ea33ff03ec3f5e909d1e738b2
    # Parent  b4784a66a8e6c7069d9a0af4250d0055e435be75
    Removing fixme an log assert handler from assertion system
    
    diff -r b4784a66a8e6 -r 7abfb55f1ecc lemon/assert.h
    a b  
    2727
    2828namespace lemon {
    2929
    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)
    3233  {
    3334    std::cerr << file << ":" << line << ": ";
    3435    if (function)
    namespace lemon { 
    3738    if (assertion)
    3839      std::cerr << " (assertion '" << assertion << "' failed)";
    3940    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);
    4741    std::abort();
    4842  }
    4943
    namespace lemon { 
    6357#endif // LEMON_ASSERT_H
    6458
    6559#undef LEMON_ASSERT
    66 #undef LEMON_FIXME
    6760#undef LEMON_DEBUG
    6861
    69 #if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +               \
    70   (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
     62#if (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
    7163  (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
    7264#error "LEMON assertion system is not set properly"
    7365#endif
    7466
    75 #if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +              \
    76      (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
     67#if ((defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
    7768     (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||     \
    7869     defined(LEMON_ENABLE_ASSERTS)) &&                  \
    7970  (defined(LEMON_DISABLE_ASSERTS) ||                    \
    namespace lemon { 
    8273#endif
    8374
    8475
    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
    8977#  undef LEMON_ASSERT_HANDLER
    9078#  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort
    9179#elif defined LEMON_ASSERT_CUSTOM
    namespace lemon { 
    120108///
    121109/// \brief Macro for assertion with customizable message
    122110///
    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.
    129117///
    130118/// The assertions are enabled in the default behaviour.
    131119/// You can disable them with the following code:
    namespace lemon { 
    139127/// \endcode
    140128/// The checking is also disabled when the standard macro \c NDEBUG is defined.
    141129///
    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.
    145 ///
    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.
     130/// As a default behaviour the failed assertion prints a short log message to
     131/// the standard error and aborts the execution.
     132///
     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.
    153136/// - \c LEMON_ASSERT_CUSTOM The user can define own assertion handler
    154137///   function.
    155138///   \code
    namespace lemon { 
    177160
    178161/// \ingroup exceptions
    179162///
    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 ///
    196163/// \brief Macro for internal assertions
    197164///
    198165/// Macro for internal assertions, it is used in the library to check
    namespace lemon { 
    224191
    225192#  ifndef LEMON_ASSERT_HANDLER
    226193#    define LEMON_ASSERT(exp, msg)  (static_cast<void>(0))
    227 #    define LEMON_FIXME(msg) (static_cast<void>(0))
    228194#    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
    229195#  else
    230196#    define LEMON_ASSERT(exp, msg)                                      \
    namespace lemon { 
    233199                             LEMON_FUNCTION_NAME,                       \
    234200                             ::lemon::_assert_bits::cstringify(msg),    \
    235201                             #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 
    241202#    if LEMON_ENABLE_DEBUG
    242203#      define LEMON_DEBUG(exp, msg)                                     \
    243204         (static_cast<void> (!!(exp) ? 0 : (                            \
  • test/error_test.cc

    diff -r b4784a66a8e6 -r 7abfb55f1ecc test/error_test.cc
    a b void assertion_text_disable() { 
    4747  LEMON_ASSERT(false, "This is a fault message");
    4848}
    4949
    50 void fixme_disable() {
    51   LEMON_FIXME("fixme_disable() is fixme!");
    52 }
    53 
    5450void check_assertion_disable() {
    5551  no_assertion_text_disable();
    5652  assertion_text_disable();
    57   fixme_disable();
    5853}
    5954#undef LEMON_DISABLE_ASSERTS
    6055
    void assertion_text_custom() { 
    7873  LEMON_ASSERT(false, "This is a fault message");
    7974}
    8075
    81 void fixme_custom() {
    82   LEMON_FIXME("fixme_custom() is fixme!");
    83 }
    84 
    8576void check_assertion_custom() {
    8677  no_assertion_text_custom();
    8778  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");
    9080}
    9181
    9282#undef LEMON_ASSERT_CUSTOM