[geocode-glib] test: Port locale test to GeocodeForward



commit 7b5d91bad588c1157f92498110508cf1d482d5aa
Author: Bastien Nocera <hadess hadess net>
Date:   Sun Nov 25 02:04:02 2012 +0100

    test: Port locale test to GeocodeForward
    
    At least, partially

 geocode-glib/test-gcglib.c |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/geocode-glib/test-gcglib.c b/geocode-glib/test-gcglib.c
index e182d83..7fdb7ff 100644
--- a/geocode-glib/test-gcglib.c
+++ b/geocode-glib/test-gcglib.c
@@ -239,30 +239,35 @@ test_search (void)
 static void
 test_locale (void)
 {
-	GeocodeObject *object;
+	GeocodeForward *object;
 	GError *error = NULL;
-	GHashTable *ht;
+	GList *res;
+	GeocodeLocation *loc;
 	char *old_locale;
 
 	old_locale = g_strdup (setlocale(LC_MESSAGES, NULL));
 
 	/* Check Moscow's name in Czech */
-	setlocale (LC_MESSAGES, "cs_CZ");
-	object = geocode_object_new_for_location ("moscow");
-	ht = geocode_object_resolve (object, &error);
-	if (ht == NULL) {
+	setlocale (LC_MESSAGES, "cs_CZ.UTF-8");
+	object = geocode_forward_new_for_string ("moscow");
+	res = geocode_forward_search (object, &error);
+	if (res == NULL) {
 		g_warning ("Failed at geocoding: %s", error->message);
 		g_error_free (error);
 	}
-	g_assert (ht != NULL);
+	g_assert (res != NULL);
 	g_object_unref (object);
-	g_assert (g_strcmp0 (g_hash_table_lookup (ht, "line2"), "Moskva") == 0);
-	g_print ("Got geocode answer:\n");
-	g_hash_table_foreach (ht, (GHFunc) print_res, NULL);
-	g_hash_table_destroy (ht);
 
+	loc = res->data;
+	g_assert_cmpstr (loc->description, ==, "Moskva");
+
+	g_list_free_full (res, (GDestroyNotify) geocode_location_free);
+
+	/* FIXME, when we have a better way to
+	 * differentiate the results */
+#if 0
 	/* Check Lyon's region in French */
-	setlocale (LC_MESSAGES, "fr_FR");
+	setlocale (LC_MESSAGES, "fr_FR.UTF-8");
 	object = geocode_object_new_for_location ("lyon");
 	ht = geocode_object_resolve (object, &error);
 	if (ht == NULL) {
@@ -275,7 +280,7 @@ test_locale (void)
 	g_print ("Got geocode answer:\n");
 	g_hash_table_foreach (ht, (GHFunc) print_res, NULL);
 	g_hash_table_destroy (ht);
-
+#endif
 	/* And reset the locale */
 	setlocale (LC_MESSAGES, old_locale);
 	g_free (old_locale);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]