File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
main/java/com/comphenix/protocol/collections
test/java/com/comphenix/protocol/collections Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -76,8 +76,7 @@ protected void ensureCapacity(int key) {
76
76
77
77
// Fast calculation of the new size.
78
78
// See IntMath#ceilingPowerOfTwo in newer guava versions.
79
- int newLength = IntegerMath .nextPowerOfTwo (key );
80
-
79
+ int newLength = IntegerMath .nextPowerOfTwo (key + 1 );
81
80
this .array = Arrays .copyOf (array , newLength );
82
81
}
83
82
Original file line number Diff line number Diff line change
1
+ package com .comphenix .protocol .collections ;
2
+
3
+ import com .comphenix .protocol .utility .IntegerMath ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
7
+
8
+ class IntegerMapTest {
9
+ @ Test
10
+ public void testNextPower () {
11
+ assertEquals (128 , IntegerMath .nextPowerOfTwo (127 ));
12
+ assertEquals (128 , IntegerMath .nextPowerOfTwo (128 ));
13
+ assertEquals (256 , IntegerMath .nextPowerOfTwo (129 ));
14
+ }
15
+ @ Test
16
+ public void testCapacityIncrement () {
17
+ IntegerMap <Boolean > map = new IntegerMap <>();
18
+ for (int i = 0 ; i < 512 ; i ++) {
19
+ map .put (i , false );
20
+ }
21
+ assertEquals (map .size (), 512 );
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments