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