1 16 17 package test.types; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.types.UnsignedByte; 21 22 25 public class TestUnsignedByte extends TestCase { 26 27 public TestUnsignedByte(String name) { 28 super(name); 29 } 30 31 34 private void runFailTest(long value) throws Exception { 35 UnsignedByte oUnsignedByte = null; 36 try { 37 oUnsignedByte = new UnsignedByte(value); 38 } 39 catch (Exception e) { } 41 assertNull("validation restriction failed [" + 43 String.valueOf(value) + "]. did not restrict bad value.", oUnsignedByte); 44 } 45 46 49 private void runPassTest(long value) throws Exception { 50 UnsignedByte oUnsignedByte = null; 51 try { 52 oUnsignedByte = new UnsignedByte(value); 53 } 54 catch (Exception e) { } 56 assertEquals("unsigned byte not equal" + 57 String.valueOf(value), oUnsignedByte.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(255); 80 } 81 82 85 public void testMaxOver() throws Exception { 86 runFailTest(256); 87 } 88 89 92 public void testMinExclusive() throws Exception { 93 runPassTest(0L); 94 } 95 } 96 | Popular Tags |