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 6 // See http://www.boost.org/libs/test for the library home page. 7 8 // Boost.Test 9 #define BOOST_TEST_MODULE "Unit test example 05" 10 #include <boost/test/unit_test.hpp> 11 namespace bt = boost::unit_test; 12 13 //____________________________________________________________________________// 14 15 BOOST_AUTO_TEST_SUITE( my_suite ) 16 17 struct F { FF18 F() : i( 0 ) { BOOST_TEST_MESSAGE( "setup fixture" ); } ~FF19 ~F() { BOOST_TEST_MESSAGE( "teardown fixture" ); } 20 21 int i; 22 }; 23 24 //____________________________________________________________________________// 25 26 // this test case will use struct F as fixture 27 auto& d = 28 * bt::enabled() 29 * bt::expected_failures(1); BOOST_FIXTURE_TEST_CASE(my_test1,F)30BOOST_FIXTURE_TEST_CASE( my_test1, F ) 31 { 32 // you have direct access to non-private members of fixture structure 33 BOOST_TEST( i == 1 ); 34 } 35 36 //____________________________________________________________________________// 37 38 // you could have any number of test cases with the same fixture 39 BOOST_FIXTURE_TEST_CASE( my_test2, F, * bt::depends_on("my_suite/my_test1") ) 40 { 41 BOOST_TEST( i == 2 ); 42 43 BOOST_TEST( i == 0 ); 44 } 45 46 //____________________________________________________________________________// 47 48 BOOST_AUTO_TEST_SUITE_END() 49 50 // EOF 51