|
@@ -22,8 +22,10 @@
|
22
|
22
|
package com.dmdirc.parser;
|
23
|
23
|
|
24
|
24
|
import com.dmdirc.harness.parser.TestParser;
|
|
25
|
+
|
25
|
26
|
import java.util.HashMap;
|
26
|
27
|
import java.util.Map;
|
|
28
|
+
|
27
|
29
|
import org.junit.Ignore;
|
28
|
30
|
import org.junit.Test;
|
29
|
31
|
import static org.junit.Assert.*;
|
|
@@ -151,6 +153,21 @@ public class ChannelInfoTest {
|
151
|
153
|
assertEquals(0, parser.sentLines.size());
|
152
|
154
|
}
|
153
|
155
|
|
|
156
|
+ @Test
|
|
157
|
+ public void testGetSetParamMode() {
|
|
158
|
+ final TestParser parser = new TestParser();
|
|
159
|
+ final ChannelInfo info = getChannelInfo(parser);
|
|
160
|
+ parser.injectLine(":server 324 nick #DMDirc_testing +k lalala");
|
|
161
|
+ parser.sentLines.clear();
|
|
162
|
+
|
|
163
|
+ assertEquals("lalala", info.getModeParam('k'));
|
|
164
|
+ assertEquals("", info.getModeParam('z'));
|
|
165
|
+
|
|
166
|
+ parser.injectLine(":server MODE #DMDirc_testing -k *");
|
|
167
|
+
|
|
168
|
+ assertEquals("", info.getModeParam('k'));
|
|
169
|
+ }
|
|
170
|
+
|
154
|
171
|
@Test
|
155
|
172
|
public void testModeSendFull() {
|
156
|
173
|
final TestParser parser = new TestParser();
|
|
@@ -164,8 +181,8 @@ public class ChannelInfoTest {
|
164
|
181
|
info.alterMode(true, 't', null);
|
165
|
182
|
info.alterMode(true, 'r', null);
|
166
|
183
|
|
167
|
|
- assertTrue("Parser must send modes as soon as the max number is reached",
|
168
|
|
- parser.sentLines.size() == 1);
|
|
184
|
+ assertEquals("Parser must send modes as soon as the max number is reached",
|
|
185
|
+ 1, parser.sentLines.size());
|
169
|
186
|
final String modes = getModes(parser.sentLines.get(0));
|
170
|
187
|
|
171
|
188
|
assertTrue(modes.indexOf('i') > -1);
|
|
@@ -191,8 +208,8 @@ public class ChannelInfoTest {
|
191
|
208
|
info.alterMode(true, 'N', null);
|
192
|
209
|
info.sendModes();
|
193
|
210
|
|
194
|
|
- assertTrue("sendModes must send modes",
|
195
|
|
- parser.sentLines.size() == 2);
|
|
211
|
+ assertEquals("sendModes must send modes",
|
|
212
|
+ 2, parser.sentLines.size());
|
196
|
213
|
|
197
|
214
|
final String modes = getModes(parser.sentLines.get(0))
|
198
|
215
|
+ getModes(parser.sentLines.get(1));
|
|
@@ -219,8 +236,8 @@ public class ChannelInfoTest {
|
219
|
236
|
info.alterMode(false, 'i', null);
|
220
|
237
|
info.sendModes();
|
221
|
238
|
|
222
|
|
- assertTrue("sendModes must send modes",
|
223
|
|
- parser.sentLines.size() == 1);
|
|
239
|
+ assertEquals("sendModes must send modes in one go",
|
|
240
|
+ 1, parser.sentLines.size());
|
224
|
241
|
|
225
|
242
|
final String modes = getModes(parser.sentLines.get(0));
|
226
|
243
|
|
|
@@ -241,8 +258,8 @@ public class ChannelInfoTest {
|
241
|
258
|
info.alterMode(true, 'n', null);
|
242
|
259
|
info.sendModes();
|
243
|
260
|
|
244
|
|
- assertTrue("sendModes must send modes",
|
245
|
|
- parser.sentLines.size() == 1);
|
|
261
|
+ assertEquals("sendModes must send modes in one go",
|
|
262
|
+ 1, parser.sentLines.size());
|
246
|
263
|
|
247
|
264
|
final String modes = getModes(parser.sentLines.get(0));
|
248
|
265
|
|
|
@@ -252,6 +269,58 @@ public class ChannelInfoTest {
|
252
|
269
|
assertTrue(modes.indexOf('m') > -1);
|
253
|
270
|
}
|
254
|
271
|
|
|
272
|
+ @Test
|
|
273
|
+ public void testModeUnsetKey() {
|
|
274
|
+ final TestParser parser = new TestParser();
|
|
275
|
+ final ChannelInfo info = getChannelInfo(parser);
|
|
276
|
+ parser.injectLine(":server 324 nick #DMDirc_testing +k lalala");
|
|
277
|
+ parser.sentLines.clear();
|
|
278
|
+
|
|
279
|
+ info.alterMode(true, 'k', "foobar");
|
|
280
|
+ info.sendModes();
|
|
281
|
+
|
|
282
|
+ assertEquals("sendModes must send modes in one go",
|
|
283
|
+ 1, parser.sentLines.size());
|
|
284
|
+ assertEquals("Setting +k must set -k first",
|
|
285
|
+ "-k+k lalala foobar", getModes(parser.sentLines.get(0)));
|
|
286
|
+ }
|
|
287
|
+
|
|
288
|
+ @Test @Ignore
|
|
289
|
+ public void testModeUnsetKeyMultiple() {
|
|
290
|
+ final TestParser parser = new TestParser();
|
|
291
|
+ final ChannelInfo info = getChannelInfo(parser);
|
|
292
|
+ parser.injectLine(":server 324 nick #DMDirc_testing +k lalala");
|
|
293
|
+ parser.sentLines.clear();
|
|
294
|
+
|
|
295
|
+ info.alterMode(true, 'k', "foobar");
|
|
296
|
+ info.alterMode(true, 'k', "blahblah");
|
|
297
|
+ info.alterMode(true, 'k', "unittest");
|
|
298
|
+ info.sendModes();
|
|
299
|
+
|
|
300
|
+ assertEquals("sendModes must send modes in one go",
|
|
301
|
+ 1, parser.sentLines.size());
|
|
302
|
+ assertEquals("Setting a mode multiple times should have no effect",
|
|
303
|
+ "-k+k lalala unittest", getModes(parser.sentLines.get(0)));
|
|
304
|
+ }
|
|
305
|
+
|
|
306
|
+ @Test @Ignore
|
|
307
|
+ public void testModeUnsetLimitMultiple() {
|
|
308
|
+ final TestParser parser = new TestParser();
|
|
309
|
+ final ChannelInfo info = getChannelInfo(parser);
|
|
310
|
+ parser.injectLine(":server 324 nick #DMDirc_testing +l 73");
|
|
311
|
+ parser.sentLines.clear();
|
|
312
|
+
|
|
313
|
+ info.alterMode(true, 'l', "74");
|
|
314
|
+ info.alterMode(true, 'l', "75");
|
|
315
|
+ info.alterMode(true, 'l', "76");
|
|
316
|
+ info.sendModes();
|
|
317
|
+
|
|
318
|
+ assertEquals("sendModes must send modes in one go",
|
|
319
|
+ 1, parser.sentLines.size());
|
|
320
|
+ assertEquals("Setting a mode multiple times should have no effect",
|
|
321
|
+ "+l 76", getModes(parser.sentLines.get(0)));
|
|
322
|
+ }
|
|
323
|
+
|
255
|
324
|
private String getModes(final String line) {
|
256
|
325
|
final String res = line.substring("MODE #DMDirc_testing ".length());
|
257
|
326
|
|