]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/geometries/point_xyz.cpp
00dcc0fd6dca73ecee6b7ebb8f3ed80cd890a257
[ceph.git] / ceph / src / boost / libs / geometry / test / geometries / point_xyz.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2020 Digvijay Janartha, Hamirpur, India.
5
6 // This file was modified by Oracle on 2020.
7 // Modifications copyright (c) 2020, Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13
14
15 #include <geometry_test_common.hpp>
16
17 #include <boost/geometry/algorithms/make.hpp>
18 #include <boost/geometry/geometries/point.hpp>
19 #include <boost/geometry/geometries/point_xyz.hpp>
20
21 #include <test_common/test_point.hpp>
22
23
24 template <typename T>
25 bg::model::d3::point_xyz<T> create_point_xyz()
26 {
27 T t1 = 1;
28 T t2 = 2;
29 T t3 = 3;
30 return bg::model::d3::point_xyz<T>(t1, t2, t3);
31 }
32
33 template <typename P, typename T>
34 void check_point_xyz(P& to_check, T x, T y, T z)
35 {
36 BOOST_CHECK_EQUAL(bg::get<0>(to_check), x);
37 BOOST_CHECK_EQUAL(bg::get<1>(to_check), y);
38 BOOST_CHECK_EQUAL(bg::get<2>(to_check), z);
39 BOOST_CHECK_EQUAL(to_check.x(), x);
40 BOOST_CHECK_EQUAL(to_check.y(), y);
41 BOOST_CHECK_EQUAL(to_check.z(), z);
42 }
43
44 template <typename T>
45 void test_default_constructor()
46 {
47 bg::model::d3::point_xyz<T> p(create_point_xyz<T>());
48 check_point_xyz(p, 1, 2, 3);
49 }
50
51 template <typename T>
52 void test_copy_constructor()
53 {
54 bg::model::d3::point_xyz<T> p = create_point_xyz<T>();
55 check_point_xyz(p, 1, 2, 3);
56 }
57
58 template <typename T>
59 void test_copy_assignment()
60 {
61 bg::model::d3::point_xyz<T> p(create_point_xyz<T>());
62 bg::set<0>(p, 4);
63 bg::set<1>(p, 5);
64 bg::set<2>(p, 6);
65 check_point_xyz(p, 4, 5, 6);
66 }
67
68 template <typename T>
69 void test_constexpr()
70 {
71 typedef bg::model::d3::point_xyz<T> P;
72 constexpr P p = P(1, 2, 3);
73 constexpr T c = bg::get<0>(p);
74 BOOST_CHECK_EQUAL(c, 1);
75 check_point_xyz(p, 1, 2, 3);
76 }
77
78 template <typename T>
79 void test_all()
80 {
81 test_default_constructor<T>();
82 test_copy_constructor<T>();
83 test_copy_assignment<T>();
84 test_constexpr<T>();
85 }
86
87 int test_main(int, char* [])
88 {
89 test_all<int>();
90 test_all<float>();
91 test_all<double>();
92
93 return 0;
94 }