test/error_test.cc
author hegyi
Thu, 05 Jan 2006 12:30:09 +0000
changeset 1878 409a31271efd
parent 1435 8e85e6bbefdf
child 1956 a055123339d5
permissions -rw-r--r--
Several changes. \n If new map is added to mapstorage it emits signal with the name of the new map. This was important, because from now on not only tha mapwin should be updated. \n Furthermore algobox gets a pointer to mapstorage instead of only the mapnames from it. This is important because without it it would be complicated to pass all of the required maps to algobox.
     1 /* -*- C++ -*-
     2  * test/error_test.cc - Part of LEMON, a generic C++ optimization library
     3  *
     4  * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     5  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     6  *
     7  * Permission to use, modify and distribute this software is granted
     8  * provided that this copyright notice appears in all copies. For
     9  * precise terms see the accompanying LICENSE file.
    10  *
    11  * This software is provided "AS IS" with no warranty of any kind,
    12  * express or implied, and with no claim as to its suitability for any
    13  * purpose.
    14  *
    15  */
    16 
    17 #include <iostream>
    18 
    19 #include <lemon/error.h>
    20 #include "test_tools.h"
    21 using namespace lemon;
    22 using std::cout;
    23 using std::endl;
    24 
    25 void faulty_fn() {
    26   fault("This is a fault message");
    27 }
    28 
    29 void exception_fn() {
    30   throw Exception("This is a fn throwing excpt with some args: ") 
    31     << 5 << ", " << 18;
    32 }
    33 
    34 void unfinished_fn() {
    35   FIXME("unfinished_fn() is unfinished!");
    36 }
    37 
    38 
    39 int main() {
    40   try {
    41     faulty_fn();
    42     check(false, "A faulty function did not fail.");
    43   }
    44   catch(const Exception &e) {
    45     cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    46   }
    47 
    48   try {
    49     exception_fn();
    50     check(false, "The function did not throw Exception.");
    51   }
    52   catch(const Exception &e) {
    53     cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    54   }
    55 
    56   try {
    57     unfinished_fn();
    58     check(false, "FIXME macro does not work.");
    59   }
    60   catch(const Exception &e) {
    61     cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    62   }
    63 
    64   return 0;
    65 }