• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_xyz.hpp>
16 
17 #include <test_common/test_point.hpp>
18 
19 
20 template <typename T>
create_point_xyz()21 bg::model::d3::point_xyz<T> create_point_xyz()
22 {
23     T t1 = 1;
24     T t2 = 2;
25     T t3 = 3;
26     return bg::model::d3::point_xyz<T>(t1, t2, t3);
27 }
28 
29 template <typename P, typename T>
check_point_xyz(P & to_check,T x,T y,T z)30 void check_point_xyz(P& to_check, T x, T y, T z)
31 {
32     BOOST_CHECK_EQUAL(bg::get<0>(to_check), x);
33     BOOST_CHECK_EQUAL(bg::get<1>(to_check), y);
34     BOOST_CHECK_EQUAL(bg::get<2>(to_check), z);
35     BOOST_CHECK_EQUAL(to_check.x(), x);
36     BOOST_CHECK_EQUAL(to_check.y(), y);
37     BOOST_CHECK_EQUAL(to_check.z(), z);
38 }
39 
40 template <typename T>
test_default_constructor()41 void test_default_constructor()
42 {
43     bg::model::d3::point_xyz<T> p(create_point_xyz<T>());
44     check_point_xyz(p, 1, 2, 3);
45 }
46 
47 template <typename T>
test_copy_constructor()48 void test_copy_constructor()
49 {
50     bg::model::d3::point_xyz<T> p = create_point_xyz<T>();
51     check_point_xyz(p, 1, 2, 3);
52 }
53 
54 template <typename T>
test_copy_assignment()55 void test_copy_assignment()
56 {
57     bg::model::d3::point_xyz<T> p(create_point_xyz<T>());
58     bg::set<0>(p, 4);
59     bg::set<1>(p, 5);
60     bg::set<2>(p, 6);
61     check_point_xyz(p, 4, 5, 6);
62 }
63 
64 template <typename T>
test_all()65 void test_all()
66 {
67     test_default_constructor<T>();
68     test_copy_constructor<T>();
69     test_copy_assignment<T>();
70 }
71 
test_main(int,char * [])72 int test_main(int, char* [])
73 {
74     test_all<int>();
75     test_all<float>();
76     test_all<double>();
77 
78     return 0;
79 }
80