COIN-OR::LEMON - Graph Library

source: lemon/test/error_test.cc @ 171:02f4d5d9bfd7

Last change on this file since 171:02f4d5d9bfd7 was 171:02f4d5d9bfd7, checked in by Peter Kovacs <kpeter@…>, 11 years ago

Improve and redesign test programs + unify their output (ticket #25)

  • Move graph related utilities form test_tools.h to graph_test.h.
  • Move the contents of graph_utils_test.h to graph_utils_test.cc.
  • Rename map_test.h -> graph_maps_test.h.
  • Rename digraph_test.h -> graph_test.h.
  • Many improvements in the following files:
    • digraph_test.cc
    • graph_test.cc
    • graph_test.h
    • graph_maps_test.h
    • graph_utils_test.cc
    • bfs_test.cc
    • dfs_test.cc
    • counter_test.cc
  • Test programs print messages only if it really seems necessary.
  • Remove \file commands form .cc test files.
File size: 2.0 KB
Line 
1/* -*- C++ -*-
2 *
3 * This file is a part of LEMON, a generic C++ optimization library
4 *
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 *
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.
12 *
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
15 * purpose.
16 *
17 */
18
19#include <iostream>
20
21#include <lemon/error.h>
22#include "test_tools.h"
23
24using namespace lemon;
25
26#ifdef LEMON_ENABLE_ASSERTS
27#undef LEMON_ENABLE_ASSERTS
28#endif
29
30#ifdef LEMON_DISABLE_ASSERTS
31#undef LEMON_DISABLE_ASSERTS
32#endif
33
34//checking disabled asserts
35#define LEMON_DISABLE_ASSERTS
36#include <lemon/assert.h>
37
38void no_assertion_text_disable() {
39  LEMON_ASSERT(true, "This is a fault message");
40}
41
42void assertion_text_disable() {
43  LEMON_ASSERT(false, "This is a fault message");
44}
45
46void fixme_disable() {
47  LEMON_FIXME("fixme_disable() is fixme!");
48}
49
50void check_assertion_disable() {
51  no_assertion_text_disable();
52  assertion_text_disable();
53  fixme_disable();
54}
55#undef LEMON_DISABLE_ASSERTS
56
57//checking custom assert handler
58#define LEMON_ASSERT_CUSTOM
59
60static int cnt = 0;
61void my_assert_handler(const char*, int, const char*,
62                       const char*, const char*) {
63  ++cnt;
64}
65
66#define LEMON_CUSTOM_ASSERT_HANDLER my_assert_handler
67#include <lemon/assert.h>
68
69void no_assertion_text_custom() {
70  LEMON_ASSERT(true, "This is a fault message");
71}
72
73void assertion_text_custom() {
74  LEMON_ASSERT(false, "This is a fault message");
75}
76
77void fixme_custom() {
78  LEMON_FIXME("fixme_custom() is fixme!");
79}
80
81void check_assertion_custom() {
82  no_assertion_text_custom();
83  assertion_text_custom();
84  fixme_custom();
85  check(cnt == 2, "The custom assert handler does not work");
86}
87
88#undef LEMON_ASSERT_CUSTOM
89
90
91int main() {
92  check_assertion_disable();
93  check_assertion_custom();
94
95  return 0;
96}
Note: See TracBrowser for help on using the repository browser.