]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/util/select_most_precise.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / util / select_most_precise.cpp
CommitLineData
7c673cae
FG
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
1e59de90
TL
8// This file was modified by Oracle on 2021.
9// Modifications copyright (c) 2021, Oracle and/or its affiliates.
10// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11
7c673cae
FG
12// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
15// Use, modification and distribution is subject to the Boost Software License,
16// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17// http://www.boost.org/LICENSE_1_0.txt)
18
19
20#include <geometry_test_common.hpp>
21
22#include <boost/geometry/util/select_most_precise.hpp>
23
24
25struct user_defined {};
26
27template <typename T1, typename T2, typename ExpectedType>
28void test()
29{
1e59de90
TL
30 using type = typename bg::select_most_precise<T1, T2>::type;
31 bool is_same = std::is_same<type, ExpectedType>::value;
7c673cae
FG
32
33 BOOST_CHECK_MESSAGE(is_same,
34 "The most precise of types " <<
35 "T1: {" << typeid(T1).name() << " | s: " << sizeof(T1) << "}" <<
36 " and " <<
37 "T2: {" << typeid(T2).name() << " | s: " << sizeof(T2) << "}" <<
38 " does not match " <<
39 "ExpectedType: {" << typeid(ExpectedType).name() << " | s: " << sizeof(ExpectedType) << "}");
40}
41
42int test_main(int, char* [])
43{
44 // fp only
45 test<float, float, float>();
46 test<float, double, double>();
47 test<double, float, double>();
48 test<double, double, double>();
49
50 // integer only
51 test<int, int, int>();
52 test<int, short int, int>();
53 test<short int, int, int>();
54 test<short int, short int, short int>();
55
56 // int/fp
57 test<double, int, double>();
58 test<int, double, double>();
59 test<long double, long double, long double>();
60 test<float, int, float>();
61 test<int, float, float>();
62
63 if ( sizeof(long double) > sizeof(double) )
64 {
65 // This cannot be done for MSVC because double/long double is the same
66 // This is also true for Android
67 test<double, long double, long double>();
68 test<long double, double, long double>();
69 }
70
71 // with any other non-integer/float class
72 test<int, user_defined, user_defined>();
73 test<user_defined, int, user_defined>();
74 test<long double, user_defined, user_defined>();
75 test<user_defined, long double, user_defined>();
76 test<user_defined, user_defined, user_defined>();
77
78 // should not compile
79 //test<void, void, void>();
80
81 return 0;
82}