Add regression test for FixedpointCoordinate
This commit is contained in:
parent
356dfc806d
commit
1b5d332e93
20
unit_tests/data_structures/coordinate.cpp
Normal file
20
unit_tests/data_structures/coordinate.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include <osrm/coordinate.hpp>
|
||||||
|
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
// Regression test for bug captured in #1347
|
||||||
|
BOOST_AUTO_TEST_CASE(regression_test_1347)
|
||||||
|
{
|
||||||
|
FixedPointCoordinate u(10 * COORDINATE_PRECISION, -100 * COORDINATE_PRECISION);
|
||||||
|
FixedPointCoordinate v(10.001 * COORDINATE_PRECISION, -100.002 * COORDINATE_PRECISION);
|
||||||
|
FixedPointCoordinate q(10.002 * COORDINATE_PRECISION, -100.001 * COORDINATE_PRECISION);
|
||||||
|
|
||||||
|
float d1 = FixedPointCoordinate::ComputePerpendicularDistance(u, v, q);
|
||||||
|
|
||||||
|
float ratio;
|
||||||
|
FixedPointCoordinate nearest_location;
|
||||||
|
float d2 = FixedPointCoordinate::ComputePerpendicularDistance(u, v, q, nearest_location, ratio);
|
||||||
|
|
||||||
|
BOOST_CHECK_LE(std::abs(d1 - d2), 0.01);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user