Add testBounds() to DiskStoreTest

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 4 years ago
parent 9de0b26da4
commit ad5f714982
  1. 87
      cache/src/test/java/dev/openrs2/cache/DiskStoreTest.kt

@ -17,6 +17,93 @@ import kotlin.test.assertTrue
object DiskStoreTest { object DiskStoreTest {
private val root = Paths.get(DiskStoreTest::class.java.getResource("disk-store").toURI()) private val root = Paths.get(DiskStoreTest::class.java.getResource("disk-store").toURI())
@Test
fun testBounds() {
readTest("empty") { store ->
assertThrows<IllegalArgumentException> {
store.exists(-1)
}
assertThrows<IllegalArgumentException> {
store.exists(256)
}
assertThrows<IllegalArgumentException> {
store.list(-1)
}
assertThrows<IllegalArgumentException> {
store.list(256)
}
assertThrows<IllegalArgumentException> {
store.exists(-1, 0)
}
assertThrows<IllegalArgumentException> {
store.exists(256, 0)
}
assertThrows<IllegalArgumentException> {
store.exists(0, -1)
}
assertThrows<IllegalArgumentException> {
store.read(-1, 0).release()
}
assertThrows<IllegalArgumentException> {
store.read(256, 0).release()
}
assertThrows<IllegalArgumentException> {
store.read(0, -1).release()
}
}
writeTest("empty") { store ->
assertThrows<IllegalArgumentException> {
store.create(-1)
}
assertThrows<IllegalArgumentException> {
store.create(256)
}
assertThrows<IllegalArgumentException> {
store.write(-1, 0, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
store.write(256, 0, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
store.write(0, -1, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
store.remove(-1)
}
assertThrows<IllegalArgumentException> {
store.remove(256)
}
assertThrows<IllegalArgumentException> {
store.remove(-1, 0)
}
assertThrows<IllegalArgumentException> {
store.remove(256, 0)
}
assertThrows<IllegalArgumentException> {
store.remove(0, -1)
}
}
}
@Test @Test
fun testCreateArchive() { fun testCreateArchive() {
writeTest("empty-archive") { store -> writeTest("empty-archive") { store ->

Loading…
Cancel
Save