src/test/error_test.cc
author alpar
Mon, 19 Jul 2004 13:31:47 +0000
changeset 708 429dfcbbf47d
parent 489 afbdf8a3a633
child 727 aada518af30f
permissions -rw-r--r--
A new benchmark (hcube)
and other minor changes
     1 #include <iostream>
     2 
     3 #include <hugo/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 }