Package org.apache.harmony.pack200

Examples of org.apache.harmony.pack200.BHSDCodec.decode()


    }

    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);
        }
    }
View Full Code Here


      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);
    }
  }
View Full Code Here

    }

    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);
        }
    }
View Full Code Here

                long difference = (largest - smallest) / 4;
                for (long j = smallest; j <= largest; j += difference) {
                    byte[] encoded = codec.encode(j, 0);
                    long decoded = 0;
                    try {
                        decoded = codec.decode(
                                new ByteArrayInputStream(encoded), 0);
                    } catch (EOFException e) {
                        System.out.println(e);
                    }
                    if (j != decoded) {
View Full Code Here

                    }
                }
            }

            // Test encode-decode with 0
            assertEquals(0, codec.decode(new ByteArrayInputStream(codec.encode(
                    0, 0)), 0));
        }
    }

    public void testDeltaEncodings() throws IOException, Pack200Exception {
View Full Code Here

                long difference = (largest - smallest) / 4;
                for (long j = smallest; j <= largest; j += difference) {
                    byte[] encoded = codec.encode(j, 0);
                    long decoded = 0;
                    try {
                        decoded = codec.decode(
                                new ByteArrayInputStream(encoded), 0);
                    } catch (EOFException e) {
                        System.out.println(e);
                    }
                    if (j != decoded) {
View Full Code Here

                    }
                }
            }

            // Test encode-decode with 0
            assertEquals(0, codec.decode(new ByteArrayInputStream(codec.encode(
                    0, 0)), 0));
        }
    }

}
View Full Code Here

    }

    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);
        }
    }
View Full Code Here

            // Test encode-decode with a selection of numbers within the range of the codec
            long delta = (codec.largest() - codec.smallest()) / 4;
            for (long j = codec.smallest(); j <= codec.largest() + 1; j += delta) {
                byte[] encoded = codec.encode(j, 0);
                long decoded = codec.decode(new ByteArrayInputStream(encoded),
                        0);
                if (j != decoded) {
                    fail("Failed with codec: " + codec + " expected: " + j
                            + ", got: " + decoded);
                }
View Full Code Here

                            + ", got: " + decoded);
                }
            }

            // Test encode-decode with 0
            assertEquals(0, codec.decode(new ByteArrayInputStream(codec.encode(
                    0, 0)), 0));
        }
    }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.