]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/array/test/array_getfail2.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / array / test / array_getfail2.cpp
1 /* tests using std::get on boost:array
2 * (C) Copyright Marshall Clow 2012
3 * Distributed under the Boost Software License, Version 1.0. (See
4 * accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7
8 #include <string>
9 #include <iostream>
10 #include <boost/array.hpp>
11 #include <algorithm>
12 #ifndef BOOST_NO_CXX11_HDR_ARRAY
13 #include <array>
14 #endif
15
16 #define BOOST_TEST_MAIN
17 #include <boost/test/unit_test.hpp>
18
19 namespace {
20
21 #ifndef BOOST_NO_CXX11_HDR_ARRAY
22 template< class T >
23 void RunStdTests()
24 {
25 typedef boost::array< T, 5 > test_type;
26 typedef T arr[5];
27 test_type test_case; // = { 1, 1, 2, 3, 5 };
28
29 T &aRef = std::get<0> ( test_case );
30 BOOST_CHECK ( &*test_case.begin () == &aRef );
31
32 const T &caRef = std::get<0> ( test_case );
33 BOOST_CHECK ( &*test_case.cbegin () == &caRef );
34 }
35 #endif
36
37 template< class T >
38 void RunBoostTests()
39 {
40 typedef boost::array< T, 5 > test_type;
41 typedef T arr[5];
42 test_type test_case; // = { 1, 1, 2, 3, 5 };
43
44 T &aRef = boost::get<5> ( test_case );
45 BOOST_CHECK ( &*test_case.begin () == &aRef );
46 }
47
48 }
49
50 BOOST_AUTO_TEST_CASE( test_main )
51 {
52 RunBoostTests< bool >();
53 RunBoostTests< void * >();
54 RunBoostTests< long double >();
55 RunBoostTests< std::string >();
56
57 #ifndef BOOST_NO_CXX11_HDR_ARRAY
58 RunStdTests< bool >();
59 RunStdTests< void * >();
60 RunStdTests< long double >();
61 RunStdTests< std::string >();
62 #endif
63 }
64