Pārlūkot izejas kodu

Extra ConfigFile test cases. Removed some superfluous conditionals in ConfigFile.

issue 1106

git-svn-id: http://svn.dmdirc.com/trunk@3889 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 gadus atpakaļ
vecāks
revīzija
971603925a

+ 1
- 1
src/com/dmdirc/util/ConfigFile.java Parādīt failu

@@ -185,7 +185,7 @@ public class ConfigFile {
185 185
                 for (String entry : flatdomains.get(domain)) {
186 186
                     lines.add("  " + escape(entry));
187 187
                 }
188
-            } else if (keydomains.containsKey(domain)) {
188
+            } else {
189 189
                 for (Map.Entry<String, String> entry : keydomains.get(domain).entrySet()) {
190 190
                     lines.add("  " + escape(entry.getKey()) + "="
191 191
                             + escape(entry.getValue()));

+ 10
- 0
test/com/dmdirc/util/ConfigFileTest.java Parādīt failu

@@ -233,5 +233,15 @@ public class ConfigFileTest extends junit.framework.TestCase {
233 233
         config.delete();
234 234
         assertFalse(file.exists());
235 235
     }
236
+    
237
+    @Test
238
+    public void testDuplicateKeys() throws IOException, InvalidConfigFileException {
239
+        final ConfigFile file = new ConfigFile(getClass().getResourceAsStream("test2.txt"));
240
+        file.read();
241
+        
242
+        assertTrue(file.isKeyDomain("section one"));
243
+        assertEquals(3, file.getKeyDomain("section one").size());
244
+        assertTrue(file.isFlatDomain("section one point one"));
245
+    }
236 246
 
237 247
 }

+ 25
- 0
test/com/dmdirc/util/test3.txt Parādīt failu

@@ -0,0 +1,25 @@
1
+# This is a DMDirc configuration file.
2
+# Written on: Mon Dec 17 23:32:19 GMT 2007
3
+
4
+# This section indicates which sections below take key/value
5
+# pairs, rather than a simple list. It should be placed above
6
+# any sections that take key/values.
7
+
8
+keysections:
9
+  section one
10
+
11
+section alpha:
12
+  line 1
13
+  line 2
14
+
15
+section one point one:
16
+  line 1
17
+
18
+section one:
19
+  1=one
20
+  2=two
21
+  3=three
22
+
23
+section one:
24
+
25
+section one point one:

Notiek ielāde…
Atcelt
Saglabāt