Skip to content

Commit

Permalink
fix: LocationTest.shouldGenerateNearbyGPSCoordinateWithOriginInMiles …
Browse files Browse the repository at this point in the history
…not accounting for precision tolerance (#1039)

* Add fabs to distance calculation to catch errors due to precision

* Add fabs to distance calculation to catch errors due to precision

* Remove leftover debugging code
  • Loading branch information
dj-riff authored Jan 23, 2025
1 parent 2e71cab commit 7b61883
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/modules/location_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,10 +669,11 @@ TEST_F(LocationTest, shouldGenerateNearbyGPSCoordinateWithOriginInMiles)
ASSERT_EQ(generatedLongitudeParts[1].size(), 3);

const auto distanceKm =
vincentyDistance(std::get<0>(origin), std::get<1>(origin), latitudeAsFloat, longitudeAsFloat);
vincentyDistance(std::get<0>(origin), std::get<1>(origin), latitudeAsFloat, longitudeAsFloat);
const auto distanceMiles = distanceKm * 0.621371;
constexpr double TOLERANCE = 1e-12;

ASSERT_LE(distanceMiles, 10.0);
ASSERT_LE(fabs(distanceMiles - 10.0), 10.0 + TOLERANCE);
}

TEST_F(LocationTest, shouldGenerateDirection)
Expand Down

0 comments on commit 7b61883

Please sign in to comment.