1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
21 #include <lemon/error.h>
22 #include "test_tools.h"
24 using namespace lemon;
26 #ifdef LEMON_ENABLE_ASSERTS
27 #undef LEMON_ENABLE_ASSERTS
30 #ifdef LEMON_DISABLE_ASSERTS
31 #undef LEMON_DISABLE_ASSERTS
38 //checking disabled asserts
39 #define LEMON_DISABLE_ASSERTS
40 #include <lemon/assert.h>
42 void no_assertion_text_disable() {
43 LEMON_ASSERT(true, "This is a fault message");
46 void assertion_text_disable() {
47 LEMON_ASSERT(false, "This is a fault message");
50 void fixme_disable() {
51 LEMON_FIXME("fixme_disable() is fixme!");
54 void check_assertion_disable() {
55 no_assertion_text_disable();
56 assertion_text_disable();
59 #undef LEMON_DISABLE_ASSERTS
61 //checking custom assert handler
62 #define LEMON_ASSERT_CUSTOM
65 void my_assert_handler(const char*, int, const char*,
66 const char*, const char*) {
70 #define LEMON_CUSTOM_ASSERT_HANDLER my_assert_handler
71 #include <lemon/assert.h>
73 void no_assertion_text_custom() {
74 LEMON_ASSERT(true, "This is a fault message");
77 void assertion_text_custom() {
78 LEMON_ASSERT(false, "This is a fault message");
82 LEMON_FIXME("fixme_custom() is fixme!");
85 void check_assertion_custom() {
86 no_assertion_text_custom();
87 assertion_text_custom();
89 check(cnt == 2, "The custom assert handler does not work");
92 #undef LEMON_ASSERT_CUSTOM
96 check_assertion_disable();
97 check_assertion_custom();