diff options
| author | Laurent Richard <[email protected]> | 2004-10-07 11:02:31 +0000 |
|---|---|---|
| committer | Laurent Richard <[email protected]> | 2004-10-07 11:02:31 +0000 |
| commit | 27fb7a5b96462dc22fff821789ad382804579b28 (patch) | |
| tree | 90eff8fc95db9e9b1a32da52dc993da6a2cf2f77 /tests/lib/unit++/tester.cc | |
| parent | Added FLAG_PASSED message flag to indicate a forwarded message (used in maild... (diff) | |
| download | vmime-27fb7a5b96462dc22fff821789ad382804579b28.tar.gz vmime-27fb7a5b96462dc22fff821789ad382804579b28.zip | |
New unit test system: Unit++.
Added test for header::getAllByName/Type
Diffstat (limited to 'tests/lib/unit++/tester.cc')
| -rw-r--r-- | tests/lib/unit++/tester.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/lib/unit++/tester.cc b/tests/lib/unit++/tester.cc new file mode 100644 index 00000000..f4b65acd --- /dev/null +++ b/tests/lib/unit++/tester.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2001 Claus Dr�by +// Terms of use are in the file COPYING +#include <typeinfo> +#include <iostream> +#include "tester.h" +using namespace std; + +using namespace unitpp; + +void tester::summary() +{ + os << "Tests [Ok-Fail-Error]: [" << n_test.n_ok() << '-' + << n_test.n_fail() << '-' << n_test.n_err() << "]\n"; +} +void tester::visit(test& t) +{ + try { + t(); + n_test.add_ok(); + write(t); + } catch (assertion_error& e) { + n_test.add_fail(); + write(t, e); + } catch (exception& e) { + n_test.add_err(); + write(t, e); + } catch (...) { + n_test.add_err(); + write(t, 0); + } +} + +void tester::visit(suite& t) +{ + if (verbose) + os << "****** " << t.name() << " ******" << endl; + accu.push(n_test); +} + +void tester::visit(suite& , int) +{ + res_cnt r(accu.top()); + accu.pop(); + if (n_test.n_err() != r.n_err()) + n_suite.add_err(); + else if (n_test.n_fail() != r.n_fail()) + n_suite.add_fail(); + else + n_suite.add_ok(); +} +void tester::write(test& t) +{ + if (verbose) + disp(t, "OK"); +} +void tester::disp(test& t, const string& status) +{ + os << status << ": " << t.name() << endl; +} +void tester::write(test& t, assertion_error& e) +{ + disp(t, "FAIL"); + os << e << '\n'; +} +void tester::write(test& t, std::exception& e) +{ + disp(t, "ERROR"); + os << " : [" << typeid(e).name() << "] " << e.what() << '\n'; +} +void tester::write(test& t, int ) +{ + disp(t, "ERROR"); + os << " : " << "unknown exception" << '\n'; +} |
