]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/util/compress_variant.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / test / util / compress_variant.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14
15
16 #include <boost/test/included/test_exec_monitor.hpp>
17 #include <boost/geometry/util/compress_variant.hpp>
18 #include <boost/mpl/assert.hpp>
19 #include <boost/mpl/equal.hpp>
20 #include <boost/mpl/vector.hpp>
21 #include <boost/type_traits/is_same.hpp>
22 #include <boost/variant/variant.hpp>
23
24
25 template <typename ExpectedTypes, BOOST_VARIANT_ENUM_PARAMS(typename T)>
26 void check_variant_types(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>)
27 {
28 BOOST_MPL_ASSERT((
29 boost::mpl::equal<
30 typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
31 ExpectedTypes
32 >
33 ));
34 }
35
36 template <typename Variant, typename ExpectedTypes>
37 void test_variant_result()
38 {
39 check_variant_types<ExpectedTypes>(typename boost::geometry::compress_variant<Variant>::type());
40 }
41
42 template <typename Variant, typename ExpectedType>
43 void test_single_type_result()
44 {
45 BOOST_MPL_ASSERT((
46 boost::is_same<
47 typename boost::geometry::compress_variant<Variant>::type,
48 ExpectedType
49 >
50 ));
51 }
52
53
54 int test_main(int, char* [])
55 {
56 test_variant_result<
57 boost::variant<int, float, double>,
58 boost::mpl::vector<int, float, double>
59 >();
60
61 test_variant_result<
62 boost::variant<int, float, double, int, int, float, double, double, float>,
63 boost::mpl::vector<int, double, float>
64 >();
65
66 test_single_type_result<
67 boost::variant<int>,
68 int
69 >();
70
71 test_single_type_result<
72 boost::variant<double, double, double, double, double>,
73 double
74 >();
75
76 return 0;
77 }