blob: 99e3130f3a3e361293b413d439eb264e497522d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.compress;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
/**
* @author bjorncs
*/
class ZstdOuputStreamTest {
@Test
void output_stream_compresses_input() throws IOException {
byte[] inputData = "The quick brown fox jumps over the lazy dog".getBytes();
ByteArrayOutputStream arrayOut = new ByteArrayOutputStream();
try (ZstdOuputStream zstdOut = new ZstdOuputStream(arrayOut, 12)) {
zstdOut.write(inputData[0]);
zstdOut.write(inputData, 1, inputData.length - 1);
}
byte[] compressedData = arrayOut.toByteArray();
ZstdCompressor compressor = new ZstdCompressor();
byte[] decompressedData = new byte[inputData.length];
compressor.decompress(compressedData, 0, compressedData.length, decompressedData, 0, decompressedData.length);
assertArrayEquals(inputData, decompressedData);
}
}
|