[empathy] port check-empathy-utils.c to GTest
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy] port check-empathy-utils.c to GTest
- Date: Tue, 3 Nov 2009 12:42:59 +0000 (UTC)
commit f053694701a9cb6c35fa0250c1a0b3374bd54395
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Oct 27 15:44:59 2009 +0000
port check-empathy-utils.c to GTest
tests/.gitignore | 2 +
tests/Makefile.am | 25 +++++++++++++++++++--
tests/check-empathy-utils.c | 29 --------------------------
tests/check-libempathy.h | 1 -
tests/check-main.c | 1 -
tests/empathy-utils-test.c | 48 +++++++++++++++++++++++++++++++++++++++++++
6 files changed, 72 insertions(+), 34 deletions(-)
---
diff --git a/tests/.gitignore b/tests/.gitignore
index 28aa99b..4e0f3c1 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,2 +1,4 @@
check-main
*.log
+empathy-utils-test
+test-report.xml
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a93b6fd..21ee99b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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-libempathy.h b/tests/check-libempathy.h
index 5dcb2b1..35da2a1 100644
--- a/tests/check-libempathy.h
+++ b/tests/check-libempathy.h
@@ -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);
diff --git a/tests/check-main.c b/tests/check-main.c
index 7adbc15..f5cd50a 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_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
index 0000000..415526f
--- /dev/null
+++ b/tests/empathy-utils-test.c
@@ -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;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]