tested_at.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Copyright Rene Rivera 2011-2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #include <boost/predef/version_number.h>
  8. #include <boost/predef/other/workaround.h>
  9. #include <exception>
  10. #include <vector>
  11. #include <string>
  12. #include <iostream>
  13. namespace
  14. {
  15. struct test_info
  16. {
  17. std::string value;
  18. bool passed;
  19. test_info(std::string const & v, bool p) : value(v), passed(p) {}
  20. test_info(test_info const & o) : value(o.value), passed(o.passed) {}
  21. };
  22. std::vector<test_info> test_results;
  23. }
  24. #define PREDEF_CHECK(X) test_results.push_back(test_info(#X,(X)))
  25. void test_BOOST_PREDEF_TESTED_AT()
  26. {
  27. PREDEF_CHECK(BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(15,15,15),0xF,0xF,0xF));
  28. PREDEF_CHECK(BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(1,0,0),1,0,0));
  29. PREDEF_CHECK(BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(0,9,0),1,0,0));
  30. PREDEF_CHECK(BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER(2,0,0),1,0,0));
  31. PREDEF_CHECK(!BOOST_PREDEF_TESTED_AT(BOOST_VERSION_NUMBER_NOT_AVAILABLE,1,0,0));
  32. }
  33. int main()
  34. {
  35. test_BOOST_PREDEF_TESTED_AT();
  36. unsigned fail_count = 0;
  37. std::vector<test_info>::iterator i = test_results.begin();
  38. std::vector<test_info>::iterator e = test_results.end();
  39. for (; i != e; ++i)
  40. {
  41. std::cout
  42. << (i->passed ? "[passed]" : "[failed]")
  43. << " " << i->value
  44. << std::endl;
  45. fail_count += i->passed ? 0 : 1;
  46. }
  47. std::cout
  48. << std::endl
  49. << "TOTAL: "
  50. << "passed " << (test_results.size()-fail_count) << ", "
  51. << "failed " << (fail_count) << ", "
  52. << "of " << (test_results.size())
  53. << std::endl;
  54. return fail_count;
  55. }