1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/error_test.cc Thu Feb 07 21:28:39 2008 +0000
1.3 @@ -0,0 +1,68 @@
1.4 +/* -*- C++ -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library
1.7 + *
1.8 + * Copyright (C) 2003-2008
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#include <iostream>
1.23 +
1.24 +#include <lemon/error.h>
1.25 +#include "test_tools.h"
1.26 +
1.27 +using namespace lemon;
1.28 +using std::cout;
1.29 +using std::endl;
1.30 +
1.31 +void faulty_fn() {
1.32 + fault("This is a fault message");
1.33 +}
1.34 +
1.35 +void exception_fn() {
1.36 + throw Exception("This is a function throwing exception with some args: ")
1.37 + << 5 << ", " << 18;
1.38 +}
1.39 +
1.40 +void unfinished_fn() {
1.41 + LEMON_FIXME("unfinished_fn() is unfinished!");
1.42 +}
1.43 +
1.44 +
1.45 +int main() {
1.46 + try {
1.47 + faulty_fn();
1.48 + check(false, "A faulty function did not fail.");
1.49 + }
1.50 + catch(const Exception &e) {
1.51 + cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
1.52 + }
1.53 +
1.54 + try {
1.55 + exception_fn();
1.56 + check(false, "The function did not throw Exception.");
1.57 + }
1.58 + catch(const Exception &e) {
1.59 + cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
1.60 + }
1.61 +
1.62 + try {
1.63 + unfinished_fn();
1.64 + check(false, "FIXME macro does not work.");
1.65 + }
1.66 + catch(const Exception &e) {
1.67 + cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
1.68 + }
1.69 +
1.70 + return 0;
1.71 +}