Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify IntelInflater API #47

Closed
gspowley opened this issue Feb 23, 2017 · 1 comment
Closed

Modify IntelInflater API #47

gspowley opened this issue Feb 23, 2017 · 1 comment
Assignees

Comments

@gspowley
Copy link
Contributor

The IntelInflater API needs some changes to match the Inflater API.

  1. The IntelInflater should not require calling reset() before use.
  2. When inflate(result) is called without specifying the length argument, length should default to result.length.

The following code will test these changes.

        final IntelInflaterFactory intelInflaterFactory = new IntelInflaterFactory();

        for (int i = 0; i < 10; i++) {
            // create deflater with compression level i
            final Deflater deflater = new Deflater(i, true);

            // setup deflater
            deflater.reset();
            deflater.setInput(input);
            deflater.finish();

            // compress data
            int compressedBytes = 0;
            while (!deflater.finished()) {
                compressedBytes = deflater.deflate(compressed, 0, compressed.length);
            }
            deflater.end();

            // log results
            log.info("%d bytes compressed to %d bytes : %2.2f%% compression\n",
                    LEN, compressedBytes, 100.0 - 100.0 * compressedBytes / LEN);

            // decompress and check output == input
            Inflater inflater = intelInflaterFactory.makeInflater(true);
            try {
                inflater.setInput(compressed, 0, compressedBytes);
                inflater.inflate(result);
                inflater.end();
            } catch (java.util.zip.DataFormatException e) {
                e.printStackTrace();
            }

            Assert.assertEquals(input, result);
        }
@gspowley
Copy link
Contributor Author

Closed with #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants