decl_post_none.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 only middle base class with 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_PRECONDITIONS
  15. << "a::ctor::pre" << std::endl
  16. << "b::ctor::pre" << std::endl
  17. << "c::ctor::pre" << std::endl
  18. #endif
  19. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  20. << "c::static_inv" << std::endl
  21. #endif
  22. #ifndef BOOST_CONTRACT_NO_OLDS
  23. << "c::ctor::old" << std::endl
  24. #endif
  25. << "c::ctor::body" << std::endl
  26. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  27. << "c::static_inv" << std::endl
  28. << "c::inv" << std::endl
  29. #endif
  30. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  31. << "b::static_inv" << std::endl
  32. #endif
  33. #ifndef BOOST_CONTRACT_NO_OLDS
  34. << "b::ctor::old" << std::endl
  35. #endif
  36. << "b::ctor::body" << std::endl
  37. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  38. << "b::static_inv" << std::endl
  39. << "b::inv" << std::endl
  40. #endif
  41. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  42. << "a::static_inv" << std::endl
  43. #endif
  44. #ifndef BOOST_CONTRACT_NO_OLDS
  45. << "a::ctor::old" << std::endl
  46. #endif
  47. << "a::ctor::body" << std::endl
  48. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  49. << "a::static_inv" << std::endl
  50. << "a::inv" << std::endl
  51. #endif
  52. ;
  53. a_post = true;
  54. b_post = true;
  55. c_post = true;
  56. {
  57. out.str("");
  58. a aa;
  59. BOOST_TEST(out.eq(ok.str()));
  60. }
  61. a_post = false;
  62. b_post = true;
  63. c_post = true;
  64. {
  65. out.str("");
  66. a aa;
  67. BOOST_TEST(out.eq(ok.str()));
  68. }
  69. a_post = true;
  70. b_post = false;
  71. c_post = true;
  72. {
  73. out.str("");
  74. a aa;
  75. BOOST_TEST(out.eq(ok.str()));
  76. }
  77. a_post = true;
  78. b_post = true;
  79. c_post = false;
  80. {
  81. out.str("");
  82. a aa;
  83. BOOST_TEST(out.eq(ok.str()));
  84. }
  85. a_post = false;
  86. b_post = false;
  87. c_post = false;
  88. {
  89. out.str("");
  90. a aa;
  91. BOOST_TEST(out.eq(ok.str()));
  92. }
  93. return boost::report_errors();
  94. }