From ad5f7149820420bacc40ffa44954568479a989c5 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 23 Aug 2020 22:58:25 +0100 Subject: [PATCH] Add testBounds() to DiskStoreTest Signed-off-by: Graham --- .../java/dev/openrs2/cache/DiskStoreTest.kt | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/cache/src/test/java/dev/openrs2/cache/DiskStoreTest.kt b/cache/src/test/java/dev/openrs2/cache/DiskStoreTest.kt index a1ec357876..38dccb259e 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 ->