1 33 34 package edu.rice.cs.drjava.config; 35 36 import edu.rice.cs.drjava.DrJavaTestCase; 37 38 import java.util.ArrayList ; 39 40 45 public final class ForcedChoiceOptionTest extends DrJavaTestCase { 46 49 public ForcedChoiceOptionTest(String name) { super(name); } 50 51 public void testGetName() { 52 ForcedChoiceOption fco = new ForcedChoiceOption("javadoc_access", 53 "protected", 54 null); 55 56 assertEquals("javadoc_access", fco.getName()); 57 } 58 59 public void testParse() { 60 ArrayList <String > aList = new ArrayList <String >(4); 61 62 aList.add("public"); 63 aList.add("protected"); 64 aList.add("package"); 65 aList.add("private"); 66 ForcedChoiceOption fco = new ForcedChoiceOption("javadoc_access", 67 "protected", 68 aList); 69 70 assertTrue("Parsing \"private\"", "private".equals(fco.parse("private"))); 71 try { fco.parse("Private"); fail(); } 72 catch (OptionParseException e) { } 73 74 try { fco.parse("true"); fail(); } 75 catch (OptionParseException e) { } 76 77 try { fco.parse(".33"); fail(); } 78 catch (OptionParseException e) { } 79 } 80 81 public void testFormat() { 82 ForcedChoiceOption fco = new ForcedChoiceOption("javadoc_access", 83 "protected", 84 null); 85 86 assertTrue("Formatting \"private\"", "private".equals(fco.format("private"))); 87 assertTrue("Formatting \"public\"", "public".equals(fco.format("public"))); 88 } 89 } 90 | Popular Tags |