Skip to content

Commit 81312a7

Browse files
committed
ImmutableIntList of four does not store 2nd and 3rd element correctly.
1 parent b78047d commit 81312a7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/main/java/com/hivemq/client/internal/util/collections/ImmutableIntList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public interface ImmutableIntList {
4747
Checks.notNull(others, "Int array");
4848
final int[] array = new int[3 + others.length];
4949
array[0] = i1;
50-
array[0] = i2;
51-
array[0] = i3;
50+
array[1] = i2;
51+
array[2] = i3;
5252
System.arraycopy(others, 0, array, 3, others.length);
5353
return new ImmutableIntArray(array);
5454
}

src/test/java/com/hivemq/client/internal/util/collections/ImmutableIntListTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ void of_single() {
8080
assertSame(ImmutableIntElement.class, built1.getClass());
8181
}
8282

83+
@Test
84+
void of_four() {
85+
ImmutableIntList subject = ImmutableIntList.of(1, 2, 3, 4);
86+
assertEquals(1, subject.get(0));
87+
assertEquals(2, subject.get(1));
88+
assertEquals(3, subject.get(2));
89+
assertEquals(4, subject.get(3));
90+
}
91+
8392
@Test
8493
void of_multiple() {
8594
final ImmutableIntList of1 = ImmutableIntList.of(1, 2);

0 commit comments

Comments
 (0)