add test for hashcode/equals with sorted and unsorted lists

This commit is contained in:
2018-01-22 18:22:14 +01:00
parent 67c16460d8
commit 7de2ac1fd3

View File

@@ -516,6 +516,7 @@ public class IntListTest {
Assert.assertTrue(list.isSorted());
}
@SuppressWarnings("unlikely-arg-type")
@Test
public void testHashCodeEquals() {
final IntList a = new IntList();
@@ -537,8 +538,6 @@ public class IntListTest {
Assert.assertTrue(a.equals(b));
Assert.assertEquals(a.hashCode(), b.hashCode());
// TODO sorted and unsorted lists with same length
// change one value
a.remove(2, 3);
a.insert(2, 99);
@@ -558,6 +557,12 @@ public class IntListTest {
// equals with a different class
Assert.assertFalse(a.equals("not an IntList"));
// sorted and unsorted lists with same length
final IntList sorted = IntList.of(1, 2, 3, 4);
final IntList unsorted = IntList.of(4, 3, 2, 1);
Assert.assertFalse(sorted.equals(unsorted));
Assert.assertNotEquals(sorted.hashCode(), unsorted.hashCode());
}
@Test