testircisupportparser.cpp
1 //------------------------------------------------------------------------------
2 // testircisupportparser.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
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.
14 //
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., 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 
28 #define T_ASSERT_EQUAL(a, b) \
29  if ((a) != (b)) \
30  { \
31  return false; \
32  }
33 
34 bool TestIRCISupportPrefix::executeTest()
35 {
36  IRCISupportParser parser;
37  parser.appendLine("AWAYLEN=300 CALLERID=g CASEMAPPING=rfc1459 "
38  "CHANMODES=IXZbegw,k,FHJLdfjl,ABCDKMNOPQRSTcimnprstuz CHANNELLEN=64 "
39  "CHANTYPES=# CHARSET=ascii ELIST=MU ESILENCE EXCEPTS=e "
40  "EXTBAN=,ABCNOQRSTUcjmprsz FNC INVEX=I :are supported by this server");
41  parser.appendLine("KICKLEN=420 MAP MAXBANS=60 MAXCHANNELS=75 MAXPARA=32 "
42  "MAXTARGETS=20 MODES=20 NAMESX NETWORK=ExampleNetwork NICKLEN=20 OPERLOG "
43  "OVERRIDE PREFIX=(ohav)@%^+ :are supported by this server");
44  parser.appendLine("REMOVE SECURELIST SILENCE=32 SSL=109.74.206.218:6697 "
45  "STARTTLS STATUSMSG=@%+ TOPICLEN=420 UHNAMES USERIP VBANLIST WALLCHOPS "
46  "WALLVOICES WATCH=64 :are supported by this server");
47  parser.parse();
48  IRCUserPrefix prefixes = parser.userPrefixes();
49  T_ASSERT_EQUAL(prefixes.modeForPrefix('@'), 'o');
50  T_ASSERT_EQUAL(prefixes.modeForPrefix('%'), 'h');
51  T_ASSERT_EQUAL(prefixes.modeForPrefix('^'), 'a');
52  T_ASSERT_EQUAL(prefixes.modeForPrefix('+'), 'v');
53  T_ASSERT_EQUAL(prefixes.prefixForMode('o'), '@');
54  T_ASSERT_EQUAL(prefixes.prefixForMode('h'), '%');
55  T_ASSERT_EQUAL(prefixes.prefixForMode('a'), '^');
56  T_ASSERT_EQUAL(prefixes.prefixForMode('v'), '+');
57  return true;
58 }
59 
60 bool TestIRCISupportNoPrefix::executeTest()
61 {
62  IRCISupportParser parser;
63  parser.appendLine("AWAYLEN=300 :are supported by this server");
64  parser.parse();
65  IRCUserPrefix prefixes = parser.userPrefixes();
66  T_ASSERT_EQUAL(prefixes.modeForPrefix('@'), 'o');
67  T_ASSERT_EQUAL(prefixes.modeForPrefix('%'), 'h');
68  T_ASSERT_EQUAL(prefixes.modeForPrefix('^'), '\0');
69  T_ASSERT_EQUAL(prefixes.modeForPrefix('+'), 'v');
70  T_ASSERT_EQUAL(prefixes.prefixForMode('o'), '@');
71  T_ASSERT_EQUAL(prefixes.prefixForMode('h'), '%');
72  T_ASSERT_EQUAL(prefixes.prefixForMode('a'), '\0');
73  T_ASSERT_EQUAL(prefixes.prefixForMode('v'), '+');
74  return true;
75 }
One-to-one association of visible prefixes to user mode.
Definition: ircuserprefix.h:37