Line | |
---|
1 | /* -*- C++ -*- |
---|
2 | * src/test/error_test.cc - Part of LEMON, a generic C++ optimization library |
---|
3 | * |
---|
4 | * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
5 | * (Egervary Combinatorial Optimization Research Group, EGRES). |
---|
6 | * |
---|
7 | * Permission to use, modify and distribute this software is granted |
---|
8 | * provided that this copyright notice appears in all copies. For |
---|
9 | * precise terms see the accompanying LICENSE file. |
---|
10 | * |
---|
11 | * This software is provided "AS IS" with no warranty of any kind, |
---|
12 | * express or implied, and with no claim as to its suitability for any |
---|
13 | * purpose. |
---|
14 | * |
---|
15 | */ |
---|
16 | |
---|
17 | #include <iostream> |
---|
18 | |
---|
19 | #include <lemon/error.h> |
---|
20 | #include "test_tools.h" |
---|
21 | using namespace lemon; |
---|
22 | using std::cout; |
---|
23 | using std::endl; |
---|
24 | |
---|
25 | void faulty_fn() { |
---|
26 | fault("This is a fault message"); |
---|
27 | } |
---|
28 | |
---|
29 | void exception_fn() { |
---|
30 | throw Exception("This is a fn throwing excpt with some args: ") |
---|
31 | << 5 << ", " << 18; |
---|
32 | } |
---|
33 | |
---|
34 | void unfinished_fn() { |
---|
35 | FIXME("unfinished_fn() is unfinished!"); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | int main() { |
---|
40 | try { |
---|
41 | faulty_fn(); |
---|
42 | check(false, "A faulty function did not fail."); |
---|
43 | } |
---|
44 | catch(const Exception &e) { |
---|
45 | cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl; |
---|
46 | } |
---|
47 | |
---|
48 | try { |
---|
49 | exception_fn(); |
---|
50 | check(false, "The function did not throw Exception."); |
---|
51 | } |
---|
52 | catch(const Exception &e) { |
---|
53 | cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl; |
---|
54 | } |
---|
55 | |
---|
56 | try { |
---|
57 | unfinished_fn(); |
---|
58 | check(false, "FIXME macro does not work."); |
---|
59 | } |
---|
60 | catch(const Exception &e) { |
---|
61 | cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl; |
---|
62 | } |
---|
63 | |
---|
64 | return 0; |
---|
65 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.