decl_entry_static_inv_none.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 static invariants.
  6. #define BOOST_CONTRACT_TEST_NO_A_STATIC_INV
  7. #define BOOST_CONTRACT_TEST_NO_B_STATIC_INV
  8. #define BOOST_CONTRACT_TEST_NO_C_STATIC_INV
  9. #include "decl.hpp"
  10. #include <boost/preprocessor/control/iif.hpp>
  11. #include <boost/detail/lightweight_test.hpp>
  12. #include <sstream>
  13. int main() {
  14. std::ostringstream ok; ok // Test nothing fails.
  15. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  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_POSTCONDITIONS
  23. << "a::dtor::post" << std::endl
  24. #endif
  25. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  26. << "b::inv" << std::endl
  27. #endif
  28. #ifndef BOOST_CONTRACT_NO_OLDS
  29. << "b::dtor::old" << std::endl
  30. #endif
  31. << "b::dtor::body" << std::endl
  32. #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
  33. << "b::dtor::post" << std::endl
  34. #endif
  35. #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  36. << "c::inv" << std::endl
  37. #endif
  38. #ifndef BOOST_CONTRACT_NO_OLDS
  39. << "c::dtor::old" << std::endl
  40. #endif
  41. << "c::dtor::body" << std::endl
  42. #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
  43. << "c::dtor::post" << std::endl
  44. #endif
  45. ;
  46. #ifdef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  47. #define BOOST_CONTRACT_TEST_entry_inv 0
  48. #else
  49. #define BOOST_CONTRACT_TEST_entry_inv 1
  50. #endif
  51. a_entry_static_inv = true;
  52. b_entry_static_inv = true;
  53. c_entry_static_inv = true;
  54. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  55. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  56. {
  57. a aa;
  58. out.str("");
  59. }
  60. BOOST_TEST(out.eq(ok.str()));
  61. a_entry_static_inv = false;
  62. b_entry_static_inv = true;
  63. c_entry_static_inv = true;
  64. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  65. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  66. {
  67. a aa;
  68. out.str("");
  69. }
  70. BOOST_TEST(out.eq(ok.str()));
  71. a_entry_static_inv = true;
  72. b_entry_static_inv = false;
  73. c_entry_static_inv = true;
  74. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  75. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  76. {
  77. a aa;
  78. out.str("");
  79. }
  80. BOOST_TEST(out.eq(ok.str()));
  81. a_entry_static_inv = true;
  82. b_entry_static_inv = true;
  83. c_entry_static_inv = false;
  84. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  85. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  86. {
  87. a aa;
  88. out.str("");
  89. }
  90. BOOST_TEST(out.eq(ok.str()));
  91. a_entry_static_inv = false;
  92. b_entry_static_inv = false;
  93. c_entry_static_inv = false;
  94. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  95. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  96. {
  97. a aa;
  98. out.str("");
  99. }
  100. BOOST_TEST(out.eq(ok.str()));
  101. #undef BOOST_CONTRACT_TEST_entry_inv
  102. return boost::report_errors();
  103. }