exception_uncaught.run-fail.cpp 638 B

123456789101112131415161718192021222324252627282930
  1. // (C) Copyright 2015 Boost.test team
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //[example_code
  7. #define BOOST_TEST_MODULE example
  8. #include <boost/test/included/unit_test.hpp>
  9. struct my_struct {
  10. my_struct(int var_) : var(var_)
  11. {
  12. if(var_ < 0) throw std::runtime_error("negative value not allowed");
  13. }
  14. int var;
  15. };
  16. BOOST_AUTO_TEST_CASE( test )
  17. {
  18. my_struct instance(-2);
  19. // ...
  20. }
  21. BOOST_AUTO_TEST_CASE( test2 )
  22. {
  23. BOOST_TEST(true);
  24. }
  25. //]