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