harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r647100 [9/9] - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/pack200/ main/java/org/apache/harmony/pack200/bytecode/ main/java/org/apache/harmony/pack200/bytecode/forms/ test/java/org/apache/harmony/...
Date Fri, 11 Apr 2008 10:10:00 GMT
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodeAttributeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodeAttributeTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodeAttributeTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodeAttributeTest.java Fri Apr 11 03:09:38 2008
@@ -39,7 +39,8 @@
         public MockCodeAttribute(int maxStack, int maxLocals,
                 byte[] codePacked, Segment segment,
                 OperandManager operandManager, List exceptionTable) {
-            super(maxStack, maxLocals, codePacked, segment, operandManager, exceptionTable);
+            super(maxStack, maxLocals, codePacked, segment, operandManager,
+                    exceptionTable);
         }
 
         public int getLength() {
@@ -48,6 +49,7 @@
     }
 
     public class MockCpBands extends CpBands {
+
         public MockCpBands(Segment segment) {
             super(segment);
         }
@@ -99,18 +101,19 @@
                     new int[] { 0 }, // bcThisMethod
                     new int[] {}, // bcSuperMethod
                     new int[] {} // bcInitRef
-, null
-            );
+                    , null);
         }
     }
 
     public class MockSegment extends Segment {
+
         public SegmentConstantPool getConstantPool() {
             return new MockSegmentConstantPool(cpBands);
         }
     }
 
     public class MockSegmentConstantPool extends SegmentConstantPool {
+
         public MockSegmentConstantPool(CpBands bands) {
             super(bands);
         }
@@ -149,8 +152,7 @@
                 mixedByteArray, // codePacked
                 segment, // segment
                 operandManager, // operandManager
-                new ArrayList()
-        );
+                new ArrayList());
         assertEquals(29, attribute.getLength());
 
         attribute.attributes.add(new LocalVariableTableAttribute(0, null, null,
@@ -168,8 +170,7 @@
                 mixedByteArray, // codePacked
                 segment, // segment
                 operandManager, // operandManager
-                new ArrayList()
-        );
+                new ArrayList());
         assertEquals(2, attribute.maxLocals);
         assertEquals(3, attribute.maxStack);
         assertEquals("aload_0_putfield_this", ((ByteCode) attribute.byteCodes
@@ -192,8 +193,7 @@
                 singleByteArray, // codePacked
                 segment, // segment
                 operandManager, // operandManager
-                new ArrayList()
-        );
+                new ArrayList());
         assertEquals(3, attribute.maxLocals);
         assertEquals(4, attribute.maxStack);
         assertEquals("invokespecial_this", ((ByteCode) attribute.byteCodes

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecEncodingTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecEncodingTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecEncodingTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecEncodingTest.java Fri Apr 11 03:09:38 2008
@@ -29,138 +29,147 @@
 import org.apache.harmony.pack200.Pack200Exception;
 
 /**
- *
+ * 
  */
 public class CodecEncodingTest extends TestCase {
 
     public void testCanonicalEncodings() throws IOException, Pack200Exception {
-		Codec defaultCodec = new BHSDCodec(2,16,0,0);
-		assertEquals(defaultCodec,CodecEncoding.getCodec(0,null, defaultCodec));
-		Map map = new HashMap();
-		// These are the canonical encodings specified by the Pack200 spec
-		map.put(new Integer(1), "(1,256)");
-		map.put(new Integer(2), "(1,256,1)");
-		map.put(new Integer(3), "(1,256,0,1)");
-		map.put(new Integer(4), "(1,256,1,1)");
-		map.put(new Integer(5), "(2,256)");
-		map.put(new Integer(6), "(2,256,1)");
-		map.put(new Integer(7), "(2,256,0,1)");
-		map.put(new Integer(8), "(2,256,1,1)");
-		map.put(new Integer(9), "(3,256)");
-		map.put(new Integer(10), "(3,256,1)");
-		map.put(new Integer(11), "(3,256,0,1)");
-		map.put(new Integer(12), "(3,256,1,1)");
-		map.put(new Integer(13), "(4,256)");
-		map.put(new Integer(14), "(4,256,1)");
-		map.put(new Integer(15), "(4,256,0,1)");
-		map.put(new Integer(16), "(4,256,1,1)");
-		map.put(new Integer(17), "(5,4)");
-		map.put(new Integer(18), "(5,4,1)");
-		map.put(new Integer(19), "(5,4,2)");
-		map.put(new Integer(20), "(5,16)");
-		map.put(new Integer(21), "(5,16,1)");
-		map.put(new Integer(22), "(5,16,2)");
-		map.put(new Integer(23), "(5,32)");
-		map.put(new Integer(24), "(5,32,1)");
-		map.put(new Integer(25), "(5,32,2)");
-		map.put(new Integer(26), "(5,64)");
-		map.put(new Integer(27), "(5,64,1)");
-		map.put(new Integer(28), "(5,64,2)");
-		map.put(new Integer(29), "(5,128)");
-		map.put(new Integer(30), "(5,128,1)");
-		map.put(new Integer(31), "(5,128,2)");
-		map.put(new Integer(32), "(5,4,0,1)");
-		map.put(new Integer(33), "(5,4,1,1)");
-		map.put(new Integer(34), "(5,4,2,1)");
-		map.put(new Integer(35), "(5,16,0,1)");
-		map.put(new Integer(36), "(5,16,1,1)");
-		map.put(new Integer(37), "(5,16,2,1)");
-		map.put(new Integer(38), "(5,32,0,1)");
-		map.put(new Integer(39), "(5,32,1,1)");
-		map.put(new Integer(40), "(5,32,2,1)");
-		map.put(new Integer(41), "(5,64,0,1)");
-		map.put(new Integer(42), "(5,64,1,1)");
-		map.put(new Integer(43), "(5,64,2,1)");
-		map.put(new Integer(44), "(5,128,0,1)");
-		map.put(new Integer(45), "(5,128,1,1)");
-		map.put(new Integer(46), "(5,128,2,1)");
-		map.put(new Integer(47), "(2,192)");
-		map.put(new Integer(48), "(2,224)");
-		map.put(new Integer(49), "(2,240)");
-		map.put(new Integer(50), "(2,248)");
-		map.put(new Integer(51), "(2,252)");
-		map.put(new Integer(52), "(2,8,0,1)");
-		map.put(new Integer(53), "(2,8,1,1)");
-		map.put(new Integer(54), "(2,16,0,1)");
-		map.put(new Integer(55), "(2,16,1,1)");
-		map.put(new Integer(56), "(2,32,0,1)");
-		map.put(new Integer(57), "(2,32,1,1)");
-		map.put(new Integer(58), "(2,64,0,1)");
-		map.put(new Integer(59), "(2,64,1,1)");
-		map.put(new Integer(60), "(2,128,0,1)");
-		map.put(new Integer(61), "(2,128,1,1)");
-		map.put(new Integer(62), "(2,192,0,1)");
-		map.put(new Integer(63), "(2,192,1,1)");
-		map.put(new Integer(64), "(2,224,0,1)");
-		map.put(new Integer(65), "(2,224,1,1)");
-		map.put(new Integer(66), "(2,240,0,1)");
-		map.put(new Integer(67), "(2,240,1,1)");
-		map.put(new Integer(68), "(2,248,0,1)");
-		map.put(new Integer(69), "(2,248,1,1)");
-		map.put(new Integer(70), "(3,192)");
-		map.put(new Integer(71), "(3,224)");
-		map.put(new Integer(72), "(3,240)");
-		map.put(new Integer(73), "(3,248)");
-		map.put(new Integer(74), "(3,252)");
-		map.put(new Integer(75), "(3,8,0,1)");
-		map.put(new Integer(76), "(3,8,1,1)");
-		map.put(new Integer(77), "(3,16,0,1)");
-		map.put(new Integer(78), "(3,16,1,1)");
-		map.put(new Integer(79), "(3,32,0,1)");
-		map.put(new Integer(80), "(3,32,1,1)");
-		map.put(new Integer(81), "(3,64,0,1)");
-		map.put(new Integer(82), "(3,64,1,1)");
-		map.put(new Integer(83), "(3,128,0,1)");
-		map.put(new Integer(84), "(3,128,1,1)");
-		map.put(new Integer(85), "(3,192,0,1)");
-		map.put(new Integer(86), "(3,192,1,1)");
-		map.put(new Integer(87), "(3,224,0,1)");
-		map.put(new Integer(88), "(3,224,1,1)");
-		map.put(new Integer(89), "(3,240,0,1)");
-		map.put(new Integer(90), "(3,240,1,1)");
-		map.put(new Integer(91), "(3,248,0,1)");
-		map.put(new Integer(92), "(3,248,1,1)");
-		map.put(new Integer(93), "(4,192)");
-		map.put(new Integer(94), "(4,224)");
-		map.put(new Integer(95), "(4,240)");
-		map.put(new Integer(96), "(4,248)");
-		map.put(new Integer(97), "(4,252)");
-		map.put(new Integer(98), "(4,8,0,1)");
-		map.put(new Integer(99), "(4,8,1,1)");
-		map.put(new Integer(100), "(4,16,0,1)");
-		map.put(new Integer(101), "(4,16,1,1)");
-		map.put(new Integer(102), "(4,32,0,1)");
-		map.put(new Integer(103), "(4,32,1,1)");
-		map.put(new Integer(104), "(4,64,0,1)");
-		map.put(new Integer(105), "(4,64,1,1)");
-		map.put(new Integer(106), "(4,128,0,1)");
-		map.put(new Integer(107), "(4,128,1,1)");
-		map.put(new Integer(108), "(4,192,0,1)");
-		map.put(new Integer(109), "(4,192,1,1)");
-		map.put(new Integer(110), "(4,224,0,1)");
-		map.put(new Integer(111), "(4,224,1,1)");
-		map.put(new Integer(112), "(4,240,0,1)");
-		map.put(new Integer(113), "(4,240,1,1)");
-		map.put(new Integer(114), "(4,248,0,1)");
-		map.put(new Integer(115), "(4,248,1,1)");
-		for(int i=1;i<=115;i++) {
-			assertEquals(map.get(new Integer(i)),CodecEncoding.getCodec(i,null, null).toString());
-		}
-	}
-	public void testArbitraryCodec() throws IOException, Pack200Exception {
-		assertEquals("(1,256)",CodecEncoding.getCodec(116,new ByteArrayInputStream(new byte[] { 0x00, (byte)0xFF}), null).toString());
-		assertEquals("(5,128,2,1)",CodecEncoding.getCodec(116,new ByteArrayInputStream(new byte[] { 0x25, (byte)0x7F}), null).toString());
-		assertEquals("(2,128,1,1)",CodecEncoding.getCodec(116,new ByteArrayInputStream(new byte[] { 0x0B, (byte)0x7F}), null).toString());
-	}
+        Codec defaultCodec = new BHSDCodec(2, 16, 0, 0);
+        assertEquals(defaultCodec, CodecEncoding
+                .getCodec(0, null, defaultCodec));
+        Map map = new HashMap();
+        // These are the canonical encodings specified by the Pack200 spec
+        map.put(new Integer(1), "(1,256)");
+        map.put(new Integer(2), "(1,256,1)");
+        map.put(new Integer(3), "(1,256,0,1)");
+        map.put(new Integer(4), "(1,256,1,1)");
+        map.put(new Integer(5), "(2,256)");
+        map.put(new Integer(6), "(2,256,1)");
+        map.put(new Integer(7), "(2,256,0,1)");
+        map.put(new Integer(8), "(2,256,1,1)");
+        map.put(new Integer(9), "(3,256)");
+        map.put(new Integer(10), "(3,256,1)");
+        map.put(new Integer(11), "(3,256,0,1)");
+        map.put(new Integer(12), "(3,256,1,1)");
+        map.put(new Integer(13), "(4,256)");
+        map.put(new Integer(14), "(4,256,1)");
+        map.put(new Integer(15), "(4,256,0,1)");
+        map.put(new Integer(16), "(4,256,1,1)");
+        map.put(new Integer(17), "(5,4)");
+        map.put(new Integer(18), "(5,4,1)");
+        map.put(new Integer(19), "(5,4,2)");
+        map.put(new Integer(20), "(5,16)");
+        map.put(new Integer(21), "(5,16,1)");
+        map.put(new Integer(22), "(5,16,2)");
+        map.put(new Integer(23), "(5,32)");
+        map.put(new Integer(24), "(5,32,1)");
+        map.put(new Integer(25), "(5,32,2)");
+        map.put(new Integer(26), "(5,64)");
+        map.put(new Integer(27), "(5,64,1)");
+        map.put(new Integer(28), "(5,64,2)");
+        map.put(new Integer(29), "(5,128)");
+        map.put(new Integer(30), "(5,128,1)");
+        map.put(new Integer(31), "(5,128,2)");
+        map.put(new Integer(32), "(5,4,0,1)");
+        map.put(new Integer(33), "(5,4,1,1)");
+        map.put(new Integer(34), "(5,4,2,1)");
+        map.put(new Integer(35), "(5,16,0,1)");
+        map.put(new Integer(36), "(5,16,1,1)");
+        map.put(new Integer(37), "(5,16,2,1)");
+        map.put(new Integer(38), "(5,32,0,1)");
+        map.put(new Integer(39), "(5,32,1,1)");
+        map.put(new Integer(40), "(5,32,2,1)");
+        map.put(new Integer(41), "(5,64,0,1)");
+        map.put(new Integer(42), "(5,64,1,1)");
+        map.put(new Integer(43), "(5,64,2,1)");
+        map.put(new Integer(44), "(5,128,0,1)");
+        map.put(new Integer(45), "(5,128,1,1)");
+        map.put(new Integer(46), "(5,128,2,1)");
+        map.put(new Integer(47), "(2,192)");
+        map.put(new Integer(48), "(2,224)");
+        map.put(new Integer(49), "(2,240)");
+        map.put(new Integer(50), "(2,248)");
+        map.put(new Integer(51), "(2,252)");
+        map.put(new Integer(52), "(2,8,0,1)");
+        map.put(new Integer(53), "(2,8,1,1)");
+        map.put(new Integer(54), "(2,16,0,1)");
+        map.put(new Integer(55), "(2,16,1,1)");
+        map.put(new Integer(56), "(2,32,0,1)");
+        map.put(new Integer(57), "(2,32,1,1)");
+        map.put(new Integer(58), "(2,64,0,1)");
+        map.put(new Integer(59), "(2,64,1,1)");
+        map.put(new Integer(60), "(2,128,0,1)");
+        map.put(new Integer(61), "(2,128,1,1)");
+        map.put(new Integer(62), "(2,192,0,1)");
+        map.put(new Integer(63), "(2,192,1,1)");
+        map.put(new Integer(64), "(2,224,0,1)");
+        map.put(new Integer(65), "(2,224,1,1)");
+        map.put(new Integer(66), "(2,240,0,1)");
+        map.put(new Integer(67), "(2,240,1,1)");
+        map.put(new Integer(68), "(2,248,0,1)");
+        map.put(new Integer(69), "(2,248,1,1)");
+        map.put(new Integer(70), "(3,192)");
+        map.put(new Integer(71), "(3,224)");
+        map.put(new Integer(72), "(3,240)");
+        map.put(new Integer(73), "(3,248)");
+        map.put(new Integer(74), "(3,252)");
+        map.put(new Integer(75), "(3,8,0,1)");
+        map.put(new Integer(76), "(3,8,1,1)");
+        map.put(new Integer(77), "(3,16,0,1)");
+        map.put(new Integer(78), "(3,16,1,1)");
+        map.put(new Integer(79), "(3,32,0,1)");
+        map.put(new Integer(80), "(3,32,1,1)");
+        map.put(new Integer(81), "(3,64,0,1)");
+        map.put(new Integer(82), "(3,64,1,1)");
+        map.put(new Integer(83), "(3,128,0,1)");
+        map.put(new Integer(84), "(3,128,1,1)");
+        map.put(new Integer(85), "(3,192,0,1)");
+        map.put(new Integer(86), "(3,192,1,1)");
+        map.put(new Integer(87), "(3,224,0,1)");
+        map.put(new Integer(88), "(3,224,1,1)");
+        map.put(new Integer(89), "(3,240,0,1)");
+        map.put(new Integer(90), "(3,240,1,1)");
+        map.put(new Integer(91), "(3,248,0,1)");
+        map.put(new Integer(92), "(3,248,1,1)");
+        map.put(new Integer(93), "(4,192)");
+        map.put(new Integer(94), "(4,224)");
+        map.put(new Integer(95), "(4,240)");
+        map.put(new Integer(96), "(4,248)");
+        map.put(new Integer(97), "(4,252)");
+        map.put(new Integer(98), "(4,8,0,1)");
+        map.put(new Integer(99), "(4,8,1,1)");
+        map.put(new Integer(100), "(4,16,0,1)");
+        map.put(new Integer(101), "(4,16,1,1)");
+        map.put(new Integer(102), "(4,32,0,1)");
+        map.put(new Integer(103), "(4,32,1,1)");
+        map.put(new Integer(104), "(4,64,0,1)");
+        map.put(new Integer(105), "(4,64,1,1)");
+        map.put(new Integer(106), "(4,128,0,1)");
+        map.put(new Integer(107), "(4,128,1,1)");
+        map.put(new Integer(108), "(4,192,0,1)");
+        map.put(new Integer(109), "(4,192,1,1)");
+        map.put(new Integer(110), "(4,224,0,1)");
+        map.put(new Integer(111), "(4,224,1,1)");
+        map.put(new Integer(112), "(4,240,0,1)");
+        map.put(new Integer(113), "(4,240,1,1)");
+        map.put(new Integer(114), "(4,248,0,1)");
+        map.put(new Integer(115), "(4,248,1,1)");
+        for (int i = 1; i <= 115; i++) {
+            assertEquals(map.get(new Integer(i)), CodecEncoding.getCodec(i,
+                    null, null).toString());
+        }
+    }
+
+    public void testArbitraryCodec() throws IOException, Pack200Exception {
+        assertEquals("(1,256)", CodecEncoding.getCodec(116,
+                new ByteArrayInputStream(new byte[] { 0x00, (byte) 0xFF }),
+                null).toString());
+        assertEquals("(5,128,2,1)", CodecEncoding.getCodec(116,
+                new ByteArrayInputStream(new byte[] { 0x25, (byte) 0x7F }),
+                null).toString());
+        assertEquals("(2,128,1,1)", CodecEncoding.getCodec(116,
+                new ByteArrayInputStream(new byte[] { 0x0B, (byte) 0x7F }),
+                null).toString());
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecTest.java Fri Apr 11 03:09:38 2008
@@ -27,202 +27,207 @@
 import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.RunCodec;
 
-
 /**
- *
+ * 
  */
 public class CodecTest extends TestCase {
 
-	public void testInvalidCodings() {
-		for (int i = 0; i < 256; i++) {
-			try {
-				new BHSDCodec(1, i);
-				fail("b=1 -> h=256");
-			} catch (IllegalArgumentException e) {
-				assertTrue(true);
-			}
-		}
-		for (int i = 1; i <= 5; i++) {
-			try {
-				new BHSDCodec(i, 256);
-				if (i == 5)
-					fail("h=256 -> b!=5");
-			} catch (IllegalArgumentException e) {
-				assertTrue(true);
-			}
-		}
-
-	}
-
-	public void testCodecToString() {
-		assertEquals("(1,256)", Codec.BYTE1.toString());
-		assertEquals("(3,128)", Codec.CHAR3.toString());
-		assertEquals("(5,4)", Codec.BCI5.toString());
-		assertEquals("(5,4,2)", Codec.BRANCH5.toString());
-		assertEquals("(5,64)", Codec.UNSIGNED5.toString());
-		assertEquals("(5,64,1)", Codec.SIGNED5.toString());
-		assertEquals("(5,64,0,1)", Codec.UDELTA5.toString());
-		assertEquals("(5,64,1,1)", Codec.DELTA5.toString());
-		assertEquals("(5,64,2,1)", Codec.MDELTA5.toString());
-		assertEquals("(5,64)", Codec.UNSIGNED5.toString());
-		assertEquals("(5,64,1)", Codec.SIGNED5.toString());
-		assertEquals("(5,64,1,1)", Codec.DELTA5.toString());
-		assertEquals("(5,64,2,1)", Codec.MDELTA5.toString());
-	}
-
-	public void testByte1() throws Exception {
-		for (int i = 0; i < 255; i++)
-			decode(Codec.BYTE1, new byte[] { (byte) i }, i, 0);
-	}
-
-	public void testByte1Delta() throws Exception {
-		Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
-		long last = 0;
-		for (int i = 1; i < 255; i++)
-			last = decode(BYTE1D, new byte[] { (byte) 1 }, i, last);
-	}
-	public void testByte1DeltaException() throws Exception {
-		Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
-		try {
-			BYTE1D.decode(new ByteArrayInputStream(new byte[] { (byte) 1 }));
-			fail("Decoding with a delta stream and not passing a last value should throw exception");
-		} catch (Pack200Exception e) {
-			assertTrue(true);
-		}
-	}
-	public void testByte1Signed() throws Exception {
-		Codec BYTE1S2 = new BHSDCodec(1,256,2);
-		decode(BYTE1S2,new byte[] { 0 }, 0, 0);
-		decode(BYTE1S2,new byte[] { 1 }, 1, 0);
-		decode(BYTE1S2,new byte[] { 2 }, 2, 0);
-		decode(BYTE1S2,new byte[] { 3 }, -1, 0);
-		decode(BYTE1S2,new byte[] { 4 }, 3, 0);
-		decode(BYTE1S2,new byte[] { 5 }, 4, 0);
-		decode(BYTE1S2,new byte[] { 6 }, 5, 0);
-		decode(BYTE1S2,new byte[] { 7 }, -2, 0);
-		decode(BYTE1S2,new byte[] { 8 }, 6, 0);
-		decode(BYTE1S2,new byte[] { 9 }, 7, 0);
-		decode(BYTE1S2,new byte[] { 10 }, 8, 0);
-		decode(BYTE1S2,new byte[] { 11 }, -3, 0);
-	}
-	public void testCardinality() throws Exception {
-		BHSDCodec byte1 = Codec.BYTE1;
-		assertEquals(256,byte1.cardinality());
-		assertEquals(0,byte1.smallest());
-		assertEquals(255,byte1.largest());
-		assertFalse(byte1.encodes(-257));
-		assertFalse(byte1.encodes(-256));
-		assertFalse(byte1.encodes(-255));
-		assertFalse(byte1.encodes(-129));
-		assertFalse(byte1.encodes(-128));
-		assertFalse(byte1.encodes(-127));
-		assertFalse(byte1.encodes(-1));
-		assertTrue(byte1.encodes(0));
-		assertTrue(byte1.encodes(1));
-		assertTrue(byte1.encodes(255));
-		assertFalse(byte1.encodes(256));
-		BHSDCodec byte1s = new BHSDCodec(1,256,1);
-		assertEquals(256,byte1s.cardinality());
-		assertEquals(-128,byte1s.smallest());
-		assertEquals(127,byte1s.largest());
-		assertFalse(byte1s.encodes(-257));
-		assertFalse(byte1s.encodes(-256));
-		assertFalse(byte1s.encodes(-255));
-		assertFalse(byte1s.encodes(-129));
-		assertTrue(byte1s.encodes(-128));
-		assertTrue(byte1s.encodes(-127));
-		assertTrue(byte1s.encodes(-1));
-		assertTrue(byte1s.encodes(0));
-		assertTrue(byte1s.encodes(1));
-		assertTrue(byte1s.encodes(127));
-		assertFalse(byte1s.encodes(128));
-		assertFalse(byte1s.encodes(129));
-		assertFalse(byte1s.encodes(255));
-		assertFalse(byte1s.encodes(256));
-		BHSDCodec byte2s = new BHSDCodec(1,256,2);
-		assertEquals(256,byte2s.cardinality());
-		assertEquals(-64,byte2s.smallest());
-		assertEquals(191,byte2s.largest());
-		assertFalse(byte2s.encodes(-257));
-		assertFalse(byte2s.encodes(-256));
-		assertFalse(byte2s.encodes(-255));
-		assertFalse(byte2s.encodes(-129));
-		assertFalse(byte2s.encodes(-128));
-		assertFalse(byte2s.encodes(-127));
-		assertFalse(byte2s.encodes(-65));
-		assertTrue(byte2s.encodes(-64));
-		assertTrue(byte2s.encodes(-64));
-		assertTrue(byte2s.encodes(-1));
-		assertTrue(byte2s.encodes(0));
-		assertTrue(byte2s.encodes(1));
-		assertTrue(byte2s.encodes(127));
-		assertTrue(byte2s.encodes(128));
-		assertTrue(byte2s.encodes(191));
-		assertFalse(byte2s.encodes(192));
-		assertFalse(byte2s.encodes(256));
-	}
-
-	public void testRunCodec() throws Exception {
-		RunCodec runCodec = new RunCodec(1,Codec.UNSIGNED5,Codec.BYTE1);
-		ByteArrayInputStream bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
-		assertEquals(192,runCodec.decode(bais));
-		assertEquals(192,runCodec.decode(bais));
-		assertEquals(0,runCodec.decode(bais));
-		assertEquals(0,bais.available());
-		runCodec = new RunCodec(1,Codec.BYTE1,Codec.UNSIGNED5);
-		bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
-		assertEquals(192,runCodec.decode(bais));
-		assertEquals(0,runCodec.decode(bais));
-		assertEquals(192,runCodec.decode(bais));
-		assertEquals(0,bais.available());
-	}
-	public void testUnsigned5() throws Exception {
-		decode(Codec.UNSIGNED5, new byte[] { 1 }, 1, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 191 }, 191, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 0 }, 192, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 193, 0 }, 193, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 255, 0 }, 255, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 1 }, 256, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 5 }, 512, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 13 }, 1024, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 29 }, 2048, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 255, (byte) 191 }, 12479, 0);
-
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192, 0 },
-				12480, 0);
-		decode(Codec.UNSIGNED5,
-				new byte[] { (byte) 255, (byte) 255, (byte) 191 }, 798911, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
-				(byte) 192, 0 }, 798912, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 255, (byte) 255,
-				(byte) 255, (byte) 191 }, 51130559, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
-				(byte) 192, (byte) 192, 0 }, 51130560, 0);
-		decode(Codec.UNSIGNED5, new byte[] { (byte) 255, (byte) 252,
-				(byte) 252, (byte) 252, (byte) 252 }, 0xFFFFFFFFL, 0);
-		decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192 });
-		decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192 });
-		decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
-				(byte) 192 });
-		decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
-				(byte) 192, (byte) 192 });
-	}
-
-	private void decodeFail(final Codec codec, final byte[] data)
-			throws IOException, Pack200Exception {
-		try {
-			decode(codec, data, 0, 0);
-			fail("Should have detected an EOFException");
-		} catch (EOFException e) {
-			assertTrue(true);
-		}
-	}
-
-	private long decode(final Codec codec, final byte[] data, final long value,
-			final long last) throws IOException, Pack200Exception {
-		final ByteArrayInputStream in = new ByteArrayInputStream(data);
-		assertEquals(value, codec.decode(in, last));
-		assertEquals(-1, in.read());
-		return (value);
-	}
+    public void testInvalidCodings() {
+        for (int i = 0; i < 256; i++) {
+            try {
+                new BHSDCodec(1, i);
+                fail("b=1 -> h=256");
+            } catch (IllegalArgumentException e) {
+                assertTrue(true);
+            }
+        }
+        for (int i = 1; i <= 5; i++) {
+            try {
+                new BHSDCodec(i, 256);
+                if (i == 5)
+                    fail("h=256 -> b!=5");
+            } catch (IllegalArgumentException e) {
+                assertTrue(true);
+            }
+        }
+
+    }
+
+    public void testCodecToString() {
+        assertEquals("(1,256)", Codec.BYTE1.toString());
+        assertEquals("(3,128)", Codec.CHAR3.toString());
+        assertEquals("(5,4)", Codec.BCI5.toString());
+        assertEquals("(5,4,2)", Codec.BRANCH5.toString());
+        assertEquals("(5,64)", Codec.UNSIGNED5.toString());
+        assertEquals("(5,64,1)", Codec.SIGNED5.toString());
+        assertEquals("(5,64,0,1)", Codec.UDELTA5.toString());
+        assertEquals("(5,64,1,1)", Codec.DELTA5.toString());
+        assertEquals("(5,64,2,1)", Codec.MDELTA5.toString());
+        assertEquals("(5,64)", Codec.UNSIGNED5.toString());
+        assertEquals("(5,64,1)", Codec.SIGNED5.toString());
+        assertEquals("(5,64,1,1)", Codec.DELTA5.toString());
+        assertEquals("(5,64,2,1)", Codec.MDELTA5.toString());
+    }
+
+    public void testByte1() throws Exception {
+        for (int i = 0; i < 255; i++)
+            decode(Codec.BYTE1, new byte[] { (byte) i }, i, 0);
+    }
+
+    public void testByte1Delta() throws Exception {
+        Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
+        long last = 0;
+        for (int i = 1; i < 255; i++)
+            last = decode(BYTE1D, new byte[] { (byte) 1 }, i, last);
+    }
+
+    public void testByte1DeltaException() throws Exception {
+        Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
+        try {
+            BYTE1D.decode(new ByteArrayInputStream(new byte[] { (byte) 1 }));
+            fail("Decoding with a delta stream and not passing a last value should throw exception");
+        } catch (Pack200Exception e) {
+            assertTrue(true);
+        }
+    }
+
+    public void testByte1Signed() throws Exception {
+        Codec BYTE1S2 = new BHSDCodec(1, 256, 2);
+        decode(BYTE1S2, new byte[] { 0 }, 0, 0);
+        decode(BYTE1S2, new byte[] { 1 }, 1, 0);
+        decode(BYTE1S2, new byte[] { 2 }, 2, 0);
+        decode(BYTE1S2, new byte[] { 3 }, -1, 0);
+        decode(BYTE1S2, new byte[] { 4 }, 3, 0);
+        decode(BYTE1S2, new byte[] { 5 }, 4, 0);
+        decode(BYTE1S2, new byte[] { 6 }, 5, 0);
+        decode(BYTE1S2, new byte[] { 7 }, -2, 0);
+        decode(BYTE1S2, new byte[] { 8 }, 6, 0);
+        decode(BYTE1S2, new byte[] { 9 }, 7, 0);
+        decode(BYTE1S2, new byte[] { 10 }, 8, 0);
+        decode(BYTE1S2, new byte[] { 11 }, -3, 0);
+    }
+
+    public void testCardinality() throws Exception {
+        BHSDCodec byte1 = Codec.BYTE1;
+        assertEquals(256, byte1.cardinality());
+        assertEquals(0, byte1.smallest());
+        assertEquals(255, byte1.largest());
+        assertFalse(byte1.encodes(-257));
+        assertFalse(byte1.encodes(-256));
+        assertFalse(byte1.encodes(-255));
+        assertFalse(byte1.encodes(-129));
+        assertFalse(byte1.encodes(-128));
+        assertFalse(byte1.encodes(-127));
+        assertFalse(byte1.encodes(-1));
+        assertTrue(byte1.encodes(0));
+        assertTrue(byte1.encodes(1));
+        assertTrue(byte1.encodes(255));
+        assertFalse(byte1.encodes(256));
+        BHSDCodec byte1s = new BHSDCodec(1, 256, 1);
+        assertEquals(256, byte1s.cardinality());
+        assertEquals(-128, byte1s.smallest());
+        assertEquals(127, byte1s.largest());
+        assertFalse(byte1s.encodes(-257));
+        assertFalse(byte1s.encodes(-256));
+        assertFalse(byte1s.encodes(-255));
+        assertFalse(byte1s.encodes(-129));
+        assertTrue(byte1s.encodes(-128));
+        assertTrue(byte1s.encodes(-127));
+        assertTrue(byte1s.encodes(-1));
+        assertTrue(byte1s.encodes(0));
+        assertTrue(byte1s.encodes(1));
+        assertTrue(byte1s.encodes(127));
+        assertFalse(byte1s.encodes(128));
+        assertFalse(byte1s.encodes(129));
+        assertFalse(byte1s.encodes(255));
+        assertFalse(byte1s.encodes(256));
+        BHSDCodec byte2s = new BHSDCodec(1, 256, 2);
+        assertEquals(256, byte2s.cardinality());
+        assertEquals(-64, byte2s.smallest());
+        assertEquals(191, byte2s.largest());
+        assertFalse(byte2s.encodes(-257));
+        assertFalse(byte2s.encodes(-256));
+        assertFalse(byte2s.encodes(-255));
+        assertFalse(byte2s.encodes(-129));
+        assertFalse(byte2s.encodes(-128));
+        assertFalse(byte2s.encodes(-127));
+        assertFalse(byte2s.encodes(-65));
+        assertTrue(byte2s.encodes(-64));
+        assertTrue(byte2s.encodes(-64));
+        assertTrue(byte2s.encodes(-1));
+        assertTrue(byte2s.encodes(0));
+        assertTrue(byte2s.encodes(1));
+        assertTrue(byte2s.encodes(127));
+        assertTrue(byte2s.encodes(128));
+        assertTrue(byte2s.encodes(191));
+        assertFalse(byte2s.encodes(192));
+        assertFalse(byte2s.encodes(256));
+    }
+
+    public void testRunCodec() throws Exception {
+        RunCodec runCodec = new RunCodec(1, Codec.UNSIGNED5, Codec.BYTE1);
+        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[] {
+                (byte) 192, 0, (byte) 192, 0 });
+        assertEquals(192, runCodec.decode(bais));
+        assertEquals(192, runCodec.decode(bais));
+        assertEquals(0, runCodec.decode(bais));
+        assertEquals(0, bais.available());
+        runCodec = new RunCodec(1, Codec.BYTE1, Codec.UNSIGNED5);
+        bais = new ByteArrayInputStream(new byte[] { (byte) 192, 0, (byte) 192,
+                0 });
+        assertEquals(192, runCodec.decode(bais));
+        assertEquals(0, runCodec.decode(bais));
+        assertEquals(192, runCodec.decode(bais));
+        assertEquals(0, bais.available());
+    }
+
+    public void testUnsigned5() throws Exception {
+        decode(Codec.UNSIGNED5, new byte[] { 1 }, 1, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 191 }, 191, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 0 }, 192, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 193, 0 }, 193, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 255, 0 }, 255, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 1 }, 256, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 5 }, 512, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 13 }, 1024, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 29 }, 2048, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 255, (byte) 191 }, 12479, 0);
+
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192, 0 },
+                12480, 0);
+        decode(Codec.UNSIGNED5,
+                new byte[] { (byte) 255, (byte) 255, (byte) 191 }, 798911, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
+                (byte) 192, 0 }, 798912, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 255, (byte) 255,
+                (byte) 255, (byte) 191 }, 51130559, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
+                (byte) 192, (byte) 192, 0 }, 51130560, 0);
+        decode(Codec.UNSIGNED5, new byte[] { (byte) 255, (byte) 252,
+                (byte) 252, (byte) 252, (byte) 252 }, 0xFFFFFFFFL, 0);
+        decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192 });
+        decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192 });
+        decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
+                (byte) 192 });
+        decodeFail(Codec.UNSIGNED5, new byte[] { (byte) 192, (byte) 192,
+                (byte) 192, (byte) 192 });
+    }
+
+    private void decodeFail(final Codec codec, final byte[] data)
+            throws IOException, Pack200Exception {
+        try {
+            decode(codec, data, 0, 0);
+            fail("Should have detected an EOFException");
+        } catch (EOFException e) {
+            assertTrue(true);
+        }
+    }
+
+    private long decode(final Codec codec, final byte[] data, final long value,
+            final long last) throws IOException, Pack200Exception {
+        final ByteArrayInputStream in = new ByteArrayInputStream(data);
+        assertEquals(value, codec.decode(in, last));
+        assertEquals(-1, in.read());
+        return (value);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/HelloWorld.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/HelloWorld.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/HelloWorld.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/HelloWorld.java Fri Apr 11 03:09:38 2008
@@ -20,14 +20,17 @@
  * This is intended to be used as a test class for unpacking a packed Jar file.
  */
 public class HelloWorld {
-	int i=97,j=42,k=12345;
-	float f=3.142f,g=2.718f;
-	long l=299792458;
-	double d=4.0d;
-	public static void main(String[] args) {
-		System.out.println("Hello world");
-	}
-	public HelloWorld[][] method(int a,int b,int c) {
-		return null;
-	}
+
+    int i = 97, j = 42, k = 12345;
+    float f = 3.142f, g = 2.718f;
+    long l = 299792458;
+    double d = 4.0d;
+
+    public static void main(String[] args) {
+        System.out.println("Hello world");
+    }
+
+    public HelloWorld[][] method(int a, int b, int c) {
+        return null;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ICTupleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ICTupleTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ICTupleTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ICTupleTest.java Fri Apr 11 03:09:38 2008
@@ -22,7 +22,8 @@
 public class ICTupleTest extends TestCase {
 
     public void testPredictedClassTupleParsing() {
-        IcTuple tuple = new IcTuple("orw/SimpleHelloWorld$SimpleHelloWorldInner", 0, null, null);
+        IcTuple tuple = new IcTuple(
+                "orw/SimpleHelloWorld$SimpleHelloWorldInner", 0, null, null);
         assertEquals("SimpleHelloWorldInner", tuple.simpleClassName());
         assertEquals("orw/SimpleHelloWorld", tuple.outerClassString());
 
@@ -40,11 +41,13 @@
     }
 
     public void testExplicitClassTupleParsing() {
-        IcTuple tuple = new IcTuple("Foo$$2$Local", IcTuple.NESTED_CLASS_FLAG, null, "$2$Local");
+        IcTuple tuple = new IcTuple("Foo$$2$Local", IcTuple.NESTED_CLASS_FLAG,
+                null, "$2$Local");
         assertEquals("$2$Local", tuple.simpleClassName());
         assertEquals("Foo$$2", tuple.outerClassString());
 
-        tuple = new IcTuple("Red$Herring", IcTuple.NESTED_CLASS_FLAG, "Red$Herring", null);
+        tuple = new IcTuple("Red$Herring", IcTuple.NESTED_CLASS_FLAG,
+                "Red$Herring", null);
         assertEquals("Herring", tuple.simpleClassName());
         assertEquals("Red$Herring", tuple.outerClassString());
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PopulationCodecTest.java Fri Apr 11 03:09:38 2008
@@ -27,30 +27,41 @@
 import org.apache.harmony.pack200.PopulationCodec;
 
 public class PopulationCodecTest extends TestCase {
-	public void testPopulationCodec() throws IOException, Pack200Exception {
-		checkDecode(new byte[] { 4,5,6,4,2,1,3,0,7 }, new long[]{ 5,4,6,7 }, Codec.BYTE1);
-		// Codec.SIGNED5 can be trivial for small n, because the encoding is 2n if even, 2n-1 if odd
-		// Therefore they're left here to explain what the values are :-)
-		checkDecode(new byte[] { 4*2,4*2-1,6*2,4*2,2*2,1*2,3*2,0,7*2 }, new long[]{ -4,4,6,7 }, Codec.SIGNED5);
-		checkDecode(new byte[] { 4*2-1,4*2,6*2,4*2,2*2,1*2,3*2,0,7*2 }, new long[]{ 4,-4,6,7 }, Codec.SIGNED5);
-		checkDecode(new byte[] { 1,1,1 }, new long[]{ 1 }, Codec.BYTE1);
-		checkDecode(new byte[] { 2,2,1 }, new long[]{ 2 }, Codec.BYTE1);
-		checkDecode(new byte[] { 1,1,2 }, new long[]{ -1 }, Codec.SIGNED5);
-		checkDecode(new byte[] { 2,2,0,1,3 }, new long[]{ 3,2 }, Codec.BYTE1);
-		checkDecode(new byte[] { 1,2,3,4,4,2,3,4,0,1 }, new long[]{ 2,3,4,1 }, Codec.BYTE1);
-		checkDecode(new byte[] { 3,2,1,4,4,2,3,4,0,1 }, new long[]{ 2,1,4,1 }, Codec.BYTE1);
-		checkDecode(new byte[] { 3,2,1,4,1,2,3,4,0,1 }, new long[]{ 2,1,4,1 }, Codec.BYTE1);
-	}
 
-	private void checkDecode(byte[] data, long[] expectedResult, Codec codec) throws IOException, Pack200Exception {
-		InputStream in = new ByteArrayInputStream(data );
+    public void testPopulationCodec() throws IOException, Pack200Exception {
+        checkDecode(new byte[] { 4, 5, 6, 4, 2, 1, 3, 0, 7 }, new long[] { 5,
+                4, 6, 7 }, Codec.BYTE1);
+        // Codec.SIGNED5 can be trivial for small n, because the encoding is 2n
+        // if even, 2n-1 if odd
+        // Therefore they're left here to explain what the values are :-)
+        checkDecode(new byte[] { 4 * 2, 4 * 2 - 1, 6 * 2, 4 * 2, 2 * 2, 1 * 2,
+                3 * 2, 0, 7 * 2 }, new long[] { -4, 4, 6, 7 }, Codec.SIGNED5);
+        checkDecode(new byte[] { 4 * 2 - 1, 4 * 2, 6 * 2, 4 * 2, 2 * 2, 1 * 2,
+                3 * 2, 0, 7 * 2 }, new long[] { 4, -4, 6, 7 }, Codec.SIGNED5);
+        checkDecode(new byte[] { 1, 1, 1 }, new long[] { 1 }, Codec.BYTE1);
+        checkDecode(new byte[] { 2, 2, 1 }, new long[] { 2 }, Codec.BYTE1);
+        checkDecode(new byte[] { 1, 1, 2 }, new long[] { -1 }, Codec.SIGNED5);
+        checkDecode(new byte[] { 2, 2, 0, 1, 3 }, new long[] { 3, 2 },
+                Codec.BYTE1);
+        checkDecode(new byte[] { 1, 2, 3, 4, 4, 2, 3, 4, 0, 1 }, new long[] {
+                2, 3, 4, 1 }, Codec.BYTE1);
+        checkDecode(new byte[] { 3, 2, 1, 4, 4, 2, 3, 4, 0, 1 }, new long[] {
+                2, 1, 4, 1 }, Codec.BYTE1);
+        checkDecode(new byte[] { 3, 2, 1, 4, 1, 2, 3, 4, 0, 1 }, new long[] {
+                2, 1, 4, 1 }, Codec.BYTE1);
+    }
 
-		long[] result = new PopulationCodec(codec,codec,codec).decode(expectedResult.length,in);
-		assertEquals(expectedResult.length,result.length);
-		for(int i=0;i<expectedResult.length;i++) {
-			assertEquals(expectedResult[i],result[i]);
-		}
-		assertEquals(0,in.available());
-	}
+    private void checkDecode(byte[] data, long[] expectedResult, Codec codec)
+            throws IOException, Pack200Exception {
+        InputStream in = new ByteArrayInputStream(data);
+
+        long[] result = new PopulationCodec(codec, codec, codec).decode(
+                expectedResult.length, in);
+        assertEquals(expectedResult.length, result.length);
+        for (int i = 0; i < expectedResult.length; i++) {
+            assertEquals(expectedResult[i], result[i]);
+        }
+        assertEquals(0, in.available());
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentConstantPoolTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentConstantPoolTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentConstantPoolTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentConstantPoolTest.java Fri Apr 11 03:09:38 2008
@@ -28,68 +28,94 @@
 public class SegmentConstantPoolTest extends TestCase {
 
     public class MockSegmentConstantPool extends SegmentConstantPool {
+
         public MockSegmentConstantPool() {
-        	super(new CpBands(new Segment()));
+            super(new CpBands(new Segment()));
         };
 
-        public int matchSpecificPoolEntryIndex(String[] classNameArray, String desiredClassName, int desiredIndex) {
-        	return super.matchSpecificPoolEntryIndex(classNameArray, desiredClassName, desiredIndex);
+        public int matchSpecificPoolEntryIndex(String[] classNameArray,
+                String desiredClassName, int desiredIndex) {
+            return super.matchSpecificPoolEntryIndex(classNameArray,
+                    desiredClassName, desiredIndex);
         };
 
-        public int matchSpecificPoolEntryIndex(String[] classNameArray, String[] methodNameArray, String desiredClassName, String desiredMethodRegex, int desiredIndex) {
-        	return super.matchSpecificPoolEntryIndex(classNameArray, methodNameArray, desiredClassName, desiredMethodRegex, desiredIndex);
+        public int matchSpecificPoolEntryIndex(String[] classNameArray,
+                String[] methodNameArray, String desiredClassName,
+                String desiredMethodRegex, int desiredIndex) {
+            return super.matchSpecificPoolEntryIndex(classNameArray,
+                    methodNameArray, desiredClassName, desiredMethodRegex,
+                    desiredIndex);
         };
 
-        public boolean regexMatchesVisible(String regexString, String compareString) {
+        public boolean regexMatchesVisible(String regexString,
+                String compareString) {
             return SegmentConstantPool.regexMatches(regexString, compareString);
         }
     }
 
-	String[] testClassArray = {"Object", "Object" , "java/lang/String", "java/lang/String", "Object", "Other" };
-	String[] testMethodArray = {"<init>()", "clone()" , "equals()", "<init>", "isNull()", "Other" };
+    String[] testClassArray = { "Object", "Object", "java/lang/String",
+            "java/lang/String", "Object", "Other" };
+    String[] testMethodArray = { "<init>()", "clone()", "equals()", "<init>",
+            "isNull()", "Other" };
+
+    public void testMatchSpecificPoolEntryIndex_SingleArray() throws Exception {
+        MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
+        // Elements should be found at the proper position.
+        assertEquals(0, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, "Object", 0));
+        assertEquals(1, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, "Object", 1));
+        assertEquals(2, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, "java/lang/String", 0));
+        assertEquals(3, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, "java/lang/String", 1));
+        assertEquals(4, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, "Object", 2));
+        assertEquals(5, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, "Other", 0));
+
+        // Elements that don't exist shouldn't be found
+        assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, "NotThere", 0));
+
+        // Elements that exist but don't have the requisite number
+        // of hits shouldn't be found.
+        assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, "java/lang/String", 2));
+    }
 
-	public void testMatchSpecificPoolEntryIndex_SingleArray() throws Exception {
-		MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
-		// Elements should be found at the proper position.
-		assertEquals(0, mockInstance.matchSpecificPoolEntryIndex(testClassArray, "Object", 0));
-		assertEquals(1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, "Object", 1));
-		assertEquals(2, mockInstance.matchSpecificPoolEntryIndex(testClassArray, "java/lang/String", 0));
-		assertEquals(3, mockInstance.matchSpecificPoolEntryIndex(testClassArray, "java/lang/String", 1));
-		assertEquals(4, mockInstance.matchSpecificPoolEntryIndex(testClassArray, "Object", 2));
-		assertEquals(5, mockInstance.matchSpecificPoolEntryIndex(testClassArray, "Other", 0));
-
-		// Elements that don't exist shouldn't be found
-		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, "NotThere", 0));
-
-		// Elements that exist but don't have the requisite number
-		// of hits shouldn't be found.
-		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, "java/lang/String", 2));
-	}
-
-	public void testMatchSpecificPoolEntryIndex_DoubleArray() throws Exception {
-		MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
-		// Elements should be found at the proper position.
-		assertEquals(0, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Object", "^<init>.*", 0));
-		assertEquals(2, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", ".*", 0));
-		assertEquals(3, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", "^<init>.*", 0));
-		assertEquals(5, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "Other", ".*", 0));
-
-		// Elements that don't exist shouldn't be found
-		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "NotThere", "^<init>.*", 0));
-
-		// Elements that exist but don't have the requisite number
-		// of hits shouldn't be found.
-		assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(testClassArray, testMethodArray, "java/lang/String", "^<init>.*", 1));
-	}
-
-	public void testRegexReplacement() {
-	    MockSegmentConstantPool mockPool = new MockSegmentConstantPool();
-	    assertTrue(mockPool.regexMatchesVisible(".*", "anything"));
+    public void testMatchSpecificPoolEntryIndex_DoubleArray() throws Exception {
+        MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
+        // Elements should be found at the proper position.
+        assertEquals(0, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, testMethodArray, "Object", "^<init>.*", 0));
+        assertEquals(2, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, testMethodArray, "java/lang/String", ".*", 0));
+        assertEquals(3, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, testMethodArray, "java/lang/String",
+                "^<init>.*", 0));
+        assertEquals(5, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, testMethodArray, "Other", ".*", 0));
+
+        // Elements that don't exist shouldn't be found
+        assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, testMethodArray, "NotThere", "^<init>.*", 0));
+
+        // Elements that exist but don't have the requisite number
+        // of hits shouldn't be found.
+        assertEquals(-1, mockInstance.matchSpecificPoolEntryIndex(
+                testClassArray, testMethodArray, "java/lang/String",
+                "^<init>.*", 1));
+    }
+
+    public void testRegexReplacement() {
+        MockSegmentConstantPool mockPool = new MockSegmentConstantPool();
+        assertTrue(mockPool.regexMatchesVisible(".*", "anything"));
         assertTrue(mockPool.regexMatchesVisible(".*", ""));
         assertTrue(mockPool.regexMatchesVisible("^<init>.*", "<init>"));
         assertTrue(mockPool.regexMatchesVisible("^<init>.*", "<init>stuff"));
         assertFalse(mockPool.regexMatchesVisible("^<init>.*", "init>stuff"));
         assertFalse(mockPool.regexMatchesVisible("^<init>.*", "<init"));
         assertFalse(mockPool.regexMatchesVisible("^<init>.*", ""));
-	}
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentOptionsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentOptionsTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentOptionsTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentOptionsTest.java Fri Apr 11 03:09:38 2008
@@ -22,20 +22,22 @@
 import org.apache.harmony.pack200.SegmentOptions;
 
 /**
- *
+ * 
  */
 public class SegmentOptionsTest extends TestCase {
 
     public void testUnused() {
-		int[] unused = new int[] { 3, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
-				23, 24, 25, 26, 27, 28, 29, 30, 31 };
-		for (int i = 0; i < unused.length; i++) {
-			try {
-				new SegmentOptions(1 << unused[i]);
-				fail("Bit " + unused[i] + " should be unused, but it's not caught during construction");
-			} catch (Pack200Exception e) {
-				assertTrue(true);
-			}
-		}
-	}
+        int[] unused = new int[] { 3, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+                23, 24, 25, 26, 27, 28, 29, 30, 31 };
+        for (int i = 0; i < unused.length; i++) {
+            try {
+                new SegmentOptions(1 << unused[i]);
+                fail("Bit "
+                        + unused[i]
+                        + " should be unused, but it's not caught during construction");
+            } catch (Pack200Exception e) {
+                assertTrue(true);
+            }
+        }
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentUtilsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentUtilsTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentUtilsTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentUtilsTest.java Fri Apr 11 03:09:38 2008
@@ -16,62 +16,67 @@
  */
 package org.apache.harmony.pack200.tests;
 
-
 import junit.framework.TestCase;
 
 import org.apache.harmony.pack200.IMatcher;
 import org.apache.harmony.pack200.SegmentUtils;
 
 public class SegmentUtilsTest extends TestCase {
-	private static class MultipleMatches implements IMatcher {
-		private final int divisor;
 
-		public MultipleMatches(int divisor) {
-			this.divisor = divisor;
-		}
-
-		public boolean matches(long value) {
-			return value % divisor == 0;
-		}
-
-	}
-
-	public static final IMatcher even = new MultipleMatches(2);
-	public static final IMatcher five = new MultipleMatches(5);
-
-	public void testCountArgs() {
-		assertEquals(0, SegmentUtils.countArgs("()V"));
-		assertEquals(1, SegmentUtils.countArgs("(D)V"));
-		assertEquals(1, SegmentUtils.countArgs("([D)V"));
-		assertEquals(1, SegmentUtils.countArgs("([[D)V"));
-		assertEquals(2, SegmentUtils.countArgs("(DD)V"));
-		assertEquals(3, SegmentUtils.countArgs("(DDD)V"));
-		assertEquals(2, SegmentUtils.countArgs("(Lblah/blah;D)V"));
-		assertEquals(3, SegmentUtils.countArgs("(Lblah/blah;DLbLah;)V"));
-	}
+    private static class MultipleMatches implements IMatcher {
+
+        private final int divisor;
+
+        public MultipleMatches(int divisor) {
+            this.divisor = divisor;
+        }
+
+        public boolean matches(long value) {
+            return value % divisor == 0;
+        }
+
+    }
+
+    public static final IMatcher even = new MultipleMatches(2);
+    public static final IMatcher five = new MultipleMatches(5);
+
+    public void testCountArgs() {
+        assertEquals(0, SegmentUtils.countArgs("()V"));
+        assertEquals(1, SegmentUtils.countArgs("(D)V"));
+        assertEquals(1, SegmentUtils.countArgs("([D)V"));
+        assertEquals(1, SegmentUtils.countArgs("([[D)V"));
+        assertEquals(2, SegmentUtils.countArgs("(DD)V"));
+        assertEquals(3, SegmentUtils.countArgs("(DDD)V"));
+        assertEquals(2, SegmentUtils.countArgs("(Lblah/blah;D)V"));
+        assertEquals(3, SegmentUtils.countArgs("(Lblah/blah;DLbLah;)V"));
+    }
 
-	public void testCountInvokeInterfaceArgs() {
-	    assertEquals(1, SegmentUtils.countInvokeInterfaceArgs("(Z)V"));
+    public void testCountInvokeInterfaceArgs() {
+        assertEquals(1, SegmentUtils.countInvokeInterfaceArgs("(Z)V"));
         assertEquals(2, SegmentUtils.countInvokeInterfaceArgs("(D)V"));
         assertEquals(2, SegmentUtils.countInvokeInterfaceArgs("(J)V"));
         assertEquals(1, SegmentUtils.countInvokeInterfaceArgs("([D)V"));
         assertEquals(1, SegmentUtils.countInvokeInterfaceArgs("([[D)V"));
         assertEquals(4, SegmentUtils.countInvokeInterfaceArgs("(DD)V"));
-        assertEquals(3, SegmentUtils.countInvokeInterfaceArgs("(Lblah/blah;D)V"));
-        assertEquals(4, SegmentUtils.countInvokeInterfaceArgs("(Lblah/blah;DLbLah;)V"));
-        assertEquals(4, SegmentUtils.countInvokeInterfaceArgs("([Lblah/blah;DLbLah;)V"));
-	}
-	public void testMatches() {
-		long[] oneToTen = new long[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
-		assertEquals(6, SegmentUtils.countMatches(new long[][] { oneToTen,
-				new long[] { 5, 6, 7 } }, even));
-		assertEquals(5, SegmentUtils.countMatches(new long[][] { oneToTen },
-				even));
-		assertEquals(5, SegmentUtils.countMatches(oneToTen, even));
-		assertEquals(3, SegmentUtils.countMatches(new long[][] { oneToTen,
-				new long[] { 5, 6, 7 } }, five));
-		assertEquals(2, SegmentUtils.countMatches(new long[][] { oneToTen },
-				five));
-		assertEquals(2, SegmentUtils.countMatches(oneToTen, five));
-	}
+        assertEquals(3, SegmentUtils
+                .countInvokeInterfaceArgs("(Lblah/blah;D)V"));
+        assertEquals(4, SegmentUtils
+                .countInvokeInterfaceArgs("(Lblah/blah;DLbLah;)V"));
+        assertEquals(4, SegmentUtils
+                .countInvokeInterfaceArgs("([Lblah/blah;DLbLah;)V"));
+    }
+
+    public void testMatches() {
+        long[] oneToTen = new long[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+        assertEquals(6, SegmentUtils.countMatches(new long[][] { oneToTen,
+                new long[] { 5, 6, 7 } }, even));
+        assertEquals(5, SegmentUtils.countMatches(new long[][] { oneToTen },
+                even));
+        assertEquals(5, SegmentUtils.countMatches(oneToTen, even));
+        assertEquals(3, SegmentUtils.countMatches(new long[][] { oneToTen,
+                new long[] { 5, 6, 7 } }, five));
+        assertEquals(2, SegmentUtils.countMatches(new long[][] { oneToTen },
+                five));
+        assertEquals(2, SegmentUtils.countMatches(oneToTen, five));
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ByteCodeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ByteCodeTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ByteCodeTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ByteCodeTest.java Fri Apr 11 03:09:38 2008
@@ -21,9 +21,10 @@
 import org.apache.harmony.pack200.bytecode.ByteCode;
 
 public class ByteCodeTest extends TestCase {
-	public void testByteCode() {
-		assertEquals("nop", ByteCode.getByteCode(0).getName());
-		assertEquals("return", ByteCode.getByteCode(-79).getName());
-		assertEquals("return", ByteCode.getByteCode(177).getName());
-	}
+
+    public void testByteCode() {
+        assertEquals("nop", ByteCode.getByteCode(0).getName());
+        assertEquals("return", ByteCode.getByteCode(-79).getName());
+        assertEquals("return", ByteCode.getByteCode(177).getName());
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ClassFileEntryTest.java Fri Apr 11 03:09:38 2008
@@ -30,64 +30,93 @@
 
 public class ClassFileEntryTest extends TestCase {
 
-	public void testUTF8() {
-		CPUTF8 u1 = new CPUTF8(new String("thing"), ClassConstantPool.DOMAIN_NORMALASCIIZ); //$NON-NLS-1$
-		CPUTF8 u2 = new CPUTF8(new String("thing"), ClassConstantPool.DOMAIN_NORMALASCIIZ); //$NON-NLS-1$
-		CPUTF8 u3 = new CPUTF8(new String("otherthing"), ClassConstantPool.DOMAIN_NORMALASCIIZ); //$NON-NLS-1$
-		checkEquality(u1, u2, "thing", u3);
-	}
-	private void checkEquality(Object equal1, Object equal2, String toString, Object unequal) {
-		assertEquals(equal1,equal2);
-		assertEquals(equal1.hashCode(),equal2.hashCode());
-		assertTrue(equal1.toString().indexOf(toString)>=0);
-		assertFalse(equal1.equals(unequal));
-		assertFalse(equal2.equals(unequal));
-		assertFalse(unequal.equals(equal1));
-		assertFalse(unequal.equals(equal2));
-	}
-	public void testSourceAttribute() {
-		SourceFileAttribute sfa1 = new SourceFileAttribute(new CPUTF8(new String("Thing.java"), ClassConstantPool.DOMAIN_NORMALASCIIZ)); //$NON-NLS-1$
-		SourceFileAttribute sfa2 = new SourceFileAttribute(new CPUTF8(new String("Thing.java"), ClassConstantPool.DOMAIN_NORMALASCIIZ)); //$NON-NLS-1$
-		SourceFileAttribute sfa3 = new SourceFileAttribute(new CPUTF8(new String("OtherThing.java"), ClassConstantPool.DOMAIN_NORMALASCIIZ)); //$NON-NLS-1$
-		checkEquality(sfa1,sfa2,"Thing.java",sfa3); //$NON-NLS-1$
-	}
-	public void testCPInteger() {
-		CPInteger cp1 = new CPInteger(new Integer(3));
-		CPInteger cp2 = new CPInteger(new Integer(3));
-		CPInteger cp3 = new CPInteger(new Integer(5));
-		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
-	}
-	public void testCPLong() {
-		CPLong cp1 = new CPLong(new Long(3));
-		CPLong cp2 = new CPLong(new Long(3));
-		CPLong cp3 = new CPLong(new Long(5));
-		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
-	}
-	public void testCPDouble() {
-		CPDouble cp1 = new CPDouble(new Double(3));
-		CPDouble cp2 = new CPDouble(new Double(3));
-		CPDouble cp3 = new CPDouble(new Double(5));
-		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
-	}
-	public void testCPFloat() {
-		CPFloat cp1 = new CPFloat(new Float(3));
-		CPFloat cp2 = new CPFloat(new Float(3));
-		CPFloat cp3 = new CPFloat(new Float(5));
-		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
-	}
-	public void testCPString() {
-		CPString cp1 = new CPString(new CPUTF8(new String("3"), ClassConstantPool.DOMAIN_NORMALASCIIZ));
-		CPString cp2 = new CPString(new CPUTF8(new String("3"), ClassConstantPool.DOMAIN_NORMALASCIIZ));
-		CPString cp3 = new CPString(new CPUTF8(new String("5"), ClassConstantPool.DOMAIN_NORMALASCIIZ));
-		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
-	}
-	public void testCPField() {
-		CPMember cp1 = new CPMember(new CPUTF8("Name", ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I", ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
-		CPMember cp2 = new CPMember(new CPUTF8("Name", ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I", ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
-		CPMember cp3 = new CPMember(new CPUTF8("Name", ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("Z", ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
-		CPMember cp4 = new CPMember(new CPUTF8("GName", ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I", ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
-		checkEquality(cp1,cp2,"Name",cp3); //$NON-NLS-1$
-		checkEquality(cp1,cp2,"I",cp4); //$NON-NLS-1$
-	}
+    public void testUTF8() {
+        CPUTF8 u1 = new CPUTF8(
+                new String("thing"), ClassConstantPool.DOMAIN_NORMALASCIIZ); //$NON-NLS-1$
+        CPUTF8 u2 = new CPUTF8(
+                new String("thing"), ClassConstantPool.DOMAIN_NORMALASCIIZ); //$NON-NLS-1$
+        CPUTF8 u3 = new CPUTF8(
+                new String("otherthing"), ClassConstantPool.DOMAIN_NORMALASCIIZ); //$NON-NLS-1$
+        checkEquality(u1, u2, "thing", u3);
+    }
+
+    private void checkEquality(Object equal1, Object equal2, String toString,
+            Object unequal) {
+        assertEquals(equal1, equal2);
+        assertEquals(equal1.hashCode(), equal2.hashCode());
+        assertTrue(equal1.toString().indexOf(toString) >= 0);
+        assertFalse(equal1.equals(unequal));
+        assertFalse(equal2.equals(unequal));
+        assertFalse(unequal.equals(equal1));
+        assertFalse(unequal.equals(equal2));
+    }
+
+    public void testSourceAttribute() {
+        SourceFileAttribute sfa1 = new SourceFileAttribute(
+                new CPUTF8(
+                        new String("Thing.java"), ClassConstantPool.DOMAIN_NORMALASCIIZ)); //$NON-NLS-1$
+        SourceFileAttribute sfa2 = new SourceFileAttribute(
+                new CPUTF8(
+                        new String("Thing.java"), ClassConstantPool.DOMAIN_NORMALASCIIZ)); //$NON-NLS-1$
+        SourceFileAttribute sfa3 = new SourceFileAttribute(
+                new CPUTF8(
+                        new String("OtherThing.java"), ClassConstantPool.DOMAIN_NORMALASCIIZ)); //$NON-NLS-1$
+        checkEquality(sfa1, sfa2, "Thing.java", sfa3); //$NON-NLS-1$
+    }
+
+    public void testCPInteger() {
+        CPInteger cp1 = new CPInteger(new Integer(3));
+        CPInteger cp2 = new CPInteger(new Integer(3));
+        CPInteger cp3 = new CPInteger(new Integer(5));
+        checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
+    }
+
+    public void testCPLong() {
+        CPLong cp1 = new CPLong(new Long(3));
+        CPLong cp2 = new CPLong(new Long(3));
+        CPLong cp3 = new CPLong(new Long(5));
+        checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
+    }
+
+    public void testCPDouble() {
+        CPDouble cp1 = new CPDouble(new Double(3));
+        CPDouble cp2 = new CPDouble(new Double(3));
+        CPDouble cp3 = new CPDouble(new Double(5));
+        checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
+    }
+
+    public void testCPFloat() {
+        CPFloat cp1 = new CPFloat(new Float(3));
+        CPFloat cp2 = new CPFloat(new Float(3));
+        CPFloat cp3 = new CPFloat(new Float(5));
+        checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
+    }
+
+    public void testCPString() {
+        CPString cp1 = new CPString(new CPUTF8(new String("3"),
+                ClassConstantPool.DOMAIN_NORMALASCIIZ));
+        CPString cp2 = new CPString(new CPUTF8(new String("3"),
+                ClassConstantPool.DOMAIN_NORMALASCIIZ));
+        CPString cp3 = new CPString(new CPUTF8(new String("5"),
+                ClassConstantPool.DOMAIN_NORMALASCIIZ));
+        checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
+    }
+
+    public void testCPField() {
+        CPMember cp1 = new CPMember(new CPUTF8("Name",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
+        CPMember cp2 = new CPMember(new CPUTF8("Name",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
+        CPMember cp3 = new CPMember(new CPUTF8("Name",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("Z",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
+        CPMember cp4 = new CPMember(new CPUTF8("GName",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
+        checkEquality(cp1, cp2, "Name", cp3); //$NON-NLS-1$
+        checkEquality(cp1, cp2, "I", cp4); //$NON-NLS-1$
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java?rev=647100&r1=647099&r2=647100&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java Fri Apr 11 03:09:38 2008
@@ -25,37 +25,49 @@
 import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 
 public class ConstantPoolTest extends TestCase {
-	private ClassConstantPool pool;
 
-	public void setUp() {
-		pool = new ClassConstantPool();
-	}
-	public void testDuplicateUTF8() {
-		CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
-		CPUTF8 u2 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
-		pool.add(u1);
-		pool.add(u2);
-		assertEquals(1,pool.size());
-	}
-	public void testDuplicateField() {
-		CPMember cp1 = new CPMember(new CPUTF8("name", ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I", ClassConstantPool.DOMAIN_NORMALASCIIZ),0,null);
-		pool.add(cp1);
-		assertEquals(2,pool.size());
-		CPMember cp2 = new CPMember(new CPUTF8("name", ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I", ClassConstantPool.DOMAIN_NORMALASCIIZ),0,null);
-		pool.add(cp2);
-		assertEquals(2,pool.size());
-	}
-	public void testIndex() {
-		pool.add(new CPUTF8("OtherThing", ClassConstantPool.DOMAIN_NORMALASCIIZ));
-		CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
-		pool.add(u1);
-		pool.resolve(new Segment());
-		assertTrue(pool.indexOf(u1) > 0);
-	}
-
-	public void testAllClasses() {
-	    pool.add(new CPClass(new CPUTF8("RandomClass", ClassConstantPool.DOMAIN_NORMALASCIIZ)));
-        pool.add(new CPClass(new CPUTF8("RandomClass2", ClassConstantPool.DOMAIN_NORMALASCIIZ)));
-	    assertEquals(2, pool.allClasses().size());
-	}
+    private ClassConstantPool pool;
+
+    public void setUp() {
+        pool = new ClassConstantPool();
+    }
+
+    public void testDuplicateUTF8() {
+        CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
+        CPUTF8 u2 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
+        pool.add(u1);
+        pool.add(u2);
+        assertEquals(1, pool.size());
+    }
+
+    public void testDuplicateField() {
+        CPMember cp1 = new CPMember(new CPUTF8("name",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
+        pool.add(cp1);
+        assertEquals(2, pool.size());
+        CPMember cp2 = new CPMember(new CPUTF8("name",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), new CPUTF8("I",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ), 0, null);
+        pool.add(cp2);
+        assertEquals(2, pool.size());
+    }
+
+    public void testIndex() {
+        pool
+                .add(new CPUTF8("OtherThing",
+                        ClassConstantPool.DOMAIN_NORMALASCIIZ));
+        CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
+        pool.add(u1);
+        pool.resolve(new Segment());
+        assertTrue(pool.indexOf(u1) > 0);
+    }
+
+    public void testAllClasses() {
+        pool.add(new CPClass(new CPUTF8("RandomClass",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ)));
+        pool.add(new CPClass(new CPUTF8("RandomClass2",
+                ClassConstantPool.DOMAIN_NORMALASCIIZ)));
+        assertEquals(2, pool.allClasses().size());
+    }
 }



Mime
View raw message