test/error_test.cc
author Peter Kovacs <kpeter@inf.elte.hu>
Fri, 17 Apr 2009 18:04:36 +0200
changeset 609 e6927fe719e6
parent 277 7abfb55f1ecc
permissions -rw-r--r--
Support >= and <= constraints in NetworkSimplex (#219, #234)

By default the same inequality constraints are supported as by
Circulation (the GEQ form), but the LEQ form can also be selected
using the problemType() function.

The documentation of the min. cost flow module is reworked and
extended with important notes and explanations about the different
variants of the problem and about the dual solution and optimality
conditions.
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     5  * Copyright (C) 2003-2009
     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 
    24 using 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 #ifdef NDEBUG
    35 #undef NDEBUG
    36 #endif
    37 
    38 //checking disabled asserts
    39 #define LEMON_DISABLE_ASSERTS
    40 #include <lemon/assert.h>
    41 
    42 void no_assertion_text_disable() {
    43   LEMON_ASSERT(true, "This is a fault message");
    44 }
    45 
    46 void assertion_text_disable() {
    47   LEMON_ASSERT(false, "This is a fault message");
    48 }
    49 
    50 void check_assertion_disable() {
    51   no_assertion_text_disable();
    52   assertion_text_disable();
    53 }
    54 #undef LEMON_DISABLE_ASSERTS
    55 
    56 //checking custom assert handler
    57 #define LEMON_ASSERT_CUSTOM
    58 
    59 static int cnt = 0;
    60 void my_assert_handler(const char*, int, const char*,
    61                        const char*, const char*) {
    62   ++cnt;
    63 }
    64 
    65 #define LEMON_CUSTOM_ASSERT_HANDLER my_assert_handler
    66 #include <lemon/assert.h>
    67 
    68 void no_assertion_text_custom() {
    69   LEMON_ASSERT(true, "This is a fault message");
    70 }
    71 
    72 void assertion_text_custom() {
    73   LEMON_ASSERT(false, "This is a fault message");
    74 }
    75 
    76 void check_assertion_custom() {
    77   no_assertion_text_custom();
    78   assertion_text_custom();
    79   check(cnt == 1, "The custom assert handler does not work");
    80 }
    81 
    82 #undef LEMON_ASSERT_CUSTOM
    83 
    84 
    85 int main() {
    86   check_assertion_disable();
    87   check_assertion_custom();
    88 
    89   return 0;
    90 }