Package org.apache.harmony.pack200

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


                // range of the codec
                long largest = codec.largest();
                long smallest = codec.isSigned() ? codec.smallest() : 0;
                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) {
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

                // range of the codec
                long largest = codec.largest();
                long smallest = codec.isSigned() ? codec.smallest() : 0;
                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) {
View Full Code Here

                    }
                }
            }

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

}
View Full Code Here

            BHSDCodec codec = (BHSDCodec) CodecEncoding.getCodec(i, null, null);

            // 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

            BHSDCodec codec = (BHSDCodec) CodecEncoding.getCodec(i, null, null);
           
            // 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

                long difference = (largest - smallest) / 4;
                for (long j = smallest; j <= largest; j += difference) {
                    if(j > Integer.MAX_VALUE) {
                        break;
                    }
                    byte[] encoded = codec.encode((int)j, 0);
                    long decoded = 0;
                    try {
                        decoded = codec.decode(
                                new ByteArrayInputStream(encoded), 0);
                    } catch (EOFException e) {
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

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.