[geocode-glib] test: Add geocoding test case
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib] test: Add geocoding test case
- Date: Wed, 27 Apr 2011 14:01:39 +0000 (UTC)
commit 8d9efa7612daf4e782467f99517f474db3aebae2
Author: Bastien Nocera <hadess hadess net>
Date: Wed Apr 27 15:01:08 2011 +0100
test: Add geocoding test case
geocode-glib/test-gcglib.c | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/geocode-glib/test-gcglib.c b/geocode-glib/test-gcglib.c
index 5c38641..4e1a42d 100644
--- a/geocode-glib/test-gcglib.c
+++ b/geocode-glib/test-gcglib.c
@@ -59,6 +59,7 @@ test_rev (void)
g_error_free (error);
}
g_assert (ht != NULL);
+ g_object_unref (object);
g_assert (g_strcmp0 (g_hash_table_lookup (ht, "neighborhood"), "Onslow Village") == 0);
@@ -68,6 +69,31 @@ test_rev (void)
}
static void
+test_pub (void)
+{
+ GeocodeObject *object;
+ GError *error = NULL;
+ GHashTable *ht;
+
+ object = geocode_object_new ();
+ geocode_object_add (object, "location", "9, old palace road, guildford, surrey");
+ ht = geocode_object_resolve (object, &error);
+ if (ht == NULL) {
+ g_warning ("Failed at geocoding: %s", error->message);
+ g_error_free (error);
+ }
+ g_assert (ht != NULL);
+
+ g_object_unref (object);
+ g_assert (g_strcmp0 (g_hash_table_lookup (ht, "longitude"), "-0.589669") == 0);
+ g_assert (g_strcmp0 (g_hash_table_lookup (ht, "latitude"), "51.237070") == 0);
+
+ g_print ("Got geocode answer:\n");
+ g_hash_table_foreach (ht, (GHFunc) print_res, NULL);
+ g_hash_table_destroy (ht);
+}
+
+static void
test_json (void)
{
GHashTable *ht;
@@ -110,8 +136,6 @@ int main (int argc, char **argv)
GOptionContext *context;
GeocodeObject *object;
const GOptionEntry entries[] = {
-// { "async", 'a', 0, G_OPTION_ARG_NONE, &option_async, "Use the async API", NULL },
-// { "file-list", 'f', 0, G_OPTION_ARG_NONE, &option_file_list, "Show the file list instead of the GTIN", NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, ¶ms, NULL, "[KEY=VALUE...]" },
{ NULL }
};
@@ -134,7 +158,7 @@ int main (int argc, char **argv)
if (params == NULL) {
g_test_add_func ("/geocode/json", test_json);
g_test_add_func ("/geocode/reverse", test_rev);
-// g_test_add_func ("/geocode/pub", test_pub);
+ g_test_add_func ("/geocode/pub", test_pub);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]