]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/geometries/point_xy.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / geometry / test / geometries / point_xy.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_xy.hpp>
20
21 #include <test_common/test_point.hpp>
22
23
24 template <typename T>
25 bg::model::d2::point_xy<T> create_point_xy()
26 {
27 T t1 = 1;
28 T t2 = 2;
29 return bg::model::d2::point_xy<T>(t1, t2);
30 }
31
32 template <typename P, typename T>
33 void check_point_xy(P& to_check, T x, T y)
34 {
35 BOOST_CHECK_EQUAL(bg::get<0>(to_check), x);
36 BOOST_CHECK_EQUAL(bg::get<1>(to_check), y);
37 BOOST_CHECK_EQUAL(to_check.x(), x);
38 BOOST_CHECK_EQUAL(to_check.y(), y);
39 }
40
41 template <typename T>
42 void test_default_constructor()
43 {
44 bg::model::d2::point_xy<T> p(create_point_xy<T>());
45 check_point_xy(p, 1, 2);
46 }
47
48 template <typename T>
49 void test_copy_constructor()
50 {
51 bg::model::d2::point_xy<T> p(create_point_xy<T>());
52 check_point_xy(p, 1, 2);
53 }
54
55 template <typename T>
56 void test_copy_assignment()
57 {
58 bg::model::d2::point_xy<T> p(create_point_xy<T>());
59 bg::set<0>(p, 4);
60 bg::set<1>(p, 5);
61 check_point_xy(p, 4, 5);
62 }
63
64 template <typename T>
65 void test_constexpr()
66 {
67 typedef bg::model::d2::point_xy<T> P;
68 constexpr P p = P(1, 2);
69 constexpr T c = bg::get<0>(p);
70 BOOST_CHECK_EQUAL(c, 1);
71 check_point_xy(p, 1, 2);
72 }
73
74 template <typename T>
75 void test_all()
76 {
77 test_default_constructor<T>();
78 test_copy_constructor<T>();
79 test_copy_assignment<T>();
80 test_constexpr<T>();
81 }
82
83 int test_main(int, char* [])
84 {
85 test_all<int>();
86 test_all<float>();
87 test_all<double>();
88
89 return 0;
90 }