pidgin: 6fa5711e: Add unit tests for oscar_util_name_compa...

markdoliner at pidgin.im markdoliner at pidgin.im
Sun Feb 13 22:16:03 EST 2011


----------------------------------------------------------------------
Revision: 6fa5711ed4fe6e958f6cb9beff4fdb20c26b037d
Parent:   53e17627a3ac9c40d0047fbc5efb15aa909c1f06
Author:   markdoliner at pidgin.im
Date:     02/13/11 22:10:09
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6fa5711ed4fe6e958f6cb9beff4fdb20c26b037d

Changelog: 

Add unit tests for oscar_util_name_compare.  I suspected that this
function missed a few cases, but I was wrong, it's good.
I used ck_assert_int_eq and ck_assert_ne, which look like they
might be newer API.  If that causes a problem we can change them
to fail_if and fail_unless

Changes against parent 53e17627a3ac9c40d0047fbc5efb15aa909c1f06

  added    libpurple/tests/test_oscar_util.c
  patched  libpurple/tests/Makefile.am
  patched  libpurple/tests/check_libpurple.c
  patched  libpurple/tests/tests.h

-------------- next part --------------
============================================================
--- libpurple/tests/Makefile.am	b86fb99070acfd4e786b0fe1ee5845132fa5a3f6
+++ libpurple/tests/Makefile.am	2002936d068a75434265dea13650a4063ba1223f
@@ -14,6 +14,7 @@ check_libpurple_SOURCES=\
 		test_jabber_digest_md5.c \
 		test_jabber_jutil.c \
 		test_jabber_scram.c \
+		test_oscar_util.c \
 		test_qq.c \
 		test_yahoo_util.c \
 		test_util.c \
@@ -30,6 +31,7 @@ check_libpurple_LDADD=\
 
 check_libpurple_LDADD=\
 		$(top_builddir)/libpurple/protocols/jabber/libjabber.la \
+		$(top_builddir)/libpurple/protocols/oscar/liboscar.la \
 		$(top_builddir)/libpurple/protocols/qq/libqq_tmp.la \
 		$(top_builddir)/libpurple/protocols/yahoo/libymsg.la \
 		$(top_builddir)/libpurple/libpurple.la \
============================================================
--- libpurple/tests/check_libpurple.c	d345c0eeaccf9aec715c22cb9d71448f4cb18339
+++ libpurple/tests/check_libpurple.c	de77368425528be098ddca78409975e3b57ee739
@@ -88,6 +88,7 @@ int main(void)
 	srunner_add_suite(sr, jabber_digest_md5_suite());
 	srunner_add_suite(sr, jabber_jutil_suite());
 	srunner_add_suite(sr, jabber_scram_suite());
+	srunner_add_suite(sr, oscar_util_suite());
 	srunner_add_suite(sr, qq_suite());
 	srunner_add_suite(sr, yahoo_util_suite());
 	srunner_add_suite(sr, util_suite());
============================================================
--- libpurple/tests/tests.h	f8644231baaadb435974d502bf96358113db3dcf
+++ libpurple/tests/tests.h	2f9a3915563e8819022cb37387dd7a80948e0869
@@ -13,6 +13,7 @@ Suite * jabber_scram_suite(void);
 Suite * jabber_digest_md5_suite(void);
 Suite * jabber_jutil_suite(void);
 Suite * jabber_scram_suite(void);
+Suite * oscar_util_suite(void);
 Suite * qq_suite(void);
 Suite * yahoo_util_suite(void);
 Suite * util_suite(void);
============================================================
--- /dev/null	
+++ libpurple/tests/test_oscar_util.c	8f56ecfb4781f4793f630abe8e99ab6eb136a0dd
@@ -0,0 +1,47 @@
+#include <string.h>
+
+#include "tests.h"
+#include "../protocols/oscar/oscar.h"
+
+START_TEST(test_oscar_util_name_compare)
+{
+	int i;
+	const char *good[] = {
+		"test",
+		"TEST",
+		"Test",
+		"teSt",
+		" TesT",
+		"test ",
+		"  T E   s T  "
+	};
+	const char *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(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"));
+	}
+}
+END_TEST
+
+Suite *oscar_util_suite(void)
+{
+	Suite *s;
+	TCase *tc;
+
+	s = suite_create("OSCAR Utility Functions");
+
+	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;
+}


More information about the Commits mailing list