[geocode-glib/wip/hadess/zero-distance-test-case] tests: Add a zero distance test
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib/wip/hadess/zero-distance-test-case] tests: Add a zero distance test
- Date: Tue, 9 Oct 2018 16:11:33 +0000 (UTC)
commit bb7807d358285c13064ad7848be343409be122bf
Author: Bastien Nocera <hadess hadess net>
Date: Tue Oct 9 18:10:29 2018 +0200
tests: Add a zero distance test
The equivalent code in libgweather had a bug that made it return "nan"
as a distance if the 2 set of coordinates were exactly the same. Test
for this as well.
geocode-glib/tests/geocode-glib.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/geocode-glib/tests/geocode-glib.c b/geocode-glib/tests/geocode-glib.c
index d90779d..ce26b3d 100644
--- a/geocode-glib/tests/geocode-glib.c
+++ b/geocode-glib/tests/geocode-glib.c
@@ -628,6 +628,19 @@ test_distance (void)
g_assert_cmpfloat (geocode_location_get_distance_from (loca, locb) - 0.549311, <, 0.000001);
}
+static void
+test_zero_distance (void)
+{
+ g_autoptr (GeocodeLocation) loca = NULL, locb = NULL;
+
+ /* 1600 Pennsylvania Ave NW, Washington, DC */
+ loca = geocode_location_new (38.898556, -77.037852, GEOCODE_LOCATION_ACCURACY_UNKNOWN);
+ /* 1600 Pennsylvania Ave NW, Washington, DC */
+ locb = geocode_location_new (38.898556, -77.037852, GEOCODE_LOCATION_ACCURACY_UNKNOWN);
+
+ g_assert_cmpfloat (geocode_location_get_distance_from (loca, locb), ==, 0.0);
+}
+
static void
test_locale_format (void)
{
@@ -914,6 +927,7 @@ int main (int argc, char **argv)
g_test_add_func ("/geocode/search", test_search);
g_test_add_func ("/geocode/search_lat_long", test_search_lat_long);
g_test_add_func ("/geocode/distance", test_distance);
+ g_test_add_func ("/geocode/zero_distance", test_zero_distance);
g_test_add_func ("/geocode/osm_type", test_osm_type);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]