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