[librest/wip/baedert/gtask: 21/25] tests/lastfm: Port to GTest api



commit 1912ddc72a448d984835ebd2969096c303403634
Author: Timm Bäder <mail baedert org>
Date:   Sat Apr 23 16:30:22 2016 +0200

    tests/lastfm: Port to GTest api

 tests/lastfm.c |   24 +++++++++++++++++-------
 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 ();
 }


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