Ver código fonte

Unit test for CommandUtils

Change-Id: Id5020b8d2db071cd0e0898ea59f5e1602ef77bf7
Reviewed-on: http://gerrit.dmdirc.com/1900
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.7rc1
Simon Mott 13 anos atrás
pai
commit
306410b839
1 arquivos alterados com 48 adições e 0 exclusões
  1. 48
    0
      test/com/dmdirc/util/CommandUtilsTest.java

+ 48
- 0
test/com/dmdirc/util/CommandUtilsTest.java Ver arquivo

@@ -0,0 +1,48 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+package com.dmdirc.util;
23
+
24
+import java.util.Arrays;
25
+
26
+import org.junit.Test;
27
+import static org.junit.Assert.*;
28
+
29
+public class CommandUtilsTest {
30
+    @Test
31
+    public void testParseArguments() {
32
+        final String[][][] tests = new String[][][]{
33
+            {{"abcdef abcdef abcdef"}, {"abcdef", "abcdef", "abcdef"}},
34
+            {{"abcdef \"abcdef abcdef\""}, {"abcdef", "abcdef abcdef"}},
35
+            {{"abcdef \"abcdef foo abcdef\""}, {"abcdef", "abcdef foo abcdef"}},
36
+            {{"abcdef \"abcdef\" \"abcdef\""}, {"abcdef", "abcdef", "abcdef"}},
37
+            {{"abcdef \"\""}, {"abcdef", ""}},
38
+            {{"abcdef \" foo?\""}, {"abcdef", " foo?"}},
39
+        };
40
+
41
+        for (String[][] test : tests) {
42
+            final String[] res = CommandUtils.parseArguments(test[0][0]);
43
+            assertTrue(test[0][0] + " - " + Arrays.toString(test[1]) + " - "
44
+                    + Arrays.toString(res),
45
+                    Arrays.equals(test[1], res));
46
+        }
47
+    }
48
+}

Carregando…
Cancelar
Salvar