diff --git a/CHANGELOG.md b/CHANGELOG.md index 35e9090b8..9c4832bdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Fixed an issue that could emit `invalid` as instruction when ending on a sliproad after a traffic-light - Fixed an issue that would detect turning circles as sliproads - Fixed a bug where post-processing instructions (e.g. left + left -> uturn) could result in false pronunciations + - Fixes a bug where a bearing range of zero would cause exhaustive graph traversals # 5.3.0 Changes from 5.3.0-rc.3 diff --git a/include/util/bearing.hpp b/include/util/bearing.hpp index 930069131..de308adce 100644 --- a/include/util/bearing.hpp +++ b/include/util/bearing.hpp @@ -67,7 +67,7 @@ inline bool CheckInBounds(const int A, const int B, const int range) if (range >= 180) return true; - if (range <= 0) + if (range < 0) return false; // Map both bearings into positive modulo 360 space diff --git a/unit_tests/util/bearing.cpp b/unit_tests/util/bearing.cpp index 4a953c90d..2d7fc9fce 100644 --- a/unit_tests/util/bearing.cpp +++ b/unit_tests/util/bearing.cpp @@ -42,6 +42,9 @@ BOOST_AUTO_TEST_CASE(bearing_range_test) BOOST_CHECK_EQUAL(true, bearing::CheckInBounds(-721, 5, 10)); BOOST_CHECK_EQUAL(true, bearing::CheckInBounds(719, 5, 10)); + + BOOST_CHECK_EQUAL(false, bearing::CheckInBounds(1, 1, -1)); + BOOST_CHECK_EQUAL(true, bearing::CheckInBounds(1, 1, 0)); } BOOST_AUTO_TEST_SUITE_END()