src/test/error_test.cc
author jacint
Wed, 05 May 2004 17:51:56 +0000
changeset 537 acd69f60b9c7
child 542 69bde1d90c04
permissions -rw-r--r--
Contains Edmonds' matching algorithm in a plain and in a heuristical form.
     1 #include <iostream>
     2 
     3 #include <error.h>
     4 
     5 using namespace hugo;
     6 using std::cout;
     7 using std::endl;
     8 
     9 void faulty_fn() {
    10   fault("This is a fault message");
    11 }
    12 
    13 void exception_fn() {
    14   throw Exception("This is a fn throwing excpt with some args: ") 
    15     << 5 << ", " << 18;
    16 }
    17 
    18 void unfinished_fn() {
    19   FIXME("unfinished_fn() is unfinished!");
    20 }
    21 
    22 
    23 int main() {
    24   bool no_errors = false;
    25 
    26   try {
    27     cout << "Trying a faulty function\n";
    28     faulty_fn();
    29     no_errors = true;
    30     cout << "FAILED!\n";
    31   }
    32   catch(const Exception &e) {
    33     cout << "E: " << e.what() << endl;
    34   }
    35 
    36   try {
    37     cout << "Trying a function throwing Exception\n";
    38     exception_fn();
    39     no_errors = true;
    40     cout << "FAILED!\n";
    41   }
    42   catch(const Exception &e) {
    43     cout << "E: " << e.what() << endl;
    44   }
    45 
    46   try {
    47     cout << "Trying a function using FIXME\n";
    48     unfinished_fn();
    49     no_errors = true;
    50     cout << "FAILED!\n";
    51   }
    52   catch(const Exception &e) {
    53     cout << "E: " << e.what() << endl;
    54   }
    55 
    56   return no_errors ? 1 : 0;
    57 }