src/test/error_test.cc
changeset 489 afbdf8a3a633
child 542 69bde1d90c04
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/test/error_test.cc	Thu Apr 29 22:39:17 2004 +0000
     1.3 @@ -0,0 +1,57 @@
     1.4 +#include <iostream>
     1.5 +
     1.6 +#include <error.h>
     1.7 +
     1.8 +using namespace hugo;
     1.9 +using std::cout;
    1.10 +using std::endl;
    1.11 +
    1.12 +void faulty_fn() {
    1.13 +  fault("This is a fault message");
    1.14 +}
    1.15 +
    1.16 +void exception_fn() {
    1.17 +  throw Exception("This is a fn throwing excpt with some args: ") 
    1.18 +    << 5 << ", " << 18;
    1.19 +}
    1.20 +
    1.21 +void unfinished_fn() {
    1.22 +  FIXME("unfinished_fn() is unfinished!");
    1.23 +}
    1.24 +
    1.25 +
    1.26 +int main() {
    1.27 +  bool no_errors = false;
    1.28 +
    1.29 +  try {
    1.30 +    cout << "Trying a faulty function\n";
    1.31 +    faulty_fn();
    1.32 +    no_errors = true;
    1.33 +    cout << "FAILED!\n";
    1.34 +  }
    1.35 +  catch(const Exception &e) {
    1.36 +    cout << "E: " << e.what() << endl;
    1.37 +  }
    1.38 +
    1.39 +  try {
    1.40 +    cout << "Trying a function throwing Exception\n";
    1.41 +    exception_fn();
    1.42 +    no_errors = true;
    1.43 +    cout << "FAILED!\n";
    1.44 +  }
    1.45 +  catch(const Exception &e) {
    1.46 +    cout << "E: " << e.what() << endl;
    1.47 +  }
    1.48 +
    1.49 +  try {
    1.50 +    cout << "Trying a function using FIXME\n";
    1.51 +    unfinished_fn();
    1.52 +    no_errors = true;
    1.53 +    cout << "FAILED!\n";
    1.54 +  }
    1.55 +  catch(const Exception &e) {
    1.56 +    cout << "E: " << e.what() << endl;
    1.57 +  }
    1.58 +
    1.59 +  return no_errors ? 1 : 0;
    1.60 +}