KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sablecc > sablecc > launcher > OptionArgumentTest


1 /* This file is part of SableCC ( http://sablecc.org ).
2  *
3  * Copyright 2007 Raymond Audet <raymond.audet@gmail.com>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.sablecc.sablecc.launcher;
19
20 import junit.framework.TestCase;
21
22 import org.sablecc.sablecc.exception.InternalException;
23
24 public class OptionArgumentTest
25         extends TestCase {
26
27     OptionArgument optionArgument;
28
29     Option option;
30
31     String JavaDoc operand;
32
33     @Override JavaDoc
34     protected void setUp()
35             throws Exception JavaDoc {
36
37         this.option = Option.DESTINATION;
38
39         this.operand = "operand";
40
41         this.optionArgument = new OptionArgument(this.option, this.operand);
42     }
43
44     public void testOptionArgument() {
45
46         // Case with null option
47
Option nullOption = null;
48         try {
49             this.optionArgument = new OptionArgument(nullOption, this.operand);
50             fail("option may not be null");
51         }
52         catch (InternalException e) {
53             // Expected
54
}
55
56         assertEquals("invalid option", this.option, this.optionArgument
57                 .getOption());
58         assertEquals("invalid operand", this.operand, this.optionArgument
59                 .getOperand());
60     }
61 }
62
Popular Tags