[GIT] ppl/ppl(master): DO_TEST_F now produces a more sensible output.

Module: ppl/ppl Branch: master Commit: 5b72ef21ddc5a6e8f055f9e83ea6b19145c0c5fc URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=5b72ef21ddc5a...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Sat Apr 25 14:07:17 2009 +0200
DO_TEST_F now produces a more sensible output.
---
TODO | 2 - tests/ppl_test.hh | 55 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/TODO b/TODO index f8f3a63..97a262f 100644 --- a/TODO +++ b/TODO @@ -17,8 +17,6 @@ Enhancements for PPL 0.11 - Intervals are best instantiated with checked numbers with particular policies: review all the interfaced boxes, augment the testsuite, and update the documentation. -- DO_TEST_F should not cause the output "failed tests" to appear, - but "tests unexpectedly succeeded". - Reduce the number of FIXMEs to no more than 20. - Switch to the latest versions of Autoconf and Automake (in beta test at the time of writing): they provide features we have been looking diff --git a/tests/ppl_test.hh b/tests/ppl_test.hh index 4ee3370..ff7e1eb 100644 --- a/tests/ppl_test.hh +++ b/tests/ppl_test.hh @@ -59,24 +59,33 @@ catch (const std::exception& e) { \ exit(1); \ }
-#define BEGIN_MAIN \ -int \ -main() try { \ - set_handlers(); \ - bool succeeded = false; \ - bool overflow = false; \ - std::liststd::string failed_tests; +#define BEGIN_MAIN \ +int \ +main() try { \ + set_handlers(); \ + bool succeeded = false; \ + bool overflow = false; \ + std::liststd::string failed_tests; \ + std::liststd::string unexpectedly_succeeded_tests;
#define END_MAIN \ - if (failed_tests.empty()) \ - return 0; \ - else { \ - std::cerr << "failed tests: "; \ - std::copy(failed_tests.begin(), failed_tests.end(), \ + if (!failed_tests.empty()) { \ + std::cerr << "tests failed: "; \ + std::copy(failed_tests.begin(), \ + failed_tests.end(), \ std::ostream_iteratorstd::string(std::cerr, " ")); \ std::cerr << std::endl; \ return 1; \ } \ + if (!unexpectedly_succeeded_tests.empty()) { \ + std::cerr << "tests unexpectedly succeeded: "; \ + std::copy(unexpectedly_succeeded_tests.begin(), \ + unexpectedly_succeeded_tests.end(), \ + std::ostream_iteratorstd::string(std::cerr, " ")); \ + std::cerr << std::endl; \ + return 1; \ + } \ + return 0; \ } \ catch (const std::overflow_error& e) { \ std::cerr << "arithmetic overflow (" << e.what() << ")" \ @@ -122,16 +131,18 @@ catch (const std::exception& e) { \ if (!succeeded) \ failed_tests.push_back(#test);
-#define DO_TEST_F(test) \ - ANNOUNCE_TEST(test); \ - RUN_TEST(test); \ - if (succeeded) \ - failed_tests.push_back(#test); - -#define DO_TEST_OVERFLOW(test) \ - ANNOUNCE_TEST(test); \ - RUN_TEST(test); \ - if (succeeded || !overflow) \ +#define DO_TEST_F(test) \ + ANNOUNCE_TEST(test); \ + RUN_TEST(test); \ + if (succeeded) \ + unexpectedly_succeeded_tests.push_back(#test); + +#define DO_TEST_OVERFLOW(test) \ + ANNOUNCE_TEST(test); \ + RUN_TEST(test); \ + if (succeeded) \ + unexpectedly_succeeded_tests.push_back(#test); \ + else if (!overflow) \ failed_tests.push_back(#test);
#define DO_TEST_MAY_OVERFLOW_IF_INEXACT(test, shape) \
participants (1)
-
Roberto Bagnara