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/geometry/algorithms/make.hpp>
14 #include <boost/geometry/geometries/point.hpp>
15 #include <boost/geometry/geometries/point_xy.hpp>
16
17 #include <test_common/test_point.hpp>
18
19
20 template <typename T>
create_point_xy()21 bg::model::d2::point_xy<T> create_point_xy()
22 {
23 T t1 = 1;
24 T t2 = 2;
25 return bg::model::d2::point_xy<T>(t1, t2);
26 }
27
28 template <typename P, typename T>
check_point_xy(P & to_check,T x,T y)29 void check_point_xy(P& to_check, T x, T y)
30 {
31 BOOST_CHECK_EQUAL(bg::get<0>(to_check), x);
32 BOOST_CHECK_EQUAL(bg::get<1>(to_check), y);
33 BOOST_CHECK_EQUAL(to_check.x(), x);
34 BOOST_CHECK_EQUAL(to_check.y(), y);
35 }
36
37 template <typename T>
test_default_constructor()38 void test_default_constructor()
39 {
40 bg::model::d2::point_xy<T> p(create_point_xy<T>());
41 check_point_xy(p, 1, 2);
42 }
43
44 template <typename T>
test_copy_constructor()45 void test_copy_constructor()
46 {
47 bg::model::d2::point_xy<T> p(create_point_xy<T>());
48 check_point_xy(p, 1, 2);
49 }
50
51 template <typename T>
test_copy_assignment()52 void test_copy_assignment()
53 {
54 bg::model::d2::point_xy<T> p(create_point_xy<T>());
55 bg::set<0>(p, 4);
56 bg::set<1>(p, 5);
57 check_point_xy(p, 4, 5);
58 }
59
60 template <typename T>
test_all()61 void test_all()
62 {
63 test_default_constructor<T>();
64 test_copy_constructor<T>();
65 test_copy_assignment<T>();
66 }
67
test_main(int,char * [])68 int test_main(int, char* [])
69 {
70 test_all<int>();
71 test_all<float>();
72 test_all<double>();
73
74 return 0;
75 }
76