decl_entry_static_inv_none.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 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_PRECONDITIONS
  16. << "a::ctor::pre" << std::endl
  17. << "b::ctor::pre" << std::endl
  18. << "c::ctor::pre" << std::endl
  19. #endif
  20. #ifndef BOOST_CONTRACT_NO_OLDS
  21. << "c::ctor::old" << std::endl
  22. #endif
  23. << "c::ctor::body" << std::endl
  24. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  25. << "c::inv" << std::endl
  26. #endif
  27. #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
  28. << "c::ctor::post" << std::endl
  29. #endif
  30. #ifndef BOOST_CONTRACT_NO_OLDS
  31. << "b::ctor::old" << std::endl
  32. #endif
  33. << "b::ctor::body" << std::endl
  34. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  35. << "b::inv" << std::endl
  36. #endif
  37. #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
  38. << "b::ctor::post" << std::endl
  39. #endif
  40. #ifndef BOOST_CONTRACT_NO_OLDS
  41. << "a::ctor::old" << std::endl
  42. #endif
  43. << "a::ctor::body" << std::endl
  44. #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
  45. << "a::inv" << std::endl
  46. #endif
  47. #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
  48. << "a::ctor::post" << std::endl
  49. #endif
  50. ;
  51. #ifdef BOOST_CONTRACT_ENTRY_INVARIANTS
  52. #define BOOST_CONTRACT_TEST_entry_inv 0
  53. #else
  54. #define BOOST_CONTRACT_TEST_entry_inv 1
  55. #endif
  56. a_entry_static_inv = true;
  57. b_entry_static_inv = true;
  58. c_entry_static_inv = true;
  59. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  60. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  61. {
  62. out.str("");
  63. a aa;
  64. BOOST_TEST(out.eq(ok.str()));
  65. }
  66. a_entry_static_inv = false;
  67. b_entry_static_inv = true;
  68. c_entry_static_inv = true;
  69. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  70. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  71. {
  72. out.str("");
  73. a aa;
  74. BOOST_TEST(out.eq(ok.str()));
  75. }
  76. a_entry_static_inv = true;
  77. b_entry_static_inv = false;
  78. c_entry_static_inv = true;
  79. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  80. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  81. {
  82. out.str("");
  83. a aa;
  84. BOOST_TEST(out.eq(ok.str()));
  85. }
  86. a_entry_static_inv = true;
  87. b_entry_static_inv = true;
  88. c_entry_static_inv = false;
  89. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  90. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  91. {
  92. out.str("");
  93. a aa;
  94. BOOST_TEST(out.eq(ok.str()));
  95. }
  96. a_entry_static_inv = false;
  97. b_entry_static_inv = false;
  98. c_entry_static_inv = false;
  99. a_entering_static_inv = b_entering_static_inv = c_entering_static_inv =
  100. BOOST_PP_IIF(BOOST_CONTRACT_TEST_entry_inv, true, false);
  101. {
  102. out.str("");
  103. a aa;
  104. BOOST_TEST(out.eq(ok.str()));
  105. }
  106. #undef BOOST_CONTRACT_TEST_entry_inv
  107. return boost::report_errors();
  108. }