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

How should ZstdDecompressor.getDecompressedSize work? #106

Open
mcraiha opened this issue Mar 1, 2020 · 0 comments
Open

How should ZstdDecompressor.getDecompressedSize work? #106

mcraiha opened this issue Mar 1, 2020 · 0 comments

Comments

@mcraiha
Copy link

mcraiha commented Mar 1, 2020

Hi,

I am trying to port ZstdDecompressor to C# and I have hard time understanding how ZstdDecompressor.getDecompressedSize should work.

If I modify testDecompressWithOutputPaddingAndChecksum() to following

public void testDecompressWithOutputPaddingAndChecksum()
            throws IOException
    {
        int padding = 1021;

        byte[] compressed = Resources.toByteArray(getClass().getClassLoader().getResource("data/zstd/with-checksum.zst"));
        byte[] uncompressed = Resources.toByteArray(getClass().getClassLoader().getResource("data/zstd/with-checksum"));

        byte[] output = new byte[uncompressed.length + padding * 2]; // pre + post padding
        int decompressedSize = getDecompressor().decompress(compressed, 0, compressed.length, output, padding, output.length);

        long decompressedSize2 = ZstdDecompressor.getDecompressedSize(compressed, 0, compressed.length);

        assertEquals(decompressedSize2, 11359, "Should be equal");
        assertByteArraysEqual(uncompressed, 0, uncompressed.length, output, padding, decompressedSize);
    }

then the decompressedSize2 has value -1 and test fails. Am I missing something in here?

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

1 participant