|
@@ -0,0 +1,71 @@
|
|
1
|
+/*
|
|
2
|
+ * ProgramErrorTest.java
|
|
3
|
+ * JUnit based test
|
|
4
|
+ *
|
|
5
|
+ * Created on 08 April 2007, 13:20
|
|
6
|
+ */
|
|
7
|
+
|
|
8
|
+package com.dmdirc;
|
|
9
|
+
|
|
10
|
+import com.dmdirc.ui.interfaces.InputWindow;
|
|
11
|
+import junit.framework.*;
|
|
12
|
+
|
|
13
|
+public class WritableFrameContainerTest extends TestCase {
|
|
14
|
+
|
|
15
|
+ public WritableFrameContainerTest(String testName) {
|
|
16
|
+ super(testName);
|
|
17
|
+ }
|
|
18
|
+
|
|
19
|
+ public void testGetNumLines() {
|
|
20
|
+ final WritableFrameContainer container10 = new BasicWritableFrameContainer(10);
|
|
21
|
+
|
|
22
|
+ final int res1a = container10.getNumLines("0123456789");
|
|
23
|
+ final int res1b = container10.getNumLines("");
|
|
24
|
+ final int res1c = container10.getNumLines("qaaa");
|
|
25
|
+ final int res2a = container10.getNumLines("01234567890");
|
|
26
|
+ final int res2b = container10.getNumLines("\n");
|
|
27
|
+ final int res2c = container10.getNumLines("\r\n");
|
|
28
|
+
|
|
29
|
+ assertEquals(1, res1a);
|
|
30
|
+ assertEquals(1, res1b);
|
|
31
|
+ assertEquals(1, res1c);
|
|
32
|
+
|
|
33
|
+ assertEquals(2, res2a);
|
|
34
|
+ assertEquals(2, res2b);
|
|
35
|
+ assertEquals(2, res2c);
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+}
|
|
39
|
+
|
|
40
|
+class BasicWritableFrameContainer extends WritableFrameContainer {
|
|
41
|
+
|
|
42
|
+ private final int lineLength;
|
|
43
|
+
|
|
44
|
+ public BasicWritableFrameContainer(final int lineLength) {
|
|
45
|
+ this.lineLength = lineLength;
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ public void sendLine(String line) {
|
|
49
|
+ // Do nothing
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ public InputWindow getFrame() {
|
|
53
|
+ return null;
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ public int getMaxLineLength() {
|
|
57
|
+ return lineLength;
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ public String toString() {
|
|
61
|
+ return null;
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ public void close() {
|
|
65
|
+ // Do nothing
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ public Server getServer() {
|
|
69
|
+ return null;
|
|
70
|
+ }
|
|
71
|
+}
|