From 08b4f6ae60bd05ee86f16a07cfe5e0ea27f875e3 Mon Sep 17 00:00:00 2001 From: Bryan Chan Date: Mon, 29 Jun 2015 15:53:10 -0400 Subject: [PATCH] Detect the native byte order and use the correct expected value --- .../java/org/xerial/snappy/SnappyOutputStreamTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/xerial/snappy/SnappyOutputStreamTest.java b/src/test/java/org/xerial/snappy/SnappyOutputStreamTest.java index d596668..df97fd3 100755 --- a/src/test/java/org/xerial/snappy/SnappyOutputStreamTest.java +++ b/src/test/java/org/xerial/snappy/SnappyOutputStreamTest.java @@ -31,6 +31,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.ref.WeakReference; +import java.nio.ByteOrder; import org.junit.Test; import org.xerial.snappy.buffer.BufferAllocatorFactory; @@ -163,10 +164,11 @@ public class SnappyOutputStreamTest // Compress the data once so that we know the expected size: byte[] expectedCompressedData = compressAsChunks(orig, Integer.MAX_VALUE); // Hardcoding an expected compressed size here will catch regressions that lower the - // compression quality. On little-endian platforms, the expected size is 91013; on - // big-endian platforms, the expected size is 90943. - assertTrue(String.format("unexpected compressed data size (%d)", expectedCompressedData.length), - (expectedCompressedData.length == 91013 || expectedCompressedData.length == 90943)); + // compression quality: + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) + assertEquals(90943, expectedCompressedData.length); + else + assertEquals(91013, expectedCompressedData.length); // The chunk size should not affect the size of the compressed output: int[] chunkSizes = new int[] {1, 100, 1023, 1024, 10000}; for (int chunkSize : chunkSizes) {