[test] Add test for newly added azimuth() algorithm.

This commit is contained in:
Adam Wulkiewicz 2021-01-13 01:24:50 +01:00
parent 24dc47e23f
commit 627e9d93b5
2 changed files with 65 additions and 2 deletions

View File

@ -5,8 +5,8 @@
# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
# Copyright (c) 2018 Adam Wulkiewicz, Lodz, Poland.
#
# This file was modified by Oracle on 2014, 2015, 2016, 2017.
# Modifications copyright (c) 2014-2017, Oracle and/or its affiliates.
# This file was modified by Oracle on 2014-2021.
# Modifications copyright (c) 2014-2021, Oracle and/or its affiliates.
#
# Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
@ -20,6 +20,7 @@ test-suite boost-geometry-algorithms
:
[ run append.cpp : : : : algorithms_append ]
[ run assign.cpp : : : : algorithms_assign ]
[ run azimuth.cpp : : : : algorithms_azimuth ]
[ run centroid.cpp : : : : algorithms_centroid ]
[ run centroid_multi.cpp : : : : algorithms_centroid_multi ]
[ run comparable_distance.cpp : : : : algorithms_comparable_distance ]

View File

@ -0,0 +1,62 @@
// Boost.Geometry
// Unit Test
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include <geometry_test_common.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/algorithms/azimuth.hpp>
template <typename P>
void test_one(P const& p1, P const& p2, double expected)
{
double const result = bg::azimuth(p1, p2) * bg::math::r2d<double>();
BOOST_CHECK_CLOSE(result, expected, 0.0001);
}
template <typename P>
void test_car()
{
test_one(P(0, 0), P(0, 0), 0);
test_one(P(0, 0), P(1, 1), 45);
test_one(P(0, 0), P(100, 1), 89.427061302316517);
test_one(P(0, 0), P(-1, 1), -45);
test_one(P(0, 0), P(-100, 1), -89.427061302316517);
}
template <typename P>
void test_sph()
{
test_one(P(0, 0), P(0, 0), 0);
test_one(P(0, 0), P(1, 1), 44.995636455344851);
test_one(P(0, 0), P(100, 1), 88.984576593576293);
test_one(P(0, 0), P(-1, 1), -44.995636455344851);
test_one(P(0, 0), P(-100, 1), -88.984576593576293);
}
template <typename P>
void test_geo()
{
test_one(P(0, 0), P(0, 0), 0);
test_one(P(0, 0), P(1, 1), 45.187718848049521);
test_one(P(0, 0), P(100, 1), 88.986933066023497);
test_one(P(0, 0), P(-1, 1), -45.187718848049521);
test_one(P(0, 0), P(-100, 1), -88.986933066023497);
}
int test_main(int, char* [])
{
test_car< bg::model::point<double, 2, bg::cs::cartesian> >();
test_sph< bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_geo< bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
return 0;
}