2 * Copyright 2020 Ed Kellett
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
24 #include "client_util.h"
25 #include "ircd_util.h"
26 #include "tap/basic.h"
28 #define MSG "%s:%d (%s)", __FILE__, __LINE__, __FUNCTION__
30 static struct Channel
*channel
;
31 static struct Client
*client
;
33 static hook_data_channel_approval chmode_hdata
;
36 chmode_access_hook(void *data_
)
38 hook_data_channel_approval
*data
= data_
;
43 test_chmode_parse(void)
45 add_hook_prio("get_channel_access", chmode_access_hook
, HOOK_MONITOR
);
47 set_channel_mode(client
, client
, channel
, NULL
, 2, (const char *[]){"o", "foo"});
48 is_string("+o foo", chmode_hdata
.modestr
, MSG
);
50 set_channel_mode(client
, client
, channel
, NULL
, 3, (const char *[]){"o", "foo", "bar"});
51 is_string("+o foo", chmode_hdata
.modestr
, MSG
);
53 chmode_hdata
.modestr
= NULL
;
54 set_channel_mode(client
, client
, channel
, NULL
, 3, (const char *[]){"+-=+++--+", "foo", "bar"});
55 is_bool(true, chmode_hdata
.modestr
== NULL
, MSG
);
57 set_channel_mode(client
, client
, channel
, NULL
, 1, (const char *[]){"b"});
58 is_string("=b", chmode_hdata
.modestr
, MSG
);
60 set_channel_mode(client
, client
, channel
, NULL
, 2, (const char *[]){"bb", "foo"});
61 is_string("+b=b foo", chmode_hdata
.modestr
, MSG
);
63 set_channel_mode(client
, client
, channel
, NULL
, 1, (const char *[]){"iqiqiqiq"});
64 is_string("+i=q+i=q+i=q+i=q", chmode_hdata
.modestr
, MSG
);
66 remove_hook("get_channel_access", chmode_access_hook
);
72 channel
= make_channel();
73 client
= make_local_person();
77 main(int argc
, char *argv
[])
81 ircd_util_init(__FILE__
);