]> git.0d.be Git - empathy.git/commitdiff
port check-empathy-utils.c to GTest
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 27 Oct 2009 15:44:59 +0000 (15:44 +0000)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 3 Nov 2009 12:25:01 +0000 (12:25 +0000)
tests/.gitignore
tests/Makefile.am
tests/check-empathy-utils.c [deleted file]
tests/check-libempathy.h
tests/check-main.c
tests/empathy-utils-test.c [new file with mode: 0644]

index 28aa99b060d0b572f7283a133c022732a23afb0a..4e0f3c1f6b20ed423797f62f7a54d089c7cc433d 100644 (file)
@@ -1,2 +1,4 @@
 check-main
 *.log
+empathy-utils-test
+test-report.xml
index a93b6fd8a567fa5fae3b239d705a468c15a0abb7..21ee99bf8289fb9b613de0b1dee2ad5e757da2c3 100644 (file)
@@ -23,14 +23,19 @@ LDADD =                                                             \
        $(top_builddir)/libempathy/libempathy.la                \
        $(EMPATHY_LIBS)
 
-check_PROGRAMS = check-main
+TEST_PROGS =                                     \
+     empathy-utils-test
+
+empathy_utils_test_SOURCES = empathy-utils-test.c
+
+check_PROGRAMS = check-main $(TEST_PROGS)
+
 TESTS = check-main
 check_main_SOURCES =                             \
     check-main.c                                 \
     check-helpers.c                              \
     check-helpers.h                              \
     check-libempathy.h                           \
-    check-empathy-utils.c                        \
     check-empathy-helpers.h                      \
     check-empathy-helpers.c                      \
     check-irc-helper.h                           \
@@ -44,7 +49,7 @@ check_main_SOURCES =                             \
 check_c_sources = \
     $(check_main_SOURCES)
 include $(top_srcdir)/tools/check-coding-style.mk
-check-local: check-coding-style
+check-local: test check-coding-style
 
 check_main_LDADD = \
     @CHECK_LIBS@ \
@@ -59,3 +64,17 @@ check_main_CFLAGS = \
 TESTS_ENVIRONMENT = EMPATHY_SRCDIR=@abs_top_srcdir@ \
                    MC_PROFILE_DIR=@abs_top_srcdir@/tests \
                    MC_MANAGER_DIR=@abs_top_srcdir@/tests
+
+test-report: test-report.xml
+       gtester-report $(top_builddir)/tests/$@.xml > \
+         $(top_builddir)/tests/$@.html
+
+test-report.xml: ${TEST_PROGS} test
+
+test: ${TEST_PROGS}
+       gtester -o test-report.xml -k --verbose ${TEST_PROGS}
+
+test-%: empathy-%-test
+       gtester -o $@-report.xml -k --verbose $<
+
+.PHONY: test test-report
diff --git a/tests/check-empathy-utils.c b/tests/check-empathy-utils.c
deleted file mode 100644 (file)
index faf2610..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <check.h>
-#include "check-helpers.h"
-#include "check-libempathy.h"
-
-#include <libempathy/empathy-utils.h>
-
-START_TEST (test_empathy_substring)
-{
-  gchar *tmp;
-
-  tmp = empathy_substring ("empathy", 2, 6);
-  fail_if (tmp == NULL);
-  fail_if (strcmp (tmp, "path") != 0);
-
-  g_free (tmp);
-}
-END_TEST
-
-TCase *
-make_empathy_utils_tcase (void)
-{
-    TCase *tc = tcase_create ("empathy-utils");
-    tcase_add_test (tc, test_empathy_substring);
-    return tc;
-}
index 5dcb2b17a25a94c5eb11c97be443d2e6627721b6..35da2a14d87673c3756a5136b6ead871d8bbcbee 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef __CHECK_LIBEMPATHY__
 #define __CHECK_LIBEMPATHY__
 
-TCase * make_empathy_utils_tcase (void);
 TCase * make_empathy_irc_server_tcase (void);
 TCase * make_empathy_irc_network_tcase (void);
 TCase * make_empathy_irc_network_manager_tcase (void);
index 7adbc15df0a3a7a1a741be68a549f37e97ea0734..f5cd50a95e1f19cbbbdaea616dbae44a25641115 100644 (file)
@@ -16,7 +16,6 @@ make_libempathy_suite (void)
 {
     Suite *s = suite_create ("libempathy");
 
-    suite_add_tcase (s, make_empathy_utils_tcase ());
     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 ());
diff --git a/tests/empathy-utils-test.c b/tests/empathy-utils-test.c
new file mode 100644 (file)
index 0000000..415526f
--- /dev/null
@@ -0,0 +1,48 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include <libempathy/empathy-utils.h>
+
+static void
+test_init (int argc,
+    char **argv)
+{
+  g_test_init (&argc, &argv, NULL);
+  g_type_init ();
+}
+
+static void
+test_deinit (void)
+{
+  ;
+}
+
+static void
+test_substring (void)
+{
+  gchar *tmp;
+
+  tmp = empathy_substring ("empathy", 2, 6);
+  g_assert (tmp != NULL);
+  g_assert (strcmp (tmp, "path") == 0);
+
+  g_free (tmp);
+}
+
+int
+main (int argc,
+    char **argv)
+{
+  int result;
+
+  test_init (argc, argv);
+
+  g_test_add_func ("/utils/substring", test_substring);
+
+  result = g_test_run ();
+  test_deinit ();
+  return result;
+}