src/work/klao/error_test.cc
changeset 1101 9286569c3749
child 1120 5d8d64bde9c5
equal deleted inserted replaced
-1:000000000000 0:45896e9164a2
       
     1 #include <iostream>
       
     2 #include <string>
       
     3 
       
     4 #define LEMON_ASSERT_ABORT 0
       
     5 #include <error.h>
       
     6 
       
     7 using namespace std;
       
     8 
       
     9 void parse_line() {
       
    10   throw lemon::DataFormatError("Syntax error");
       
    11 }
       
    12 
       
    13 void parse_file(string fn) {
       
    14   try {
       
    15     parse_line();
       
    16   }
       
    17   catch(lemon::DataFormatError &e) {
       
    18     e.set_file(fn);
       
    19     e.set_line(5);
       
    20     throw;
       
    21   }
       
    22 }
       
    23 
       
    24 void fail_assert();
       
    25 
       
    26 int main() {
       
    27   try {
       
    28     parse_file("input.txt");
       
    29   }
       
    30   catch(exception &e) {
       
    31     cerr << "Exception caught: " << endl;
       
    32     cerr << e.what() << endl;
       
    33   }
       
    34 
       
    35   try {
       
    36     fail_assert();
       
    37   }
       
    38   catch(exception &e) {
       
    39     cerr << "Exception caught: " << endl;
       
    40     cerr << e.what() << endl;
       
    41   }
       
    42 
       
    43   // assert(1==0);
       
    44   LEMON_ASSERT(1==0, "Ellentmondas");
       
    45   LEMON_FIXME("Nincs kesz");
       
    46 }
       
    47 
       
    48 #undef LEMON_ASSERT_HANDLER
       
    49 #define LEMON_ASSERT_HANDLER ::lemon::assert_fail_throw
       
    50 
       
    51 #include <error.h>
       
    52 
       
    53 void fail_assert() {
       
    54   LEMON_ASSERT(2*2==5, "Marson vagyunk");
       
    55 }
       
    56 
       
    57