]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/geometries/point.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / geometry / test / geometries / point.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2020 Digvijay Janartha, Hamirpur, India.
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10
11 #include <geometry_test_common.hpp>
12
13 #include <boost/core/ignore_unused.hpp>
14 #include <boost/geometry/algorithms/make.hpp>
15 #include <boost/geometry/geometries/concepts/point_concept.hpp>
16 #include <boost/geometry/geometries/point.hpp>
17
18 #include <test_common/test_point.hpp>
19
20
21 template <typename T, typename CS>
22 bg::model::point<T, 3, CS> create_point()
23 {
24 T t1 = 1;
25 T t2 = 2;
26 T t3 = 3;
27 return bg::model::point<T, 3, CS>(t1, t2, t3);
28 }
29
30 template <typename P, typename T>
31 void check_point(P& to_check, T x, T y, T z)
32 {
33 BOOST_CHECK_EQUAL(bg::get<0>(to_check), x);
34 BOOST_CHECK_EQUAL(bg::get<1>(to_check), y);
35 BOOST_CHECK_EQUAL(bg::get<2>(to_check), z);
36 }
37
38 template <typename T, typename CS>
39 void test_default_constructor()
40 {
41 bg::model::point<T, 3, CS> p(create_point<T, CS>());
42 check_point(p, 1, 2, 3);
43 }
44
45 template <typename T, typename CS>
46 void test_copy_constructor()
47 {
48 bg::model::point<T, 3, CS> p = create_point<T, CS>();
49 check_point(p, 1, 2, 3);
50 }
51
52 template <typename T, typename CS>
53 void test_copy_assignment()
54 {
55 bg::model::point<T, 3, CS> p(create_point<T, CS>());
56 bg::set<0>(p, 4);
57 bg::set<1>(p, 5);
58 bg::set<2>(p, 6);
59 check_point(p, 4, 5, 6);
60 }
61
62 template <typename T, typename CS>
63 void test_concept()
64 {
65 typedef bg::model::point<T, 3, CS> P;
66
67 // Compilation tests, all things should compile.
68 BOOST_CONCEPT_ASSERT( (bg::concepts::ConstPoint<P>) );
69 BOOST_CONCEPT_ASSERT( (bg::concepts::Point<P>) );
70
71 typedef typename bg::coordinate_type<P>::type T1;
72 boost::ignore_unused<T1>();
73 }
74
75 template <typename T, typename CS>
76 void test_all()
77 {
78 test_default_constructor<T, CS>();
79 test_copy_constructor<T, CS>();
80 test_copy_assignment<T, CS>();
81 test_concept<T, CS>();
82 }
83
84 template <typename CS>
85 void test_cs()
86 {
87 test_all<int, CS>();
88 test_all<float, CS>();
89 test_all<double, CS>();
90 }
91
92
93 int test_main(int, char* [])
94 {
95 test_cs<bg::cs::cartesian>();
96 test_cs<bg::cs::spherical<bg::degree> >();
97 test_cs<bg::cs::spherical_equatorial<bg::degree> >();
98 test_cs<bg::cs::geographic<bg::degree> >();
99
100 return 0;
101 }