diff --git a/cache/src/test/java/dev/openrs2/cache/DiskStoreTest.kt b/cache/src/test/java/dev/openrs2/cache/DiskStoreTest.kt index a1ec3578..38dccb25 100644 --- a/cache/src/test/java/dev/openrs2/cache/DiskStoreTest.kt +++ b/cache/src/test/java/dev/openrs2/cache/DiskStoreTest.kt @@ -17,6 +17,93 @@ import kotlin.test.assertTrue object DiskStoreTest { private val root = Paths.get(DiskStoreTest::class.java.getResource("disk-store").toURI()) + @Test + fun testBounds() { + readTest("empty") { store -> + assertThrows { + store.exists(-1) + } + + assertThrows { + store.exists(256) + } + + assertThrows { + store.list(-1) + } + + assertThrows { + store.list(256) + } + + assertThrows { + store.exists(-1, 0) + } + + assertThrows { + store.exists(256, 0) + } + + assertThrows { + store.exists(0, -1) + } + + assertThrows { + store.read(-1, 0).release() + } + + assertThrows { + store.read(256, 0).release() + } + + assertThrows { + store.read(0, -1).release() + } + } + + writeTest("empty") { store -> + assertThrows { + store.create(-1) + } + + assertThrows { + store.create(256) + } + + assertThrows { + store.write(-1, 0, Unpooled.EMPTY_BUFFER) + } + + assertThrows { + store.write(256, 0, Unpooled.EMPTY_BUFFER) + } + + assertThrows { + store.write(0, -1, Unpooled.EMPTY_BUFFER) + } + + assertThrows { + store.remove(-1) + } + + assertThrows { + store.remove(256) + } + + assertThrows { + store.remove(-1, 0) + } + + assertThrows { + store.remove(256, 0) + } + + assertThrows { + store.remove(0, -1) + } + } + } + @Test fun testCreateArchive() { writeTest("empty-archive") { store ->