2 ircdtorture: an IRC RFC compliancy tester
3 (c) 2007 Jelmer Vernooij <jelmer@nl.linux.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "internals.h"
27 START_TEST(test_is_prefix)
28 struct irc_network_info info;
29 memset(&info, 0, sizeof(info));
30 network_info_parse(&info, "PREFIX=(qaohv)~&@%+");
31 fail_unless(is_prefix('&', &info));
32 fail_if(is_prefix(' ', &info));
33 network_info_parse(&info, "PREFIX=");
34 fail_if(is_prefix('&', &info));
37 START_TEST(test_get_prefix_by_mode)
38 struct irc_network_info info;
39 memset(&info, 0, sizeof(info));
40 network_info_parse(&info, "PREFIX=(qaohv)~&@%+");
41 fail_unless(get_prefix_by_mode('a', &info) == '&');
42 fail_unless(get_prefix_by_mode('q', &info) == '~');
43 fail_unless(get_prefix_by_mode('h', &info) == '%');
44 fail_unless(get_prefix_by_mode('!', &info) == ' ');
45 network_info_parse(&info, "PREFIX=(qaohv~&@%+");
46 fail_unless(get_prefix_by_mode('a', &info) == '&');
49 START_TEST(test_get_charset)
50 struct irc_network_info info;
51 memset(&info, 0, sizeof(info));
52 network_info_parse(&info, "CHARSET=ascii");
53 fail_unless(!strcmp(get_charset(&info), "ascii"));
56 START_TEST(test_get_charset_default)
57 struct irc_network_info *info;
58 info = network_info_init();
59 fail_unless(get_charset(info) == NULL);
62 START_TEST(test_chanmode_type_default)
63 fail_unless(network_chanmode_type('I', NULL) == CHANMODE_NICKLIST);
64 fail_unless(network_chanmode_type('k', NULL) == CHANMODE_SETTING);
65 fail_unless(network_chanmode_type('z', NULL) == CHANMODE_UNKNOWN);
66 fail_unless(network_chanmode_type('m', NULL) == CHANMODE_BOOL);
67 fail_unless(network_chanmode_type('l', NULL) == CHANMODE_OPT_SETTING);
70 START_TEST(test_chanmode_type_lookup)
71 struct irc_network_info ni;
72 memset(&ni, 0, sizeof(ni));
73 network_info_parse(&ni, "CHANMODES=b,k,l,ciLmMnOprRst");
74 fail_unless(network_chanmode_type('I', &ni) == CHANMODE_UNKNOWN);
75 fail_unless(network_chanmode_type('k', &ni) == CHANMODE_SETTING);
76 fail_unless(network_chanmode_type('z', &ni) == CHANMODE_UNKNOWN);
77 fail_unless(network_chanmode_type('m', &ni) == CHANMODE_BOOL);
78 fail_unless(network_chanmode_type('l', &ni) == CHANMODE_OPT_SETTING);
79 fail_unless(network_chanmode_type('w', &ni) == CHANMODE_UNKNOWN);
82 Suite *networkinfo_suite()
84 Suite *s = suite_create("networkinfo");
85 TCase *tc_core = tcase_create("core");
86 suite_add_tcase(s, tc_core);
87 tcase_add_test(tc_core, test_is_prefix);
88 tcase_add_test(tc_core, test_get_prefix_by_mode);
89 tcase_add_test(tc_core, test_get_charset);
90 tcase_add_test(tc_core, test_get_charset_default);
91 tcase_add_test(tc_core, test_chanmode_type_default);
92 tcase_add_test(tc_core, test_chanmode_type_lookup);