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