decl_post_none.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Copyright (C) 2008-2018 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0 (see accompanying
  3. // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  4. // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
  5. // Test all derived and base classes without postconditions.
  6. #define BOOST_CONTRACT_TEST_NO_A_POST
  7. #define BOOST_CONTRACT_TEST_NO_B_POST
  8. #define BOOST_CONTRACT_TEST_NO_C_POST
  9. #include "decl.hpp"
  10. #include <boost/detail/lightweight_test.hpp>
  11. #include <sstream>
  12. int main() {
  13. std::ostringstream ok; ok // Test nothing fails.
  14. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  15. << "a::static_inv" << std::endl
  16. << "a::inv" << std::endl
  17. #endif
  18. #ifndef BOOST_CONTRACT_NO_OLDS
  19. << "a::dtor::old" << std::endl
  20. #endif
  21. << "a::dtor::body" << std::endl
  22. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  23. << "a::static_inv" << std::endl
  24. #endif
  25. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  26. << "b::static_inv" << std::endl
  27. << "b::inv" << std::endl
  28. #endif
  29. #ifndef BOOST_CONTRACT_NO_OLDS
  30. << "b::dtor::old" << std::endl
  31. #endif
  32. << "b::dtor::body" << std::endl
  33. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  34. << "b::static_inv" << std::endl
  35. #endif
  36. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  37. << "c::static_inv" << std::endl
  38. << "c::inv" << std::endl
  39. #endif
  40. #ifndef BOOST_CONTRACT_NO_OLDS
  41. << "c::dtor::old" << std::endl
  42. #endif
  43. << "c::dtor::body" << std::endl
  44. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  45. << "c::static_inv" << std::endl
  46. #endif
  47. ;
  48. a_post = true;
  49. b_post = true;
  50. c_post = true;
  51. {
  52. a aa;
  53. out.str("");
  54. }
  55. BOOST_TEST(out.eq(ok.str()));
  56. a_post = false;
  57. b_post = true;
  58. c_post = true;
  59. {
  60. a aa;
  61. out.str("");
  62. }
  63. BOOST_TEST(out.eq(ok.str()));
  64. a_post = true;
  65. b_post = false;
  66. c_post = true;
  67. {
  68. a aa;
  69. out.str("");
  70. }
  71. BOOST_TEST(out.eq(ok.str()));
  72. a_post = true;
  73. b_post = true;
  74. c_post = false;
  75. {
  76. a aa;
  77. out.str("");
  78. }
  79. BOOST_TEST(out.eq(ok.str()));
  80. a_post = false;
  81. b_post = false;
  82. c_post = false;
  83. {
  84. a aa;
  85. out.str("");
  86. }
  87. BOOST_TEST(out.eq(ok.str()));
  88. return boost::report_errors();
  89. }