Add test for isValidCompressedBuffer. Add a comment on the usage of SnappyOutputStream

This commit is contained in:
Taro L. Saito 2011-06-20 09:32:11 +09:00
parent 7795673e0c
commit ae6a126d1c
2 changed files with 18 additions and 2 deletions

View File

@ -34,8 +34,14 @@ import java.io.OutputStream;
* The input data is blocked into 32kb size (in default), and each block is * The input data is blocked into 32kb size (in default), and each block is
* compressed and then passed to the given {@link OutputStream}. * compressed and then passed to the given {@link OutputStream}.
* *
* The output data format is a sequence of (compressed chunk size, compressed * The output data format is a sequence of (compressed data size, compressed
* data chunk binary...) pair. * data...) pair.
*
* Note that the compressed data created by {@link SnappyOutputStream} cannot be
* uncompressed by {@link Snappy#uncompress(byte[])} since the output formats of
* {@link Snappy#compress(byte[])} and {@link SnappyOutputStream} are different.
* Use {@link SnappyInputStream} for uncompress the data generated by
* {@link SnappyOutputStream}.
* *
* @author leo * @author leo
* *

View File

@ -283,4 +283,14 @@ public class SnappyTest
assertEquals(s, uncompressedString); assertEquals(s, uncompressedString);
} }
@Test
public void isValidCompressedData() throws Exception {
byte[] b = new byte[] { (byte) 91, (byte) 34, (byte) 80, (byte) 73, (byte) 34, (byte) 93 };
if (Snappy.isValidCompressedBuffer(b, 0, b.length)) {
byte[] uncompressed = Snappy.uncompress(b);
}
}
} }