diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-10-28 00:10:41 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-11-03 20:25:01 +0800 |
commit | 85268449651286df02e6da607abd98828fd68a6a (patch) | |
tree | 91030f116511b107fa94493352d75b3f90d41e5d | |
parent | 2a974fc78e833d232a6203d5a807b0ee5efb396a (diff) | |
download | gsoc2013-empathy-85268449651286df02e6da607abd98828fd68a6a.tar gsoc2013-empathy-85268449651286df02e6da607abd98828fd68a6a.tar.gz gsoc2013-empathy-85268449651286df02e6da607abd98828fd68a6a.tar.bz2 gsoc2013-empathy-85268449651286df02e6da607abd98828fd68a6a.tar.lz gsoc2013-empathy-85268449651286df02e6da607abd98828fd68a6a.tar.xz gsoc2013-empathy-85268449651286df02e6da607abd98828fd68a6a.tar.zst gsoc2013-empathy-85268449651286df02e6da607abd98828fd68a6a.zip |
port check-empathy-irc-server.c to GTest
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 8 | ||||
-rw-r--r-- | tests/check-irc-helper.c | 24 | ||||
-rw-r--r-- | tests/check-libempathy.h | 1 | ||||
-rw-r--r-- | tests/check-main.c | 1 | ||||
-rw-r--r-- | tests/empathy-irc-server-test.c (renamed from tests/check-empathy-irc-server.c) | 53 |
6 files changed, 48 insertions, 40 deletions
diff --git a/tests/.gitignore b/tests/.gitignore index 4e0f3c1f6..ccf6ccd3e 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,4 +1,5 @@ check-main *.log empathy-utils-test +empathy-irc-server-test test-report.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index bc7407aac..29bd2257f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,11 +24,16 @@ LDADD = \ $(EMPATHY_LIBS) TEST_PROGS = \ - empathy-utils-test + empathy-utils-test \ + empathy-irc-server-test empathy_utils_test_SOURCES = empathy-utils-test.c \ test-helper.c test-helper.h +empathy_irc_server_test_SOURCES = empathy-irc-server-test.c \ + test-helper.c test-helper.h \ + check-irc-helper.h check-irc-helper.c + check_PROGRAMS = check-main $(TEST_PROGS) TESTS = check-main @@ -41,7 +46,6 @@ check_main_SOURCES = \ check-empathy-helpers.c \ check-irc-helper.h \ check-irc-helper.c \ - check-empathy-irc-server.c \ check-empathy-irc-network.c \ check-empathy-irc-network-manager.c \ check-empathy-chatroom.c \ diff --git a/tests/check-irc-helper.c b/tests/check-irc-helper.c index 477b134c2..1a2832a7b 100644 --- a/tests/check-irc-helper.c +++ b/tests/check-irc-helper.c @@ -10,7 +10,7 @@ check_server (EmpathyIrcServer *server, guint port; gboolean ssl; - fail_if (server == NULL); + g_assert (server != NULL); g_object_get (server, "address", &address, @@ -18,9 +18,9 @@ check_server (EmpathyIrcServer *server, "ssl", &ssl, NULL); - fail_if (address == NULL || strcmp (address, _address) != 0); - fail_if (port != _port); - fail_if (ssl != _ssl); + g_assert (address != NULL && strcmp (address, _address) == 0); + g_assert (port == _port); + g_assert (ssl == _ssl); g_free (address); } @@ -36,18 +36,18 @@ check_network (EmpathyIrcNetwork *network, GSList *servers, *l; guint i; - fail_if (network == NULL); + g_assert (network != NULL); g_object_get (network, "name", &name, "charset", &charset, NULL); - fail_if (name == NULL || strcmp (name, _name) != 0); - fail_if (charset == NULL || strcmp (charset, _charset) != 0); + g_assert (name != NULL && strcmp (name, _name) == 0); + g_assert (charset != NULL && strcmp (charset, _charset) == 0); servers = empathy_irc_network_get_servers (network); - fail_if (g_slist_length (servers) != nb_servers); + g_assert (g_slist_length (servers) == nb_servers); /* Is that the right servers ? */ for (l = servers, i = 0; l != NULL; l = g_slist_next (l), i++) @@ -65,10 +65,10 @@ check_network (EmpathyIrcNetwork *network, "ssl", &ssl, NULL); - fail_if (address == NULL || strcmp (address, _servers[i].address) - != 0); - fail_if (port != _servers[i].port); - fail_if (ssl != _servers[i].ssl); + g_assert (address != NULL && strcmp (address, _servers[i].address) + == 0); + g_assert (port == _servers[i].port); + g_assert (ssl == _servers[i].ssl); g_free (address); } diff --git a/tests/check-libempathy.h b/tests/check-libempathy.h index 35da2a14d..ea8aeb158 100644 --- a/tests/check-libempathy.h +++ b/tests/check-libempathy.h @@ -1,7 +1,6 @@ #ifndef __CHECK_LIBEMPATHY__ #define __CHECK_LIBEMPATHY__ -TCase * make_empathy_irc_server_tcase (void); TCase * make_empathy_irc_network_tcase (void); TCase * make_empathy_irc_network_manager_tcase (void); TCase * make_empathy_chatroom_tcase (void); diff --git a/tests/check-main.c b/tests/check-main.c index f5cd50a95..311e6ccae 100644 --- a/tests/check-main.c +++ b/tests/check-main.c @@ -16,7 +16,6 @@ make_libempathy_suite (void) { Suite *s = suite_create ("libempathy"); - suite_add_tcase (s, make_empathy_irc_server_tcase ()); suite_add_tcase (s, make_empathy_irc_network_tcase ()); suite_add_tcase (s, make_empathy_irc_network_manager_tcase ()); suite_add_tcase (s, make_empathy_chatroom_tcase ()); diff --git a/tests/check-empathy-irc-server.c b/tests/empathy-irc-server-test.c index 52607f221..b9574c40c 100644 --- a/tests/check-empathy-irc-server.c +++ b/tests/empathy-irc-server-test.c @@ -2,14 +2,13 @@ #include <stdio.h> #include <string.h> -#include <check.h> -#include "check-helpers.h" -#include "check-libempathy.h" #include "check-irc-helper.h" +#include "test-helper.h" #include <libempathy/empathy-irc-server.h> -START_TEST (test_empathy_irc_server_new) +static void +test_empathy_irc_server_new (void) { EmpathyIrcServer *server; @@ -18,14 +17,14 @@ START_TEST (test_empathy_irc_server_new) g_object_unref (server); } -END_TEST -START_TEST (test_property_change) +static void +test_property_change (void) { EmpathyIrcServer *server; server = empathy_irc_server_new ("test.localhost", 6667, TRUE); - fail_if (server == NULL); + g_assert (server != NULL); g_object_set (server, "address", "test2.localhost", @@ -37,7 +36,6 @@ START_TEST (test_property_change) g_object_unref (server); } -END_TEST static gboolean modified = FALSE; @@ -48,46 +46,53 @@ modified_cb (EmpathyIrcServer *server, modified = TRUE; } -START_TEST (test_modified_signal) +static void +test_modified_signal (void) { EmpathyIrcServer *server; server = empathy_irc_server_new ("test.localhost", 6667, TRUE); - fail_if (server == NULL); + g_assert (server != NULL); g_signal_connect (server, "modified", G_CALLBACK (modified_cb), NULL); /* address */ g_object_set (server, "address", "test2.localhost", NULL); - fail_if (!modified); + g_assert (modified); modified = FALSE; g_object_set (server, "address", "test2.localhost", NULL); - fail_if (modified); + g_assert (!modified); /* port */ g_object_set (server, "port", 6668, NULL); - fail_if (!modified); + g_assert (modified); modified = FALSE; g_object_set (server, "port", 6668, NULL); - fail_if (modified); + g_assert (!modified); /* ssl */ g_object_set (server, "ssl", FALSE, NULL); - fail_if (!modified); + g_assert (modified); modified = FALSE; g_object_set (server, "ssl", FALSE, NULL); - fail_if (modified); + g_assert (!modified); g_object_unref (server); } -END_TEST -TCase * -make_empathy_irc_server_tcase (void) +int +main (int argc, + char **argv) { - TCase *tc = tcase_create ("empathy-irc-server"); - tcase_add_test (tc, test_empathy_irc_server_new); - tcase_add_test (tc, test_property_change); - tcase_add_test (tc, test_modified_signal); - return tc; + int result; + + test_init (argc, argv); + + g_test_add_func ("/irc-server/new", test_empathy_irc_server_new); + g_test_add_func ("/irc-server/property-change", test_property_change); + g_test_add_func ("/irc-server/modified-signal", test_modified_signal); + + result = g_test_run (); + test_deinit (); + return result; } |