/pidgin/main: 651092763669: Move the oscar unit tests to gtester

Gary Kramlich grim at reaperworld.com
Wed Mar 30 19:25:27 EDT 2016


Changeset: 651092763669b08d3082a6c07cbaaca287cc222c
Author:	 Gary Kramlich <grim at reaperworld.com>
Date:	 2016-03-12 10:38 -0600
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/651092763669

Description:

Move the oscar unit tests to gtester

diffstat:

 .hgignore                                         |   1 +
 configure.ac                                      |   1 +
 libpurple/protocols/oscar/Makefile.am             |   2 +
 libpurple/protocols/oscar/tests/.hgignore         |   7 +++
 libpurple/protocols/oscar/tests/Makefile.am       |  23 +++++++++++
 libpurple/protocols/oscar/tests/test_oscar_util.c |  45 ++++++++++------------
 6 files changed, 54 insertions(+), 25 deletions(-)

diffs (143 lines):

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -150,6 +150,7 @@ stamp-h1
 test-driver
 win32-install-dir(\.release)?
 
+subinclude:libpurple/protocols/oscar/tests/.hgignore
 subinclude:libpurple/protocols/yahoo/tests/.hgignore
 subinclude:libpurple/tests/.hgignore
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -2260,6 +2260,7 @@ AC_CONFIG_FILES([Makefile
 		   libpurple/protocols/novell/Makefile
 		   libpurple/protocols/null/Makefile
 		   libpurple/protocols/oscar/Makefile
+		   libpurple/protocols/oscar/tests/Makefile
 		   libpurple/protocols/sametime/Makefile
 		   libpurple/protocols/silc/Makefile
 		   libpurple/protocols/simple/Makefile
diff --git a/libpurple/protocols/oscar/Makefile.am b/libpurple/protocols/oscar/Makefile.am
--- a/libpurple/protocols/oscar/Makefile.am
+++ b/libpurple/protocols/oscar/Makefile.am
@@ -78,3 +78,5 @@ AM_CPPFLAGS = \
 	$(GLIB_CFLAGS) \
 	$(GPLUGIN_CFLAGS) \
 	$(DEBUG_CFLAGS)
+
+SUBDIRS=tests
diff --git a/libpurple/protocols/oscar/tests/.hgignore b/libpurple/protocols/oscar/tests/.hgignore
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/oscar/tests/.hgignore
@@ -0,0 +1,7 @@
+syntax: regexp
+^test_oscar_util$
+
+syntax: glob
+*.log
+*.trs
+
diff --git a/libpurple/protocols/oscar/tests/Makefile.am b/libpurple/protocols/oscar/tests/Makefile.am
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/oscar/tests/Makefile.am
@@ -0,0 +1,23 @@
+include $(top_srcdir)/glib-tap.mk
+
+COMMON_LIBS=\
+	$(top_builddir)/libpurple/libpurple.la \
+	$(top_builddir)/libpurple/protocols/oscar/liboscar.la \
+	$(GLIB_LIBS) \
+	$(GPLUGIN_LIBS)
+
+test_programs=\
+	test_oscar_util
+
+test_oscar_util_SOURCES=test_oscar_util.c
+test_oscar_util_LDADD=$(COMMON_LIBS)
+
+AM_CPPFLAGS = \
+	-I$(top_srcdir)/libpurple \
+	-I$(top_builddir)/libpurple \
+	$(DEBUG_CFLAGS) \
+	$(GLIB_CFLAGS) \
+	$(GPLUGIN_CFLAGS) \
+	$(PLUGIN_CFLAGS) \
+	$(DBUS_CFLAGS) \
+	$(NSS_CFLAGS)
diff --git a/libpurple/tests/test_oscar_util.c b/libpurple/protocols/oscar/tests/test_oscar_util.c
rename from libpurple/tests/test_oscar_util.c
rename to libpurple/protocols/oscar/tests/test_oscar_util.c
--- a/libpurple/tests/test_oscar_util.c
+++ b/libpurple/protocols/oscar/tests/test_oscar_util.c
@@ -1,12 +1,11 @@
-#include <string.h>
+#include <glib.h>
 
-#include "tests.h"
-#include "../protocols/oscar/oscar.h"
+#include "../oscar.h"
 
-START_TEST(test_oscar_util_name_compare)
-{
-	size_t i;
-	const char *good[] = {
+static void
+test_oscar_util_name_compare(void) {
+	gsize i;
+	const gchar *good[] = {
 		"test",
 		"TEST",
 		"Test",
@@ -15,33 +14,29 @@ START_TEST(test_oscar_util_name_compare)
 		"test ",
 		"  T E   s T  "
 	};
-	const char *bad[] = {
+	const gchar *bad[] = {
 		"toast",
 		"test at example.com",
 		"test at aim.com"
 	};
 
-	for (i = 0; i < G_N_ELEMENTS(good); i++) {
-		ck_assert_int_eq(0, oscar_util_name_compare("test", good[i]));
-		ck_assert_int_eq(0, oscar_util_name_compare(good[i], "test"));
+	for(i = 0; i < G_N_ELEMENTS(good); i++) {
+		g_assert_cmpint(0, ==, oscar_util_name_compare("test", good[i]));
+		g_assert_cmpint(0, ==, oscar_util_name_compare(good[i], "test"));
 	}
-	for (i = 0; i < G_N_ELEMENTS(bad); i++) {
-		ck_assert_int_ne(0, oscar_util_name_compare("test", bad[i]));
-		ck_assert_int_ne(0, oscar_util_name_compare(bad[i], "test"));
+
+	for(i = 0; i < G_N_ELEMENTS(bad); i++) {
+		g_assert_cmpint(0, !=, oscar_util_name_compare("test", bad[i]));
+		g_assert_cmpint(0, !=, oscar_util_name_compare(bad[i], "test"));
 	}
 }
-END_TEST
 
-Suite *oscar_util_suite(void)
-{
-	Suite *s;
-	TCase *tc;
+gint
+main(gint argc, gchar **argv) {
+	g_test_init(&argc, &argv, NULL);
 
-	s = suite_create("OSCAR Utility Functions");
+	g_test_add_func("/oscar/util/name compare",
+	                test_oscar_util_name_compare);
 
-	tc = tcase_create("Convert IM from network format to HTML");
-	tcase_add_test(tc, test_oscar_util_name_compare);
-	suite_add_tcase(s, tc);
-
-	return s;
+	return g_test_run();
 }



More information about the Commits mailing list