summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2018-10-09 18:10:29 +0200
committerBastien Nocera <hadess@hadess.net>2018-10-09 18:10:29 +0200
commitbb7807d358285c13064ad7848be343409be122bf (patch)
tree92136e9e081943359c9df90158693668bd153f9a
parentda3cf65f09dbfbf0fe417e20b469d146255d5234 (diff)
downloadgeocode-glib-bb7807d358285c13064ad7848be343409be122bf.tar.gz
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.
-rw-r--r--geocode-glib/tests/geocode-glib.c14
1 files changed, 14 insertions, 0 deletions
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
@@ -629,6 +629,19 @@ test_distance (void)
}
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)
{
#if defined(__GLIBC__) && !defined(__UCLIBC__)
@@ -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 ();
}