Skip to content

Commit 104785e

Browse files
committed
Added a shiftRemove test after the bug found in Chronicle Map
1 parent 6d0a187 commit 104785e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/java/net/openhft/smoothie/ShiftRemoveTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package net.openhft.smoothie;
1818

1919
import com.google.common.collect.ImmutableSet;
20+
import org.jetbrains.annotations.Nullable;
2021
import org.junit.Test;
2122

2223
import static org.junit.Assert.assertEquals;
@@ -44,4 +45,21 @@ public int hashCode() {
4445
return 0;
4546
}
4647
}
48+
49+
@Test
50+
public void shiftRemoveEarlyBreakTest() {
51+
SmoothieMap<Long, Integer> map = new SmoothieMap<Long, Integer>() {
52+
@Override
53+
protected long keyHashCode(@Nullable Object key) {
54+
return ((Long) key).longValue();
55+
}
56+
};
57+
58+
map.put(0L, 0);
59+
map.put(2L << (64 - Segment.LOG_HASH_TABLE_SIZE), 2);
60+
map.put(3L << (64 - Segment.LOG_HASH_TABLE_SIZE), 3);
61+
62+
map.removeIf((k, v) -> true);
63+
assertEquals(0, map.size());
64+
}
4765
}

0 commit comments

Comments
 (0)