mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Update test
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user