Browse Source

Style fixes

Change-Id: Ifbff0f1a0d193403613a0d444443dd1c45d1acc2
Reviewed-on: http://gerrit.dmdirc.com/1334
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4^0
Chris Smith 14 years ago
parent
commit
0378573a34
2 changed files with 47 additions and 47 deletions
  1. 30
    30
      test/com/dmdirc/util/ConfigFileTest.java
  2. 17
    17
      test/com/dmdirc/util/MapListTest.java

+ 30
- 30
test/com/dmdirc/util/ConfigFileTest.java View File

33
 import static org.junit.Assert.*;
33
 import static org.junit.Assert.*;
34
 
34
 
35
 public class ConfigFileTest {
35
 public class ConfigFileTest {
36
-    
36
+
37
     private ConfigFile cf;
37
     private ConfigFile cf;
38
-    
38
+
39
     @Before
39
     @Before
40
     public void setUp() throws Exception {
40
     public void setUp() throws Exception {
41
         cf = new ConfigFile(getClass().getResourceAsStream("test2.txt"));
41
         cf = new ConfigFile(getClass().getResourceAsStream("test2.txt"));
42
-    }    
42
+    }
43
 
43
 
44
     @Test
44
     @Test
45
     public void testRead() throws IOException, InvalidConfigFileException {
45
     public void testRead() throws IOException, InvalidConfigFileException {
50
     public void testWrite() throws IOException {
50
     public void testWrite() throws IOException {
51
         cf.write();
51
         cf.write();
52
     }
52
     }
53
-    
53
+
54
     @Test
54
     @Test
55
     public void testDomains() throws IOException, InvalidConfigFileException {
55
     public void testDomains() throws IOException, InvalidConfigFileException {
56
         cf.read();
56
         cf.read();
60
         assertTrue(cf.hasDomain("section one"));
60
         assertTrue(cf.hasDomain("section one"));
61
         assertFalse(cf.hasDomain("random domain"));
61
         assertFalse(cf.hasDomain("random domain"));
62
     }
62
     }
63
-    
63
+
64
     @Test
64
     @Test
65
     public void testKeyDomains() throws IOException, InvalidConfigFileException {
65
     public void testKeyDomains() throws IOException, InvalidConfigFileException {
66
         cf.read();
66
         cf.read();
68
         assertFalse(cf.isKeyDomain("section one point one"));
68
         assertFalse(cf.isKeyDomain("section one point one"));
69
         assertFalse(cf.isKeyDomain("section two"));
69
         assertFalse(cf.isKeyDomain("section two"));
70
     }
70
     }
71
-    
71
+
72
     @Test
72
     @Test
73
     public void testFlatDomains() throws IOException, InvalidConfigFileException {
73
     public void testFlatDomains() throws IOException, InvalidConfigFileException {
74
         cf.read();
74
         cf.read();
76
         assertTrue(cf.isFlatDomain("section alpha"));
76
         assertTrue(cf.isFlatDomain("section alpha"));
77
         assertTrue(cf.isFlatDomain("section one point one"));
77
         assertTrue(cf.isFlatDomain("section one point one"));
78
         assertFalse(cf.isFlatDomain("section one"));
78
         assertFalse(cf.isFlatDomain("section one"));
79
-        assertFalse(cf.hasDomain("random domain"));        
79
+        assertFalse(cf.hasDomain("random domain"));
80
     }
80
     }
81
-    
81
+
82
     @Test
82
     @Test
83
     public void testFlatDomainContents() throws IOException, InvalidConfigFileException {
83
     public void testFlatDomainContents() throws IOException, InvalidConfigFileException {
84
         cf.read();
84
         cf.read();
86
         assertEquals("line 1", cf.getFlatDomain("section alpha").get(0));
86
         assertEquals("line 1", cf.getFlatDomain("section alpha").get(0));
87
         assertEquals("line 2", cf.getFlatDomain("section alpha").get(1));
87
         assertEquals("line 2", cf.getFlatDomain("section alpha").get(1));
88
     }
88
     }
89
-    
89
+
90
     @Test
90
     @Test
91
     public void testKeyDomainContents() throws IOException, InvalidConfigFileException {
91
     public void testKeyDomainContents() throws IOException, InvalidConfigFileException {
92
         cf.read();
92
         cf.read();
95
         assertEquals("two", cf.getKeyDomain("section one").get("2"));
95
         assertEquals("two", cf.getKeyDomain("section one").get("2"));
96
         assertEquals("three", cf.getKeyDomain("section one").get("3"));
96
         assertEquals("three", cf.getKeyDomain("section one").get("3"));
97
     }
97
     }
98
-    
98
+
99
     @Test
99
     @Test
100
     public void testColons() throws IOException, InvalidConfigFileException {
100
     public void testColons() throws IOException, InvalidConfigFileException {
101
         final File file = File.createTempFile("DMDirc.unittest", null);
101
         final File file = File.createTempFile("DMDirc.unittest", null);
106
         data.put("test3", "hello:");
106
         data.put("test3", "hello:");
107
         config.addDomain("test", data);
107
         config.addDomain("test", data);
108
         config.write();
108
         config.write();
109
-        
109
+
110
         config = new ConfigFile(file);
110
         config = new ConfigFile(file);
111
         config.read();
111
         config.read();
112
-        
112
+
113
         assertTrue(config.isKeyDomain("test"));
113
         assertTrue(config.isKeyDomain("test"));
114
         data = config.getKeyDomain("test");
114
         data = config.getKeyDomain("test");
115
         assertEquals("hello", data.get("test1"));
115
         assertEquals("hello", data.get("test1"));
116
         assertEquals("hello", data.get("test:2"));
116
         assertEquals("hello", data.get("test:2"));
117
         assertEquals("hello:", data.get("test3"));
117
         assertEquals("hello:", data.get("test3"));
118
     }
118
     }
119
-    
119
+
120
     @Test
120
     @Test
121
     public void testEquals() throws IOException, InvalidConfigFileException {
121
     public void testEquals() throws IOException, InvalidConfigFileException {
122
         final File file = File.createTempFile("DMDirc.unittest", null);
122
         final File file = File.createTempFile("DMDirc.unittest", null);
127
         data.put("test3", "hello=");
127
         data.put("test3", "hello=");
128
         config.addDomain("test", data);
128
         config.addDomain("test", data);
129
         config.write();
129
         config.write();
130
-        
130
+
131
         config = new ConfigFile(file);
131
         config = new ConfigFile(file);
132
         config.read();
132
         config.read();
133
-        
133
+
134
         assertTrue(config.isKeyDomain("test"));
134
         assertTrue(config.isKeyDomain("test"));
135
         data = config.getKeyDomain("test");
135
         data = config.getKeyDomain("test");
136
         assertEquals("hello", data.get("test1"));
136
         assertEquals("hello", data.get("test1"));
137
         assertEquals("hello", data.get("test=2"));
137
         assertEquals("hello", data.get("test=2"));
138
         assertEquals("hello=", data.get("test3"));
138
         assertEquals("hello=", data.get("test3"));
139
     }
139
     }
140
-    
140
+
141
     @Test
141
     @Test
142
     public void testNewlines() throws IOException, InvalidConfigFileException {
142
     public void testNewlines() throws IOException, InvalidConfigFileException {
143
         final File file = File.createTempFile("DMDirc.unittest", null);
143
         final File file = File.createTempFile("DMDirc.unittest", null);
149
         data.put("test4", "hello\r\ngoodbye");
149
         data.put("test4", "hello\r\ngoodbye");
150
         config.addDomain("test", data);
150
         config.addDomain("test", data);
151
         config.write();
151
         config.write();
152
-        
152
+
153
         config = new ConfigFile(file);
153
         config = new ConfigFile(file);
154
         config.read();
154
         config.read();
155
-        
155
+
156
         assertTrue(config.isKeyDomain("test"));
156
         assertTrue(config.isKeyDomain("test"));
157
         data = config.getKeyDomain("test");
157
         data = config.getKeyDomain("test");
158
         assertEquals("hello", data.get("test1"));
158
         assertEquals("hello", data.get("test1"));
160
         assertEquals("hello\n", data.get("test3"));
160
         assertEquals("hello\n", data.get("test3"));
161
         assertEquals("hello\r\ngoodbye", data.get("test4"));
161
         assertEquals("hello\r\ngoodbye", data.get("test4"));
162
     }
162
     }
163
-    
163
+
164
     @Test
164
     @Test
165
     public void testBackslash() throws IOException, InvalidConfigFileException {
165
     public void testBackslash() throws IOException, InvalidConfigFileException {
166
         final File file = File.createTempFile("DMDirc.unittest", null);
166
         final File file = File.createTempFile("DMDirc.unittest", null);
171
         data.put("test3\\", "hello");
171
         data.put("test3\\", "hello");
172
         config.addDomain("test", data);
172
         config.addDomain("test", data);
173
         config.write();
173
         config.write();
174
-        
174
+
175
         config = new ConfigFile(file);
175
         config = new ConfigFile(file);
176
         config.read();
176
         config.read();
177
-        
177
+
178
         assertTrue(config.isKeyDomain("test"));
178
         assertTrue(config.isKeyDomain("test"));
179
         data = config.getKeyDomain("test");
179
         data = config.getKeyDomain("test");
180
         assertEquals("hello\\", data.get("test1"));
180
         assertEquals("hello\\", data.get("test1"));
181
         assertEquals("\\nhello", data.get("test2"));
181
         assertEquals("\\nhello", data.get("test2"));
182
         assertEquals("hello", data.get("test3\\"));
182
         assertEquals("hello", data.get("test3\\"));
183
     }
183
     }
184
-    
184
+
185
     @Test
185
     @Test
186
     public void testHash() throws IOException, InvalidConfigFileException {
186
     public void testHash() throws IOException, InvalidConfigFileException {
187
         final File file = File.createTempFile("DMDirc.unittest", null);
187
         final File file = File.createTempFile("DMDirc.unittest", null);
192
         data.put("test3", "#hello");
192
         data.put("test3", "#hello");
193
         config.addDomain("test", data);
193
         config.addDomain("test", data);
194
         config.write();
194
         config.write();
195
-        
195
+
196
         config = new ConfigFile(file);
196
         config = new ConfigFile(file);
197
         config.read();
197
         config.read();
198
-        
198
+
199
         assertTrue(config.isKeyDomain("test"));
199
         assertTrue(config.isKeyDomain("test"));
200
         data = config.getKeyDomain("test");
200
         data = config.getKeyDomain("test");
201
         assertEquals("hello", data.get("test1#"));
201
         assertEquals("hello", data.get("test1#"));
202
         assertEquals("hello", data.get("#test2"));
202
         assertEquals("hello", data.get("#test2"));
203
         assertEquals("#hello", data.get("test3"));
203
         assertEquals("#hello", data.get("test3"));
204
-    }    
205
-    
204
+    }
205
+
206
     @Test
206
     @Test
207
     public void testEscape() {
207
     public void testEscape() {
208
         final String input = "blah blah\\foo\r\nbar=:";
208
         final String input = "blah blah\\foo\r\nbar=:";
209
         final String output = "blah blah\\\\foo\\r\\nbar\\=\\:";
209
         final String output = "blah blah\\\\foo\\r\\nbar\\=\\:";
210
         assertEquals(output, ConfigFile.escape(input));
210
         assertEquals(output, ConfigFile.escape(input));
211
     }
211
     }
212
-    
212
+
213
     @Test
213
     @Test
214
     public void testUnescape() {
214
     public void testUnescape() {
215
         final String input = "blah blah\\foo\r\nbar=:";
215
         final String input = "blah blah\\foo\r\nbar=:";
216
         assertEquals(input, ConfigFile.unescape(ConfigFile.escape(input)));
216
         assertEquals(input, ConfigFile.unescape(ConfigFile.escape(input)));
217
     }
217
     }
218
-    
218
+
219
     @Test
219
     @Test
220
     public void testDelete() throws IOException {
220
     public void testDelete() throws IOException {
221
         final File file = File.createTempFile("DMDirc_unittest", null);
221
         final File file = File.createTempFile("DMDirc_unittest", null);
225
         config.delete();
225
         config.delete();
226
         assertFalse(file.exists());
226
         assertFalse(file.exists());
227
     }
227
     }
228
-    
228
+
229
     @Test
229
     @Test
230
     public void testDuplicateKeys() throws IOException, InvalidConfigFileException {
230
     public void testDuplicateKeys() throws IOException, InvalidConfigFileException {
231
         final ConfigFile file = new ConfigFile(getClass().getResourceAsStream("test2.txt"));
231
         final ConfigFile file = new ConfigFile(getClass().getResourceAsStream("test2.txt"));
232
         file.read();
232
         file.read();
233
-        
233
+
234
         assertTrue(file.isKeyDomain("section one"));
234
         assertTrue(file.isKeyDomain("section one"));
235
         assertEquals(3, file.getKeyDomain("section one").size());
235
         assertEquals(3, file.getKeyDomain("section one").size());
236
         assertTrue(file.isFlatDomain("section one point one"));
236
         assertTrue(file.isFlatDomain("section one point one"));

+ 17
- 17
test/com/dmdirc/util/MapListTest.java View File

39
         test.removeFromAll("b");
39
         test.removeFromAll("b");
40
         assertTrue(test.isEmpty());
40
         assertTrue(test.isEmpty());
41
     }
41
     }
42
-    
42
+
43
     @Test
43
     @Test
44
     public void testAddCollection() {
44
     public void testAddCollection() {
45
         final MapList<String, String> test = new MapList<String, String>();
45
         final MapList<String, String> test = new MapList<String, String>();
47
         testList.add("d");
47
         testList.add("d");
48
         testList.add("e");
48
         testList.add("e");
49
         test.add("key", testList);
49
         test.add("key", testList);
50
-        
50
+
51
         assertTrue(test.containsKey("key"));
51
         assertTrue(test.containsKey("key"));
52
         assertTrue(test.containsValue("key", "d"));
52
         assertTrue(test.containsValue("key", "d"));
53
         assertTrue(test.containsValue("key", "e"));
53
         assertTrue(test.containsValue("key", "e"));
54
     }
54
     }
55
-    
55
+
56
     @Test
56
     @Test
57
     public void testClear() {
57
     public void testClear() {
58
         final MapList<String, String> test = new MapList<String, String>();
58
         final MapList<String, String> test = new MapList<String, String>();
61
         test.clear();
61
         test.clear();
62
         assertTrue(test.isEmpty());
62
         assertTrue(test.isEmpty());
63
     }
63
     }
64
-    
64
+
65
     @Test
65
     @Test
66
     public void testClearKey() {
66
     public void testClearKey() {
67
         final MapList<String, String> test = new MapList<String, String>();
67
         final MapList<String, String> test = new MapList<String, String>();
71
         assertTrue(test.values("a").isEmpty());
71
         assertTrue(test.values("a").isEmpty());
72
         assertFalse(test.isEmpty());
72
         assertFalse(test.isEmpty());
73
     }
73
     }
74
-    
74
+
75
     @Test
75
     @Test
76
     public void testRemove() {
76
     public void testRemove() {
77
         final MapList<String, String> test = new MapList<String, String>();
77
         final MapList<String, String> test = new MapList<String, String>();
78
         test.add("a", "b");
78
         test.add("a", "b");
79
         test.add("d", "e");
79
         test.add("d", "e");
80
         test.remove("z", "b");
80
         test.remove("z", "b");
81
-        
81
+
82
         assertEquals(2, test.keySet().size());
82
         assertEquals(2, test.keySet().size());
83
         assertEquals(1, test.values("a").size());
83
         assertEquals(1, test.values("a").size());
84
         assertEquals(1, test.values("d").size());
84
         assertEquals(1, test.values("d").size());
85
-        
85
+
86
         test.remove("a", "b");
86
         test.remove("a", "b");
87
         assertEquals(2, test.keySet().size());
87
         assertEquals(2, test.keySet().size());
88
         assertEquals(0, test.values("a").size());
88
         assertEquals(0, test.values("a").size());
89
-        assertEquals(1, test.values("d").size());        
90
-    }    
91
-    
89
+        assertEquals(1, test.values("d").size());
90
+    }
91
+
92
     @Test
92
     @Test
93
     public void testKeySet() {
93
     public void testKeySet() {
94
         final MapList<String, String> test = new MapList<String, String>();
94
         final MapList<String, String> test = new MapList<String, String>();
97
         assertEquals(2, test.keySet().size());
97
         assertEquals(2, test.keySet().size());
98
         assertTrue(test.keySet().contains("a"));
98
         assertTrue(test.keySet().contains("a"));
99
         assertTrue(test.keySet().contains("d"));
99
         assertTrue(test.keySet().contains("d"));
100
-    }    
100
+    }
101
 
101
 
102
     @Test
102
     @Test
103
     public void testContainsKey() {
103
     public void testContainsKey() {
121
         assertEquals("b", test.get("a").get(0));
121
         assertEquals("b", test.get("a").get(0));
122
         assertEquals("b", test.get("a", 0));
122
         assertEquals("b", test.get("a", 0));
123
     }
123
     }
124
-    
124
+
125
     @Test
125
     @Test
126
     public void testInherit() {
126
     public void testInherit() {
127
         final MapList<String, String> test1 = new MapList<String, String>();
127
         final MapList<String, String> test1 = new MapList<String, String>();
128
         test1.add("a", "b");
128
         test1.add("a", "b");
129
-        
129
+
130
         final MapList<String, String> test2 = new MapList<String, String>(test1);
130
         final MapList<String, String> test2 = new MapList<String, String>(test1);
131
         assertEquals(1, test2.get("a").size());
131
         assertEquals(1, test2.get("a").size());
132
         assertEquals("b", test2.get("a").get(0));
132
         assertEquals("b", test2.get("a").get(0));
133
-        assertEquals("b", test2.get("a", 0));        
133
+        assertEquals("b", test2.get("a", 0));
134
     }
134
     }
135
-    
135
+
136
     @Test
136
     @Test
137
     public void testGetMap() {
137
     public void testGetMap() {
138
         final MapList<String, String> test1 = new MapList<String, String>();
138
         final MapList<String, String> test1 = new MapList<String, String>();
139
         test1.add("a", "b");
139
         test1.add("a", "b");
140
         assertNotSame(test1.getMap(), test1.getMap());
140
         assertNotSame(test1.getMap(), test1.getMap());
141
-        
141
+
142
         final MapList<String, String> test2 = new MapList<String, String>(test1);
142
         final MapList<String, String> test2 = new MapList<String, String>(test1);
143
         assertEquals(test1.getMap(), test2.getMap());
143
         assertEquals(test1.getMap(), test2.getMap());
144
-    }    
144
+    }
145
 
145
 
146
 }
146
 }

Loading…
Cancel
Save