]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/test/adaptor_test/formatted_example.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / range / test / adaptor_test / formatted_example.cpp
1 // Boost.Range library
2 //
3 // Copyright Neil Groves 2014. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 //
9 // For more information, see http://www.boost.org/libs/range/
10 //
11 //[formatted_example
12 #include <boost/range/adaptor/formatted.hpp>
13 #include <boost/assign.hpp>
14 #include <iterator>
15 #include <iostream>
16 #include <string>
17 #include <sstream>
18 #include <vector>
19
20 //<-
21 #include <boost/test/test_tools.hpp>
22 #include <boost/test/unit_test.hpp>
23
24 #include <boost/range/algorithm_ext/push_back.hpp>
25
26 namespace
27 {
28 void formatted_example_test()
29 //->
30 //=int main(int argc, const char* argv[])
31 {
32 using namespace boost::assign;
33
34 std::vector<int> input;
35 input += 1,2,3,4,5;
36
37 std::cout << boost::adaptors::format(input) << std::endl;
38
39 // Alternatively this can be written:
40 // std::cout << (input | boost::adaptors::formatted()) << std::endl;
41
42 //= return 0;
43 //=}
44 //]
45 std::ostringstream test;
46 test << boost::adaptors::format(input);
47
48 BOOST_CHECK_EQUAL(test.str(), "{1,2,3,4,5}");
49 }
50 }
51
52 boost::unit_test::test_suite*
53 init_unit_test_suite(int argc, char* argv[])
54 {
55 boost::unit_test::test_suite* test
56 = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.formatted_example" );
57
58 test->add( BOOST_TEST_CASE( &formatted_example_test ) );
59
60 return test;
61 }