Skip to content

Commit

Permalink
make test data generating more scalish
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-char committed Dec 20, 2023
1 parent c0b9d76 commit c692cf8
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,20 @@ class ZstdDecompressOutputStreamTest extends FunSuite {
}

private def generateData(size: Int): Array[Byte] = {
val builder = Array.newBuilder[Byte]
var i = 0
while (i < size) {
builder += (i % 256).toByte
i += 1
}
builder.result()
1.to(size).map(i => (i % 256).toByte).toArray
}

test("decompress zstd stream") {
val chunkSize = 4 * 1024
val testCases = Seq(0, 1, chunkSize, 10 * 1024 * 1024)

for (testCase <- testCases) {
println(s"Test case: $testCase")

val original_data = generateData(testCase)
val original_sha256 = computeSha256(original_data)

println(s"Original data size: ${original_data.length}")
val compressed_data = Zstd.compress(original_data, 9)
println(s"Compressed data size: ${compressed_data.length}")

val sourceStream = ByteBuffer.wrap(compressed_data)
val targetStream = new ByteArrayOutputStream()
Expand Down

0 comments on commit c692cf8

Please sign in to comment.