indexOf on sorted lists should return the first match

This commit is contained in:
2017-12-09 15:50:55 +01:00
parent 14181822c9
commit 3dd1955749
2 changed files with 11 additions and 2 deletions

View File

@@ -680,6 +680,13 @@ public class IntListTest {
Assert.assertEquals(1, list.indexOf(2));
}
@Test
public void testIndexOfOnSortedListReturnsFirstMatch() {
final IntList list = IntList.of(0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4);
Assert.assertEquals(2, list.indexOf(2));
Assert.assertEquals(4, list.indexOf(2, 4));
}
@Test
public void testIndexOfOnUnsortedList() {
final IntList list = IntList.of(2, 0, 1);