]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/bimap/test/test_structured_pair.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / bimap / test / test_structured_pair.cpp
CommitLineData
7c673cae
FG
1// Boost.Bimap
2//
3// Copyright (c) 2006-2007 Matias Capeletto
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8
9// VC++ 8.0 warns on usage of certain Standard Library and API functions that
10// can be cause buffer overruns or other possible security issues if misused.
92f5a8d4 11// See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
7c673cae
FG
12// But the wording of the warning is misleading and unsettling, there are no
13// portable alternative functions, and VC++ 8.0's own libraries use the
14// functions in question. So turn off the warnings.
15#define _CRT_SECURE_NO_DEPRECATE
16#define _SCL_SECURE_NO_DEPRECATE
17
18#include <boost/config.hpp>
19
20// Boost.Test
21#include <boost/test/minimal.hpp>
22
23// std
24#include <utility>
25#include <cstddef>
26
27// Boost.Static_assert
28#include <boost/static_assert.hpp>
29
30// Boost.Bimap
31#include <boost/bimap/detail/test/check_metadata.hpp>
32
33#include <boost/bimap/relation/structured_pair.hpp>
34
35
36BOOST_BIMAP_TEST_STATIC_FUNCTION( static_metadata_test )
37{
38 using namespace boost::bimaps::relation;
39
40 struct data_a { char data; };
41 struct data_b { double data; };
42
43 typedef structured_pair
44 <
45 data_a,
46 data_b,
47 normal_layout
48
49 > sp_ab;
50
51 typedef structured_pair
52 <
53 data_b,
54 data_a,
55 mirror_layout
56
57 > sp_ba;
58
59 BOOST_BIMAP_CHECK_METADATA(sp_ab, first_type , data_a);
60 BOOST_BIMAP_CHECK_METADATA(sp_ab, second_type, data_b);
61
62 BOOST_BIMAP_CHECK_METADATA(sp_ba, first_type , data_b);
63 BOOST_BIMAP_CHECK_METADATA(sp_ba, second_type, data_a);
64
65}
66
67
68void test_basic()
69{
70
71 using namespace boost::bimaps::relation;
72
73 // Instanciate two pairs and test the storage alignmentDataData
74
75 typedef structured_pair< short, double, normal_layout > pair_type;
76 typedef structured_pair< double, short, mirror_layout > mirror_type;
77
78 pair_type pa( 2, 3.1416 );
79 mirror_type pb( 3.1416, 2 );
80
81 BOOST_CHECK( pa.first == pb.second );
82 BOOST_CHECK( pa.second == pb.first );
83
84}
85
86
87int test_main( int, char* [] )
88{
89
90 BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( static_are_storage_compatible_test );
91
92 BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( static_metadata_test );
93
94 test_basic();
95
96 return 0;
97}
98