src/test/error_test.cc
author marci
Wed, 29 Sep 2004 19:02:26 +0000
changeset 923 acbef5dd0e65
parent 906 17f31d280385
child 1164 80bb73097736
permissions -rw-r--r--
more docs
alpar@906
     1
/* -*- C++ -*-
alpar@921
     2
 * src/test/error_test.cc - Part of LEMON, a generic C++ optimization library
alpar@906
     3
 *
alpar@906
     4
 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@906
     5
 * (Egervary Combinatorial Optimization Research Group, EGRES).
alpar@906
     6
 *
alpar@906
     7
 * Permission to use, modify and distribute this software is granted
alpar@906
     8
 * provided that this copyright notice appears in all copies. For
alpar@906
     9
 * precise terms see the accompanying LICENSE file.
alpar@906
    10
 *
alpar@906
    11
 * This software is provided "AS IS" with no warranty of any kind,
alpar@906
    12
 * express or implied, and with no claim as to its suitability for any
alpar@906
    13
 * purpose.
alpar@906
    14
 *
alpar@906
    15
 */
alpar@906
    16
klao@489
    17
#include <iostream>
klao@489
    18
alpar@921
    19
#include <lemon/error.h>
alpar@727
    20
#include "test_tools.h"
alpar@921
    21
using namespace lemon;
klao@489
    22
using std::cout;
klao@489
    23
using std::endl;
klao@489
    24
klao@489
    25
void faulty_fn() {
klao@489
    26
  fault("This is a fault message");
klao@489
    27
}
klao@489
    28
klao@489
    29
void exception_fn() {
klao@489
    30
  throw Exception("This is a fn throwing excpt with some args: ") 
klao@489
    31
    << 5 << ", " << 18;
klao@489
    32
}
klao@489
    33
klao@489
    34
void unfinished_fn() {
klao@489
    35
  FIXME("unfinished_fn() is unfinished!");
klao@489
    36
}
klao@489
    37
klao@489
    38
klao@489
    39
int main() {
klao@489
    40
  try {
klao@489
    41
    faulty_fn();
alpar@727
    42
    check(false, "A faulty function did not fail.");
klao@489
    43
  }
klao@489
    44
  catch(const Exception &e) {
alpar@727
    45
    cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
klao@489
    46
  }
klao@489
    47
klao@489
    48
  try {
klao@489
    49
    exception_fn();
alpar@727
    50
    check(false, "The function did not throw Exception.");
klao@489
    51
  }
klao@489
    52
  catch(const Exception &e) {
alpar@727
    53
    cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
klao@489
    54
  }
klao@489
    55
klao@489
    56
  try {
klao@489
    57
    unfinished_fn();
alpar@727
    58
    check(false, "FIXME macro does not work.");
klao@489
    59
  }
klao@489
    60
  catch(const Exception &e) {
alpar@727
    61
    cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
klao@489
    62
  }
klao@489
    63
alpar@727
    64
  return 0;
klao@489
    65
}