mirror of
https://github.com/xerial/snappy-java.git
synced 2025-07-19 03:54:27 +02:00
Detect the native byte order and use the correct expected value
This commit is contained in:
parent
d8600ed65e
commit
08b4f6ae60
@ -31,6 +31,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.xerial.snappy.buffer.BufferAllocatorFactory;
|
import org.xerial.snappy.buffer.BufferAllocatorFactory;
|
||||||
@ -163,10 +164,11 @@ public class SnappyOutputStreamTest
|
|||||||
// Compress the data once so that we know the expected size:
|
// Compress the data once so that we know the expected size:
|
||||||
byte[] expectedCompressedData = compressAsChunks(orig, Integer.MAX_VALUE);
|
byte[] expectedCompressedData = compressAsChunks(orig, Integer.MAX_VALUE);
|
||||||
// Hardcoding an expected compressed size here will catch regressions that lower the
|
// Hardcoding an expected compressed size here will catch regressions that lower the
|
||||||
// compression quality. On little-endian platforms, the expected size is 91013; on
|
// compression quality:
|
||||||
// big-endian platforms, the expected size is 90943.
|
if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||||
assertTrue(String.format("unexpected compressed data size (%d)", expectedCompressedData.length),
|
assertEquals(90943, expectedCompressedData.length);
|
||||||
(expectedCompressedData.length == 91013 || expectedCompressedData.length == 90943));
|
else
|
||||||
|
assertEquals(91013, expectedCompressedData.length);
|
||||||
// The chunk size should not affect the size of the compressed output:
|
// The chunk size should not affect the size of the compressed output:
|
||||||
int[] chunkSizes = new int[] {1, 100, 1023, 1024, 10000};
|
int[] chunkSizes = new int[] {1, 100, 1023, 1024, 10000};
|
||||||
for (int chunkSize : chunkSizes) {
|
for (int chunkSize : chunkSizes) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user