summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2016-04-23 16:30:22 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2016-06-20 12:39:44 +0200
commit03e1d6e0d17eb2a5b98c42832cd90de3ff1c2bcf (patch)
tree2631b3f63dc7d864115a862a413ffd272879a18b
parent3b0500770311792a1fd8e97ab61a6083db82244e (diff)
downloadlibrest-03e1d6e0d17eb2a5b98c42832cd90de3ff1c2bcf.tar.gz
tests/lastfm: Port to GTest api
-rw-r--r--tests/lastfm.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/lastfm.c b/tests/lastfm.c
index 12e10d4..3c11483 100644
--- a/tests/lastfm.c
+++ b/tests/lastfm.c
@@ -28,8 +28,8 @@
#define SECRET "7db227a36b3154e3a3306a23754de1d7"
#define USERNAME "rossburton"
-int
-main (int argc, char **argv)
+static void
+test_lastfm ()
{
RestProxy *proxy;
RestProxyCall *call;
@@ -52,14 +52,15 @@ main (int argc, char **argv)
call = rest_proxy_new_call (proxy);
rest_proxy_call_set_function (call, "user.getInfo");
rest_proxy_call_add_param (call, "user", USERNAME);
- if (!rest_proxy_call_sync (call, &error))
- g_error ("Cannot make call: %s", error->message);
+ rest_proxy_call_sync (call, &error);
+
+ g_assert_no_error (error);
parser = rest_xml_parser_new ();
root = rest_xml_parser_parse_from_data (parser,
rest_proxy_call_get_payload (call),
rest_proxy_call_get_payload_length (call));
- g_assert (root);
+ g_assert_nonnull (root);
g_assert_cmpstr (root->name, ==, "lfm");
g_assert_cmpstr (rest_xml_node_get_attr (root, "status"), ==, "ok");
@@ -71,7 +72,7 @@ main (int argc, char **argv)
g_assert_cmpstr (node->content, ==, "17038");
node = rest_xml_node_find (u_node, "name");
- g_assert (node);
+ g_assert_nonnull (node);
g_assert_cmpstr (node->content, ==, USERNAME);
rest_xml_node_unref (root);
@@ -79,5 +80,14 @@ main (int argc, char **argv)
g_object_unref (call);
g_object_unref (proxy);
- return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/lastm/lastfm", test_lastfm);
+
+ return g_test_run ();
}