[geocode-glib/wip/hadess/more-tests: 2/3] tests: Add π building in St Andrews
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib/wip/hadess/more-tests: 2/3] tests: Add π building in St Andrews
- Date: Thu, 30 Jun 2022 13:10:28 +0000 (UTC)
commit e762efb8ed0b6ccb80c08403ec551d772c8b6471
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jun 30 14:58:42 2022 +0200
tests: Add π building in St Andrews
See https://twitter.com/davidxnewton/status/1442232598932213761
Closes: #24
geocode-glib/tests/geocode-glib.c | 37 +++++++++++++++++++++++++++++++++++++
geocode-glib/tests/pi.json | 1 +
2 files changed, 38 insertions(+)
---
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
@@ -405,6 +405,42 @@ test_xep (void)
g_list_free (res);
}
+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)
{
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]