• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  (C) Copyright Gennadiy Rozental 2002-2014.
2 //  (C) Copyright Gennadiy Rozental & Ullrich Koethe 2001.
3 //  Distributed under the Boost Software License, Version 1.0.
4 //  (See accompanying file LICENSE_1_0.txt or copy at
5 //  http://www.boost.org/LICENSE_1_0.txt)
6 
7 //  See http://www.boost.org/libs/test for the library home page.
8 
9 // Boost.Test
10 #include <boost/test/unit_test.hpp>
11 #include <boost/test/parameterized_test.hpp>
12 using namespace boost::unit_test;
13 
14 // STL
15 #include <vector>
16 #include <string>
17 
18 #define LOG_FATAL_ERROR( M )                                  \
19 BOOST_TEST_LOG_ENTRY( ::boost::unit_test::log_fatal_errors )  \
20     << (::boost::unit_test::lazy_ostream::instance() << M)
21 //____________________________________________________________________________//
22 
23 // this free function is invoked with all parameters specified in a list
check_string(std::string const & s)24 void check_string( std::string const& s )
25 {
26     // reports 'error in "check_string": test s.substr( 0, 3 ) == "hdr" failed [actual_value != hdr]'
27     BOOST_CHECK_EQUAL( s.substr( 0, 3 ), "hdr" );
28 }
29 
30 //____________________________________________________________________________//
31 
32 test_suite*
init_unit_test_suite(int,char * [])33 init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) {
34     framework::master_test_suite().p_name.value = "Unit test example 11";
35 
36     LOG_FATAL_ERROR( "something happened" );
37 
38     // parameters have no requirements to stay alive beyond the next statement
39     std::string const params[] = { "hdr1 ", "hdr2", "3  " };
40 
41     framework::master_test_suite().add(
42         BOOST_PARAM_TEST_CASE( &check_string, (std::string const*)params, params+3 ) );
43 
44     return 0;
45 }
46 
47 //____________________________________________________________________________//
48 
49 // EOF
50