diff options
author | Bastien Nocera <hadess@hadess.net> | 2022-06-30 14:58:42 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2022-06-30 14:59:33 +0200 |
commit | e762efb8ed0b6ccb80c08403ec551d772c8b6471 (patch) | |
tree | 2af6ed47ea745aaef119ddcc03a7bfa43df02081 | |
parent | 2c11802f5e32f74f083f562c97b4b088fa98e4d6 (diff) | |
download | geocode-glib-e762efb8ed0b6ccb80c08403ec551d772c8b6471.tar.gz |
tests: Add π building in St Andrews
See https://twitter.com/davidxnewton/status/1442232598932213761
Closes: #24
-rw-r--r-- | geocode-glib/tests/geocode-glib.c | 37 | ||||
-rw-r--r-- | geocode-glib/tests/pi.json | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/geocode-glib/tests/geocode-glib.c b/geocode-glib/tests/geocode-glib.c index 7cecd9d..d2c8ed2 100644 --- a/geocode-glib/tests/geocode-glib.c +++ b/geocode-glib/tests/geocode-glib.c @@ -406,6 +406,42 @@ test_xep (void) } static void +test_pi (void) +{ + g_autoptr (GHashTable) params = NULL; + GeocodeForward *object; + GError *error = NULL; + GList *res; + GeocodePlace *place; + + /* The query parameters the mock server expects to receive. */ + params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); + add_attr_string (params, "q", "Jack Cole Building, St Andrews"); + add_attr_string (params, "limit", "1"); + add_attr_string (params, "bounded", "1"); + + object = create_forward_for_string ("Jack Cole Building, St Andrews", + params, "pi.json"); + geocode_forward_set_bounded (object, TRUE); + + geocode_forward_set_answer_count (object, 1); + res = geocode_forward_search (object, &error); + if (res == NULL) { + g_warning ("Failed at geocoding: %s", error->message); + g_error_free (error); + } + g_assert (res != NULL); + + g_object_unref (object); + + g_assert_cmpint (g_list_length (res), ==, 1); + place = res->data; + g_assert_cmpstr (geocode_place_get_street_address (place), ==, "North Haugh π"); + g_object_unref (place); + g_list_free (res); +} + +static void test_pub (void) { g_autoptr (GHashTable) params = NULL; @@ -928,6 +964,7 @@ int main (int argc, char **argv) g_test_add_func ("/geocode/reverse", test_rev); g_test_add_func ("/geocode/reverse_fail", test_rev_fail); g_test_add_func ("/geocode/pub", test_pub); + g_test_add_func ("/geocode/pi", test_pi); g_test_add_func ("/geocode/xep-0080", test_xep); g_test_add_func ("/geocode/locale_name", test_locale_name); g_test_add_func ("/geocode/locale_format", test_locale_format); diff --git a/geocode-glib/tests/pi.json b/geocode-glib/tests/pi.json new file mode 100644 index 0000000..8fa457c --- /dev/null +++ b/geocode-glib/tests/pi.json @@ -0,0 +1 @@ +[{"place_id":137481899,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":155223867,"boundingbox":["56.3400548","56.3405548","-2.8091325","-2.8082914"],"lat":"56.3403005","lon":"-2.808676959389439","display_name":"Jack Cole Building (Computer Science), π, North Haugh, St Andrews, Fife, Scotland, KY16 9SX, United Kingdom","place_rank":30,"category":"building","type":"university","importance":0.5001,"address":{"building":"Jack Cole Building (Computer Science)","house_number":"π","road":"North Haugh","town":"St Andrews","county":"Fife","ISO3166-2-lvl6":"GB-FIF","state":"Scotland","ISO3166-2-lvl4":"GB-SCT","postcode":"KY16 9SX","country":"United Kingdom","country_code":"gb"}}]
\ No newline at end of file |