From 03b20861e9d5ec19a4dfbc026a0b2dfcd46759c2 Mon Sep 17 00:00:00 2001 From: Mike Barry Date: Fri, 15 Nov 2024 05:20:57 -0500 Subject: [PATCH] fix test --- .../collection/AppendStoreTest.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/planetiler-core/src/test/java/com/onthegomap/planetiler/collection/AppendStoreTest.java b/planetiler-core/src/test/java/com/onthegomap/planetiler/collection/AppendStoreTest.java index 3b9eac02bb..626e339b84 100644 --- a/planetiler-core/src/test/java/com/onthegomap/planetiler/collection/AppendStoreTest.java +++ b/planetiler-core/src/test/java/com/onthegomap/planetiler/collection/AppendStoreTest.java @@ -3,7 +3,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import java.io.IOException; import java.nio.file.Path; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -16,6 +18,11 @@ abstract static class IntsTest { protected AppendStore.Ints store; + @AfterEach + void close() throws IOException { + store.close(); + } + @ParameterizedTest @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) void writeThenRead(int num) { @@ -44,6 +51,11 @@ abstract static class LongsTest { protected AppendStore.Longs store; + @AfterEach + void close() throws IOException { + store.close(); + } + @ParameterizedTest @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) void writeThenRead(int num) { @@ -57,10 +69,11 @@ void writeThenRead(int num) { assertThrows(IndexOutOfBoundsException.class, () -> store.getLong(num + 1)); } - private static final long maxInt = Integer.MAX_VALUE; + private static final long MAX_INT = Integer.MAX_VALUE; @ParameterizedTest - @ValueSource(longs = {maxInt - 1, maxInt, maxInt + 1, 2 * maxInt - 1, 2 * maxInt, 5 * maxInt - 1, 5 * maxInt + 1}) + @ValueSource(longs = {MAX_INT - 1, + MAX_INT, MAX_INT + 1, 2 * MAX_INT - 1, 2 * MAX_INT, 5 * MAX_INT - 1, 5 * MAX_INT + 1}) void readBig(long value) { store.appendLong(value); assertEquals(value, store.getLong(0)); @@ -121,7 +134,7 @@ static class MMapSmallLongTest extends LongsTest { @BeforeEach void setup(@TempDir Path path) { this.store = new AppendStore.SmallLongs( - (i) -> new AppendStoreMmap.Ints(path.resolve("smalllongs" + i), 4 << 2, true)); + i -> new AppendStoreMmap.Ints(path.resolve("smalllongs" + i), 4 << 2, true)); } } @@ -129,7 +142,7 @@ static class RamSmallLongTest extends LongsTest { @BeforeEach void setup() { - this.store = new AppendStore.SmallLongs((i) -> new AppendStoreRam.Ints(false, 4 << 2)); + this.store = new AppendStore.SmallLongs(i -> new AppendStoreRam.Ints(false, 4 << 2)); } } @@ -137,7 +150,7 @@ static class DirectSmallLongTest extends LongsTest { @BeforeEach void setup() { - this.store = new AppendStore.SmallLongs((i) -> new AppendStoreRam.Ints(true, 4 << 2)); + this.store = new AppendStore.SmallLongs(i -> new AppendStoreRam.Ints(true, 4 << 2)); } } }