Add support for more methods in TruncatingInputStream.

This commit is contained in:
Greyson Parrelli
2024-09-05 16:40:18 -04:00
committed by Cody Henthorne
parent 929942de9d
commit b00855b097
4 changed files with 176 additions and 3 deletions

View File

@@ -19,4 +19,20 @@ class InputStreamExtensionTests {
assertEquals(bytes.size.toLong(), length)
}
}
@Test
fun `when I call readAtMostNBytes, I only read that many bytes`() {
val bytes = ByteArray(100)
val inputStream = bytes.inputStream()
val readBytes = inputStream.readAtMostNBytes(50)
assertEquals(50, readBytes.size)
}
@Test
fun `when I call readAtMostNBytes, it will return at most the length of the stream`() {
val bytes = ByteArray(100)
val inputStream = bytes.inputStream()
val readBytes = inputStream.readAtMostNBytes(200)
assertEquals(100, readBytes.size)
}
}