Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
onukristo committed Oct 11, 2024
1 parent ade00eb commit 18b18df
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -60,7 +61,7 @@ static int[] getSeeds() {
var n = 128;
var result = new int[n];
for (int i = 0; i < n; i++) {
result[i] = i;
result[i] = ThreadLocalRandom.current().nextInt();
}
return result;
}
Expand All @@ -69,7 +70,6 @@ static int[] getSeeds() {
@MethodSource("getSeeds")
@SneakyThrows
public void testRandomAtIntBoundary(int seed) {
seed = 5;
var rnd = new Random(seed);

var originalBitmap = new LargeBitmapImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.ThreadLocalRandom;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -159,7 +160,7 @@ static int[] getSeeds() {
final var n = 128;
var result = new int[n];
for (int i = 0; i < n; i++) {
result[i] = i;
result[i] = ThreadLocalRandom.current().nextInt();
}
return result;
}
Expand Down Expand Up @@ -195,18 +196,26 @@ void testRandomRangeOverBoundary(int seed) {
bits.remove(bit);
bitmap.clear(bit);

assertThat(bits.first(), equalTo(bitmap.getFirstSetBit()));
assertThat(bits.last(), equalTo(bitmap.getFirstSetBit(bits.last())));
if (bits.isEmpty()) {
assertThat(bitmap.isEmpty(), equalTo(true));
} else {
assertThat(bits.first(), equalTo(bitmap.getFirstSetBit()));
assertThat(bits.last(), equalTo(bitmap.getFirstSetBit(bits.last())));
}
}

var lastBit = bits.first() - 1;
for (var bit : bits) {
for (long i = lastBit + 1; i < bit; i++) {
assertThat(bitmap.isSet(i), equalTo(false));
if (bits.isEmpty()) {
assertThat(bitmap.isEmpty(), equalTo(true));
} else {
var lastBit = bits.first() - 1;
for (var bit : bits) {
for (long i = lastBit + 1; i < bit; i++) {
assertThat(bitmap.isSet(i), equalTo(false));
}
assertThat(bitmap.isSet(bit), equalTo(true));

lastBit = bit;
}
assertThat(bitmap.isSet(bit), equalTo(true));

lastBit = bit;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -60,7 +61,7 @@ static int[] getSeeds() {
var n = 256;
var result = new int[n];
for (int i = 0; i < n; i++) {
result[i] = i;
result[i] = ThreadLocalRandom.current().nextInt();
}
return result;
}
Expand Down

0 comments on commit 18b18df

Please sign in to comment.