OSDN Git Service

130128版スキーマ対応
[mikutoga/Pmd2XML.git] / src / test / java / jp / sfjp / mikutoga / pmd2xml / CmdLineTest.java
1 /*
2  */
3
4 package jp.sfjp.mikutoga.pmd2xml;
5
6 import java.util.Arrays;
7 import java.util.List;
8 import org.junit.After;
9 import org.junit.AfterClass;
10 import org.junit.Before;
11 import org.junit.BeforeClass;
12 import org.junit.Test;
13
14 import static org.junit.Assert.*;
15
16 /**
17  *
18  */
19 public class CmdLineTest {
20
21     public CmdLineTest() {
22     }
23
24     @BeforeClass
25     public static void setUpClass() {
26     }
27
28     @AfterClass
29     public static void tearDownClass() {
30     }
31
32     @Before
33     public void setUp() {
34     }
35
36     @After
37     public void tearDown() {
38     }
39
40     /**
41      * Test of parse method, of class CmdLine.
42      */
43     @Test
44     public void testParse_StringArr() {
45         System.out.println("parse");
46
47         List<CmdLine> list;
48         List<String> args;
49         CmdLine cmd;
50
51         list = CmdLine.parse();
52         assertEquals(0, list.size());
53
54         list = CmdLine.parse("-h", "-nl", "crlf");
55         assertEquals(2, list.size());
56         cmd = list.get(0);
57         assertSame(OptSwitch.OPT_HELP, cmd.getOptSwitch());
58
59         args = cmd.getOptArgs();
60         assertEquals(1, args.size());
61         assertEquals("-h", args.get(0));
62
63         cmd = list.get(1);
64         assertSame(OptSwitch.OPT_NEWLINE, cmd.getOptSwitch());
65
66         args = cmd.getOptArgs();
67         assertEquals(2, args.size());
68         assertEquals("-nl", args.get(0));
69         assertEquals("crlf", args.get(1));
70
71         list = CmdLine.parse("XXX");
72         assertEquals(1, list.size());
73         cmd = list.get(0);
74         assertNull(cmd.getOptSwitch());
75         args = cmd.getOptArgs();
76         assertEquals(1, args.size());
77         assertEquals("XXX", args.get(0));
78
79         return;
80     }
81
82     /**
83      * Test of parse method, of class CmdLine.
84      */
85     @Test
86     public void testParse_List() {
87         System.out.println("parse");
88
89         List<CmdLine> list;
90         CmdLine cmd;
91
92         list = CmdLine.parse(Arrays.asList("-h"));
93         assertEquals(1, list.size());
94         cmd = list.get(0);
95         assertSame(OptSwitch.OPT_HELP, cmd.getOptSwitch());
96
97         return;
98     }
99
100 }