]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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) | |
5 | // | |
6 | // See http://www.boost.org/libs/test for the library home page. | |
7 | // | |
8 | ||
9 | //[snippet17 | |
10 | #define __BOOST_TEST_MODULE__ const_string test | |
11 | #include <boost/test/unit_test.hpp> | |
12 | ||
13 | __BOOST_AUTO_TEST_CASE__( constructors_test ) | |
14 | { | |
15 | //... | |
16 | } | |
17 | ||
18 | __BOOST_AUTO_TEST_CASE__( data_access_test ) | |
19 | { | |
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' ); | |
24 | ||
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' ); | |
28 | ||
29 | BOOST_CHECK_THROW( cs1.at( cs1.length() ), std::out_of_range ); // 3 // | |
30 | } | |
31 | //] |