Mercurial > pidgin.yaz
changeset 31653:f1874b08b3f9
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
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 14 Feb 2011 03:10:09 +0000 |
parents | 258fec7797b9 |
children | b39a2bd81566 |
files | libpurple/tests/Makefile.am libpurple/tests/check_libpurple.c libpurple/tests/test_oscar_util.c libpurple/tests/tests.h |
diffstat | 4 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/tests/Makefile.am Mon Feb 14 01:01:37 2011 +0000 +++ b/libpurple/tests/Makefile.am Mon Feb 14 03:10:09 2011 +0000 @@ -14,6 +14,7 @@ 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=\ $(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 \
--- a/libpurple/tests/check_libpurple.c Mon Feb 14 01:01:37 2011 +0000 +++ b/libpurple/tests/check_libpurple.c Mon Feb 14 03:10:09 2011 +0000 @@ -88,6 +88,7 @@ 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());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/tests/test_oscar_util.c Mon Feb 14 03:10:09 2011 +0000 @@ -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@example.com", + "test@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; +}
--- a/libpurple/tests/tests.h Mon Feb 14 01:01:37 2011 +0000 +++ b/libpurple/tests/tests.h Mon Feb 14 03:10:09 2011 +0000 @@ -13,6 +13,7 @@ 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);