Rev | Line | |
---|
[489] | 1 | #include <iostream> |
---|
| 2 | |
---|
[542] | 3 | #include <hugo/error.h> |
---|
[727] | 4 | #include "test_tools.h" |
---|
[489] | 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(); |
---|
[727] | 26 | check(false, "A faulty function did not fail."); |
---|
[489] | 27 | } |
---|
| 28 | catch(const Exception &e) { |
---|
[727] | 29 | cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl; |
---|
[489] | 30 | } |
---|
| 31 | |
---|
| 32 | try { |
---|
| 33 | exception_fn(); |
---|
[727] | 34 | check(false, "The function did not throw Exception."); |
---|
[489] | 35 | } |
---|
| 36 | catch(const Exception &e) { |
---|
[727] | 37 | cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl; |
---|
[489] | 38 | } |
---|
| 39 | |
---|
| 40 | try { |
---|
| 41 | unfinished_fn(); |
---|
[727] | 42 | check(false, "FIXME macro does not work."); |
---|
[489] | 43 | } |
---|
| 44 | catch(const Exception &e) { |
---|
[727] | 45 | cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl; |
---|
[489] | 46 | } |
---|
| 47 | |
---|
[727] | 48 | return 0; |
---|
[489] | 49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.