directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r291313 - /directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/ber/tlv/ValueTest.java
Date Sat, 24 Sep 2005 15:27:58 GMT
Author: elecharny
Date: Sat Sep 24 08:27:55 2005
New Revision: 291313

URL: http://svn.apache.org/viewcvs?rev=291313&view=rev
Log:
Added a test for decoding

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

Modified: directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/ber/tlv/ValueTest.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/ber/tlv/ValueTest.java?rev=291313&r1=291312&r2=291313&view=diff
==============================================================================
--- directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/ber/tlv/ValueTest.java (original)
+++ directory/asn1/trunk/ber-new/src/test/org/apache/asn1new/ber/tlv/ValueTest.java Sat Sep
24 08:27:55 2005
@@ -18,6 +18,8 @@
 
 import java.math.BigInteger;
 
+import org.apache.asn1new.util.IntegerDecoder;
+
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
@@ -85,8 +87,22 @@
         }
     }
     
-    public void testEncodeInt5Bytes()
+    public void testDecodeInt() throws Exception
     {
-
+        byte[] encoded = null;
+        int[] testedInt = new int[] { Integer.MIN_VALUE, -2147483647, -16777216, -16777215,
-8388608, 
+                -8388607, -65536, -65535, -32768, -32767, -256, -255, -128, -127, -1, 0,
+                1, 127, 128, 255, 256, 32767, 32768, 65535, 65536, 8388607, 8388608, 16777215,
16777216,
+                Integer.MAX_VALUE};
+        
+        for ( int i = 0; i < testedInt.length; i++)
+        {
+            encoded = new BigInteger( Integer.toString( testedInt[i] ) ).toByteArray();
+            
+            int value = IntegerDecoder.parse( new Value( encoded ) ); 
+            
+            Assert.assertEquals(testedInt[i], value );
+        }
     }
+    
 }



Mime
View raw message