comparison libpurple/tests/test_oscar_util.c @ 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
children
comparison
equal deleted inserted replaced
31652:258fec7797b9 31653:f1874b08b3f9
1 #include <string.h>
2
3 #include "tests.h"
4 #include "../protocols/oscar/oscar.h"
5
6 START_TEST(test_oscar_util_name_compare)
7 {
8 int i;
9 const char *good[] = {
10 "test",
11 "TEST",
12 "Test",
13 "teSt",
14 " TesT",
15 "test ",
16 " T E s T "
17 };
18 const char *bad[] = {
19 "toast",
20 "test@example.com",
21 "test@aim.com"
22 };
23
24 for (i = 0; i < G_N_ELEMENTS(good); i++) {
25 ck_assert_int_eq(0, oscar_util_name_compare("test", good[i]));
26 ck_assert_int_eq(0, oscar_util_name_compare(good[i], "test"));
27 }
28 for (i = 0; i < G_N_ELEMENTS(bad); i++) {
29 ck_assert_int_ne(0, oscar_util_name_compare("test", bad[i]));
30 ck_assert_int_ne(0, oscar_util_name_compare(bad[i], "test"));
31 }
32 }
33 END_TEST
34
35 Suite *oscar_util_suite(void)
36 {
37 Suite *s;
38 TCase *tc;
39
40 s = suite_create("OSCAR Utility Functions");
41
42 tc = tcase_create("Convert IM from network format to HTML");
43 tcase_add_test(tc, test_oscar_util_name_compare);
44 suite_add_tcase(s, tc);
45
46 return s;
47 }