Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Nov 15, 2024
1 parent 9646958 commit 03b2086
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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));
Expand Down Expand Up @@ -121,23 +134,23 @@ 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));
}
}

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));
}
}

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));
}
}
}

0 comments on commit 03b2086

Please sign in to comment.