src/test/error_test.cc
changeset 536 c050de070935
child 542 69bde1d90c04
equal deleted inserted replaced
-1:000000000000 0:c51fb9bf917b
       
     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 }