decl_entry_inv_none.cpp 2.8 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 all derived and base classes without entry invariants.
  6. #define BOOST_CONTRACT_TEST_NO_A_INV
  7. #define BOOST_CONTRACT_TEST_NO_B_INV
  8. #define BOOST_CONTRACT_TEST_NO_C_INV
  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. #endif
  17. #ifndef BOOST_CONTRACT_NO_OLDS
  18. << "a::dtor::old" << std::endl
  19. #endif
  20. << "a::dtor::body" << std::endl
  21. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  22. << "a::static_inv" << std::endl
  23. #endif
  24. #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
  25. << "a::dtor::post" << std::endl
  26. #endif
  27. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  28. << "b::static_inv" << std::endl
  29. #endif
  30. #ifndef BOOST_CONTRACT_NO_OLDS
  31. << "b::dtor::old" << std::endl
  32. #endif
  33. << "b::dtor::body" << std::endl
  34. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  35. << "b::static_inv" << std::endl
  36. #endif
  37. #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
  38. << "b::dtor::post" << std::endl
  39. #endif
  40. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  41. << "c::static_inv" << std::endl
  42. #endif
  43. #ifndef BOOST_CONTRACT_NO_OLDS
  44. << "c::dtor::old" << std::endl
  45. #endif
  46. << "c::dtor::body" << std::endl
  47. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  48. << "c::static_inv" << std::endl
  49. #endif
  50. #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
  51. << "c::dtor::post" << std::endl
  52. #endif
  53. ;
  54. a_entry_inv = true;
  55. b_entry_inv = true;
  56. c_entry_inv = true;
  57. {
  58. a aa;
  59. out.str("");
  60. }
  61. BOOST_TEST(out.eq(ok.str()));
  62. a_entry_inv = false;
  63. b_entry_inv = true;
  64. c_entry_inv = true;
  65. {
  66. a aa;
  67. out.str("");
  68. }
  69. BOOST_TEST(out.eq(ok.str()));
  70. a_entry_inv = true;
  71. b_entry_inv = false;
  72. c_entry_inv = true;
  73. {
  74. a aa;
  75. out.str("");
  76. }
  77. BOOST_TEST(out.eq(ok.str()));
  78. a_entry_inv = true;
  79. b_entry_inv = true;
  80. c_entry_inv = false;
  81. {
  82. a aa;
  83. out.str("");
  84. }
  85. BOOST_TEST(out.eq(ok.str()));
  86. a_entry_inv = false;
  87. b_entry_inv = false;
  88. c_entry_inv = false;
  89. {
  90. a aa;
  91. out.str("");
  92. }
  93. BOOST_TEST(out.eq(ok.str()));
  94. return boost::report_errors();
  95. }