src/test/error_test.cc
author alpar
Mon, 30 Aug 2004 12:01:47 +0000
changeset 774 4297098d9677
parent 542 69bde1d90c04
child 906 17f31d280385
permissions -rw-r--r--
Merge back the whole branches/hugo++ to trunk.
     1 #include <iostream>
     2 
     3 #include <hugo/error.h>
     4 #include "test_tools.h"
     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   try {
    25     faulty_fn();
    26     check(false, "A faulty function did not fail.");
    27   }
    28   catch(const Exception &e) {
    29     cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    30   }
    31 
    32   try {
    33     exception_fn();
    34     check(false, "The function did not throw Exception.");
    35   }
    36   catch(const Exception &e) {
    37     cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    38   }
    39 
    40   try {
    41     unfinished_fn();
    42     check(false, "FIXME macro does not work.");
    43   }
    44   catch(const Exception &e) {
    45     cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    46   }
    47 
    48   return 0;
    49 }