1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/work/klao/error_test.cc Sun Jan 09 23:28:18 2005 +0000
1.3 @@ -0,0 +1,57 @@
1.4 +#include <iostream>
1.5 +#include <string>
1.6 +
1.7 +#define LEMON_ASSERT_ABORT 0
1.8 +#include <error.h>
1.9 +
1.10 +using namespace std;
1.11 +
1.12 +void parse_line() {
1.13 + throw lemon::DataFormatError("Syntax error");
1.14 +}
1.15 +
1.16 +void parse_file(string fn) {
1.17 + try {
1.18 + parse_line();
1.19 + }
1.20 + catch(lemon::DataFormatError &e) {
1.21 + e.set_file(fn);
1.22 + e.set_line(5);
1.23 + throw;
1.24 + }
1.25 +}
1.26 +
1.27 +void fail_assert();
1.28 +
1.29 +int main() {
1.30 + try {
1.31 + parse_file("input.txt");
1.32 + }
1.33 + catch(exception &e) {
1.34 + cerr << "Exception caught: " << endl;
1.35 + cerr << e.what() << endl;
1.36 + }
1.37 +
1.38 + try {
1.39 + fail_assert();
1.40 + }
1.41 + catch(exception &e) {
1.42 + cerr << "Exception caught: " << endl;
1.43 + cerr << e.what() << endl;
1.44 + }
1.45 +
1.46 + // assert(1==0);
1.47 + LEMON_ASSERT(1==0, "Ellentmondas");
1.48 + LEMON_FIXME("Nincs kesz");
1.49 +}
1.50 +
1.51 +#undef LEMON_ASSERT_HANDLER
1.52 +#define LEMON_ASSERT_HANDLER ::lemon::assert_fail_throw
1.53 +
1.54 +#include <error.h>
1.55 +
1.56 +void fail_assert() {
1.57 + LEMON_ASSERT(2*2==5, "Marson vagyunk");
1.58 +}
1.59 +
1.60 +