decl_post_none.cpp 939 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 without postconditions.
  6. #define BOOST_CONTRACT_TEST_NO_F_POST
  7. #include "decl.hpp"
  8. #include <boost/detail/lightweight_test.hpp>
  9. #include <sstream>
  10. int main() {
  11. std::ostringstream ok; ok // Test nothing fails.
  12. #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
  13. << "f::pre" << std::endl
  14. #endif
  15. #ifndef BOOST_CONTRACT_NO_OLDS
  16. << "f::old" << std::endl
  17. #endif
  18. << "f::body" << std::endl
  19. ;
  20. f_post = true;
  21. out.str("");
  22. f();
  23. BOOST_TEST(out.eq(ok.str()));
  24. f_post = false;
  25. out.str("");
  26. f();
  27. BOOST_TEST(out.eq(ok.str()));
  28. return boost::report_errors();
  29. }