1 16 17 package test.types; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.types.UnsignedShort; 21 22 25 public class TestUnsignedShort extends TestCase { 26 27 public TestUnsignedShort(String name) { 28 super(name); 29 } 30 31 34 private void runFailTest(long value) throws Exception { 35 UnsignedShort oUnsignedShort = null; 36 try { 37 oUnsignedShort = new UnsignedShort(value); 38 } 39 catch (Exception e) { } 41 assertNull("validation restriction failed [" + 43 String.valueOf(value) + "]. did not restrict bad value.", oUnsignedShort); 44 } 45 46 49 private void runPassTest(long value) throws Exception { 50 UnsignedShort oUnsignedShort = null; 51 try { 52 oUnsignedShort = new UnsignedShort(value); 53 } 54 catch (Exception e) { } 56 assertEquals("unsigned short not equal" + 57 String.valueOf(value), oUnsignedShort.toString(), String.valueOf(value)); 58 } 59 60 63 public void testPositiveValue() throws Exception { 64 runPassTest(100); 65 } 66 67 70 public void testNegativeValue() throws Exception { 71 runFailTest(-100); 72 } 73 74 75 78 public void testMaxInclusive() throws Exception { 79 runPassTest(65535); 80 } 81 82 85 public void testMaxOver() throws Exception { 86 runFailTest(65536); 87 } 88 89 92 public void testMinExclusive() throws Exception { 93 runPassTest(0L); 94 } 95 } 96 | Popular Tags |