public void testTableLookup() { for (int i = 0; i <= 255; ++i) { byte b = (byte) i; short s = MuLawDecoderUtil.muLawDecode(b); short sLookup = (short) ULAW_TO_LINEAR_16_BIT[UnsignedUtils.uByteToInt(b)]; assertEquals(s, sLookup); } }
private void test(byte b) { short s = MuLawDecoderUtil.muLawDecode(b); byte bEncoded = MuLawEncoderUtil.muLawEncode(s); // if (b != bEncoded) // System.err.println("b != bEncoded " + b + " " + bEncoded + " s=" + // s); if (b == 127) { assertEquals(bEncoded, -1); // there are 2 values that can yield the // same short value of 0 - -1 and 127. assertEquals(s, 0); } else assertEquals(b, bEncoded); }