Bypass boost::numeric_cast checks for coordinate values that have already been validated (#4059)
(i.e. stuff that's stored in our datafiles). Keep those checks for user-supplied values (i.e. coordinates coming from files during preprocessing, or coordinates supplied by users during requests)
This commit is contained in:
@@ -125,14 +125,17 @@ BOOST_AUTO_TEST_CASE(compute_angle)
|
||||
end = Coordinate{FloatLongitude{1 + std::numeric_limits<double>::epsilon()}, FloatLatitude{0}};
|
||||
angle = coordinate_calculation::computeAngle(first, middle, end);
|
||||
BOOST_CHECK_EQUAL(angle, 180);
|
||||
}
|
||||
|
||||
// Invalid values
|
||||
BOOST_CHECK_THROW(
|
||||
coordinate_calculation::computeAngle(
|
||||
Coordinate(FloatLongitude{0}, FloatLatitude{0}),
|
||||
Coordinate(FloatLongitude{1}, FloatLatitude{0}),
|
||||
Coordinate(FloatLongitude{std::numeric_limits<double>::max()}, FloatLatitude{0})),
|
||||
boost::numeric::positive_overflow);
|
||||
BOOST_AUTO_TEST_CASE(invalid_values)
|
||||
{
|
||||
// Invalid values for unsafe types
|
||||
BOOST_CHECK_THROW(coordinate_calculation::computeAngle(
|
||||
Coordinate(UnsafeFloatLongitude{0}, UnsafeFloatLatitude{0}),
|
||||
Coordinate(UnsafeFloatLongitude{1}, UnsafeFloatLatitude{0}),
|
||||
Coordinate(UnsafeFloatLongitude{std::numeric_limits<double>::max()},
|
||||
UnsafeFloatLatitude{0})),
|
||||
boost::numeric::positive_overflow);
|
||||
}
|
||||
|
||||
// Regression test for bug captured in #1347
|
||||
|
||||
Reference in New Issue
Block a user