testircisupportparser.cpp
1 //------------------------------------------------------------------------------
2 // testircisupportparser.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2014 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "testircisupportparser.h"
24 
25 #include "irc/entities/ircuserprefix.h"
26 #include "irc/ircisupportparser.h"
27 #include "tests/asserts.h"
28 
29 bool TestIRCISupportPrefix::executeTest()
30 {
31  IRCISupportParser parser;
32  parser.appendLine("AWAYLEN=300 CALLERID=g CASEMAPPING=rfc1459 "
33  "CHANMODES=IXZbegw,k,FHJLdfjl,ABCDKMNOPQRSTcimnprstuz CHANNELLEN=64 "
34  "CHANTYPES=# CHARSET=ascii ELIST=MU ESILENCE EXCEPTS=e "
35  "EXTBAN=,ABCNOQRSTUcjmprsz FNC INVEX=I :are supported by this server");
36  parser.appendLine("KICKLEN=420 MAP MAXBANS=60 MAXCHANNELS=75 MAXPARA=32 "
37  "MAXTARGETS=20 MODES=20 NAMESX NETWORK=ExampleNetwork NICKLEN=20 OPERLOG "
38  "OVERRIDE PREFIX=(ohav)@%^+ :are supported by this server");
39  parser.appendLine("REMOVE SECURELIST SILENCE=32 SSL=109.74.206.218:6697 "
40  "STARTTLS STATUSMSG=@%+ TOPICLEN=420 UHNAMES USERIP VBANLIST WALLCHOPS "
41  "WALLVOICES WATCH=64 :are supported by this server");
42  parser.parse();
43  IRCUserPrefix prefixes = parser.userPrefixes();
44  T_ASSERT_EQUAL(prefixes.modeForPrefix('@'), 'o');
45  T_ASSERT_EQUAL(prefixes.modeForPrefix('%'), 'h');
46  T_ASSERT_EQUAL(prefixes.modeForPrefix('^'), 'a');
47  T_ASSERT_EQUAL(prefixes.modeForPrefix('+'), 'v');
48  T_ASSERT_EQUAL(prefixes.prefixForMode('o'), '@');
49  T_ASSERT_EQUAL(prefixes.prefixForMode('h'), '%');
50  T_ASSERT_EQUAL(prefixes.prefixForMode('a'), '^');
51  T_ASSERT_EQUAL(prefixes.prefixForMode('v'), '+');
52  return true;
53 }
54 
55 bool TestIRCISupportNoPrefix::executeTest()
56 {
57  IRCISupportParser parser;
58  parser.appendLine("AWAYLEN=300 :are supported by this server");
59  parser.parse();
60  IRCUserPrefix prefixes = parser.userPrefixes();
61  T_ASSERT_EQUAL(prefixes.modeForPrefix('@'), 'o');
62  T_ASSERT_EQUAL(prefixes.modeForPrefix('%'), 'h');
63  T_ASSERT_EQUAL(prefixes.modeForPrefix('^'), '\0');
64  T_ASSERT_EQUAL(prefixes.modeForPrefix('+'), 'v');
65  T_ASSERT_EQUAL(prefixes.prefixForMode('o'), '@');
66  T_ASSERT_EQUAL(prefixes.prefixForMode('h'), '%');
67  T_ASSERT_EQUAL(prefixes.prefixForMode('a'), '\0');
68  T_ASSERT_EQUAL(prefixes.prefixForMode('v'), '+');
69  return true;
70 }