1 33 34 package edu.rice.cs.drjava.config; 35 36 import edu.rice.cs.drjava.DrJavaTestCase; 37 38 41 public final class NonNegativeIntegerOptionTest extends DrJavaTestCase { 42 43 public NonNegativeIntegerOptionTest(String name) { super(name); } 44 45 public void testGetName() { 46 NonNegativeIntegerOption io1 = new NonNegativeIntegerOption("indent_size",null); 47 NonNegativeIntegerOption io2 = new NonNegativeIntegerOption("max_files",null); 48 49 assertEquals("indent_size", io1.getName()); 50 assertEquals("max_files", io2.getName()); 51 } 52 53 public void testParse() { 54 NonNegativeIntegerOption io = new NonNegativeIntegerOption("max_files",null); 55 56 assertEquals(new Integer (3), io.parse("3")); 57 try { io.parse("-3"); fail(); } 58 catch (OptionParseException e) { } 59 60 try { io.parse("true"); fail(); } 61 catch (OptionParseException e) { } 62 63 try { io.parse(".33"); fail(); } 64 catch (OptionParseException e) { } 65 } 66 67 public void testFormat() { 68 NonNegativeIntegerOption io1 = new NonNegativeIntegerOption("max_files",null); 69 NonNegativeIntegerOption io2 = new NonNegativeIntegerOption("indent_size",null); 70 71 assertEquals("33", io1.format(new Integer (33))); 72 assertEquals("33", io2.format(new Integer (33))); 73 assertEquals("-11", io1.format(new Integer (-11))); 74 assertEquals("-11", io2.format(new Integer (-11))); 75 } 76 } 77 | Popular Tags |