]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/doc/snippet/snippet17.cpp
1 // (C) Copyright Gennadiy Rozental 2001-2015.
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)
6 // See http://www.boost.org/libs/test for the library home page.
10 #define __BOOST_TEST_MODULE__ const_string test
11 #include <boost/test/unit_test.hpp>
13 __BOOST_AUTO_TEST_CASE__( constructors_test
)
18 __BOOST_AUTO_TEST_CASE__( data_access_test
)
20 const_string
cs1( "test_string" ); // 1 //
21 __BOOST_TEST__( cs1
[(size_t)0] == 't' );
22 __BOOST_TEST__( cs1
[(size_t)4] == '_' );
23 __BOOST_TEST__( cs1
[cs1
.length()-1] == 'g' );
25 __BOOST_TEST__( cs1
[(size_t)0] == cs1
.at( 0 ) ); // 2 //
26 __BOOST_TEST__( cs1
[(size_t)2] == cs1
.at( 5 ) );
27 __BOOST_TEST__( cs1
.at( cs1
.length() - 1 ) == 'g' );
29 BOOST_CHECK_THROW( cs1
.at( cs1
.length() ), std::out_of_range
); // 3 //