Update test

This commit is contained in:
J-Jamet
2021-03-24 16:13:28 +01:00
parent 59f24206ad
commit 23e7bf9f89

View File

@@ -93,11 +93,28 @@ class BinaryDataTest {
@Test @Test
fun testCompressBytes() { fun testCompressBytes() {
// Test random byte array
val byteArray = ByteArray(50) val byteArray = ByteArray(50)
Random.nextBytes(byteArray) Random.nextBytes(byteArray)
testCompressBytes(byteArray)
// Test empty byte array
testCompressBytes(ByteArray(0))
}
private fun testCompressBytes(byteArray: ByteArray) {
val binaryA = binaryCache.getBinaryData("0", true) val binaryA = binaryCache.getBinaryData("0", true)
binaryA.getOutputDataStream(binaryCache).use { outputStream ->
outputStream.write(byteArray)
}
val binaryB = binaryCache.getBinaryData("1", true) val binaryB = binaryCache.getBinaryData("1", true)
binaryB.getOutputDataStream(binaryCache).use { outputStream ->
outputStream.write(byteArray)
}
val binaryC = binaryCache.getBinaryData("2", true) val binaryC = binaryCache.getBinaryData("2", true)
binaryC.getOutputDataStream(binaryCache).use { outputStream ->
outputStream.write(byteArray)
}
binaryA.compress(binaryCache) binaryA.compress(binaryCache)
binaryB.compress(binaryCache) binaryB.compress(binaryCache)
assertEquals("Compress bytes decompressed failed.", binaryA.isCompressed, true) assertEquals("Compress bytes decompressed failed.", binaryA.isCompressed, true)