directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r307396 - /directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/primitives/PrimitivesTest.java
Date Sun, 09 Oct 2005 11:07:19 GMT
Author: elecharny
Date: Sun Oct  9 04:07:15 2005
New Revision: 307396

URL: http://svn.apache.org/viewcvs?rev=307396&view=rev
Log:
Changed the way IntegerDecoder tests handle exceptions

Modified:
    directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/primitives/PrimitivesTest.java

Modified: directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/primitives/PrimitivesTest.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/primitives/PrimitivesTest.java?rev=307396&r1=307395&r2=307396&view=diff
==============================================================================
--- directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/primitives/PrimitivesTest.java
(original)
+++ directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/primitives/PrimitivesTest.java
Sun Oct  9 04:07:15 2005
@@ -19,9 +19,9 @@
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
-import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.IntegerDecoderException;
 import org.apache.log4j.PropertyConfigurator;
 
 /**
@@ -44,74 +44,65 @@
     /**
      * Test the Integer Primitive
      */
-    public void testIntegerPrimitive()
+    public void testIntegerPrimitive() throws IntegerDecoderException
     {
+        Value value = new Value();
 
-        try
-        {
-
-            Value value = new Value();
-
-            value.init(1);
-            value.setData( new byte[] { 0x00 } ); // res = 0
-            Assert.assertEquals( 0, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(1);
-            value.setData( new byte[] { 0x01 } ); // res = 1
-            Assert.assertEquals( 1, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(1);
-            value.setData( new byte[] { ( byte ) 0xFF } ); // res = 255
-            Assert.assertEquals( -1, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(2);
-            value.setData( new byte[] { 0x00, 0x01 } ); // res = 1
-            Assert.assertEquals( 1, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(2);
-            value.setData( new byte[] { 0x01, 0x00 } ); // res = 256
-            Assert.assertEquals( 256, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(2);
-            value.setData( new byte[] { 0x01, 0x01 } ); // res = 257
-            Assert.assertEquals( 257, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(2);
-            value.setData( new byte[] { 0x01, ( byte ) 0xFF } ); // res = 511
-            Assert.assertEquals( 511, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(2);
-            value.setData( new byte[] { 0x02, 0x00 } ); // res = 512
-            Assert.assertEquals( 512, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(3);
-            value.setData( new byte[] { 0x00, ( byte ) 0xFF, ( byte ) 0xFF } ); // res =
65535
-            Assert.assertEquals( 65535, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(4);
-            value.setData(
-                new byte[] { ( byte ) 0x7F, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF }
); // res = 2^31 - 1 = MaxInt
-            Assert.assertEquals( Integer.MAX_VALUE, IntegerDecoder.parse( value ) );
-            value.reset();
-
-            value.init(4);
-            value.setData(
-                new byte[] { ( byte ) 0x80, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00 }
); // res = 2^31 = MinInt
-            Assert.assertEquals( Integer.MIN_VALUE, IntegerDecoder.parse( value ) );
-            value.reset();
-        }
-        catch ( DecoderException de )
-        {
-
-        }
+        value.init(1);
+        value.setData( new byte[] { 0x00 } ); // res = 0
+        Assert.assertEquals( 0, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(1);
+        value.setData( new byte[] { 0x01 } ); // res = 1
+        Assert.assertEquals( 1, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(1);
+        value.setData( new byte[] { ( byte ) 0xFF } ); // res = 255
+        Assert.assertEquals( -1, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(2);
+        value.setData( new byte[] { 0x00, 0x01 } ); // res = 1
+        Assert.assertEquals( 1, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(2);
+        value.setData( new byte[] { 0x01, 0x00 } ); // res = 256
+        Assert.assertEquals( 256, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(2);
+        value.setData( new byte[] { 0x01, 0x01 } ); // res = 257
+        Assert.assertEquals( 257, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(2);
+        value.setData( new byte[] { 0x01, ( byte ) 0xFF } ); // res = 511
+        Assert.assertEquals( 511, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(2);
+        value.setData( new byte[] { 0x02, 0x00 } ); // res = 512
+        Assert.assertEquals( 512, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(3);
+        value.setData( new byte[] { 0x00, ( byte ) 0xFF, ( byte ) 0xFF } ); // res = 65535
+        Assert.assertEquals( 65535, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(4);
+        value.setData(
+            new byte[] { ( byte ) 0x7F, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF } );
// res = 2^31 - 1 = MaxInt
+        Assert.assertEquals( Integer.MAX_VALUE, IntegerDecoder.parse( value ) );
+        value.reset();
+
+        value.init(4);
+        value.setData(
+            new byte[] { ( byte ) 0x80, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00 } );
// res = 2^31 = MinInt
+        Assert.assertEquals( Integer.MIN_VALUE, IntegerDecoder.parse( value ) );
+        value.reset();
     }
 } // end class TLVTagDecoderTest



Mime
View raw message