unit_test_example_06.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // (C) Copyright Gennadiy Rozental 2005-2014.
  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. // Boost.Test
  7. #define BOOST_TEST_MODULE Unit test example 06
  8. #include <boost/test/unit_test.hpp>
  9. //____________________________________________________________________________//
  10. struct F {
  11. F() : i( 0 ) { BOOST_TEST_MESSAGE( "setup fixture" ); }
  12. ~F() { BOOST_TEST_MESSAGE( "teardown fixture" ); }
  13. int i;
  14. };
  15. //____________________________________________________________________________//
  16. // struct F is going to be used as a fixture for all test cases in this test suite
  17. BOOST_FIXTURE_TEST_SUITE( s, F )
  18. BOOST_AUTO_TEST_CASE( my_test1 )
  19. {
  20. BOOST_CHECK( i == 1 );
  21. }
  22. //____________________________________________________________________________//
  23. BOOST_AUTO_TEST_CASE( my_test2 )
  24. {
  25. BOOST_CHECK_EQUAL( i, 2 );
  26. BOOST_CHECK_EQUAL( i, 0 );
  27. }
  28. //____________________________________________________________________________//
  29. BOOST_AUTO_TEST_SUITE_END()
  30. // EOF