Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import io.github.dfa1.zstd.ZstdException;
import io.github.dfa1.zstd.ZstdFrame;
import io.github.dfa1.zstd.ZstdInputStream;
import com.github.luben.zstd.ZstdDictCompress;
import com.github.luben.zstd.ZstdDictDecompress;
import org.junit.jupiter.api.Named;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down Expand Up @@ -185,8 +188,12 @@ void javaDecodeThrows(String name, Path file) {
@Nested
class GoldenDictionaries {

static Stream<Arguments> dictionaries() {
return filesIn("golden-dictionaries", "");
static Stream<Named<Path>> dictionaries() {
return filesIn("golden-dictionaries", "")
.map(args -> {
Object[] a = args.get();
return Named.of((String) a[0], (Path) a[1]);
});
}

private byte[] payload() {
Expand All @@ -195,7 +202,7 @@ private byte[] payload() {

@ParameterizedTest(name = "{0}")
@MethodSource("dictionaries")
void javaDictCompressJniDictDecompress(String name, Path file) {
void javaDictCompressJniDictDecompress(Path file) {
// Given
byte[] raw = read(file);
byte[] data = payload();
Expand All @@ -206,20 +213,19 @@ void javaDictCompressJniDictDecompress(String name, Path file) {
}

// When
var jniDict = new com.github.luben.zstd.ZstdDictDecompress(raw);
byte[] restored = com.github.luben.zstd.Zstd.decompress(frame, jniDict, data.length);
byte[] restored = com.github.luben.zstd.Zstd.decompress(frame, new ZstdDictDecompress(raw), data.length);

// Then
assertThat(restored).isEqualTo(data);
}

@ParameterizedTest(name = "{0}")
@MethodSource("dictionaries")
void jniDictCompressJavaDictDecompress(String name, Path file) {
void jniDictCompressJavaDictDecompress(Path file) {
// Given
byte[] raw = read(file);
byte[] data = payload();
var jniDict = new com.github.luben.zstd.ZstdDictCompress(raw, Zstd.defaultCompressionLevel());
ZstdDictCompress jniDict = new ZstdDictCompress(raw, Zstd.defaultCompressionLevel());
byte[] frame = com.github.luben.zstd.Zstd.compress(data, jniDict);

// When
Expand All @@ -234,7 +240,7 @@ void jniDictCompressJavaDictDecompress(String name, Path file) {

@ParameterizedTest(name = "{0}")
@MethodSource("dictionaries")
void dictIdRidesWithFrame(String name, Path file) {
void dictIdRidesWithFrame(Path file) {
// Given
byte[] raw = read(file);
ZstdDictionary dict = ZstdDictionary.of(raw);
Expand Down
Loading