Closed GoogleCodeExporter closed 8 years ago
This does also influence the contains method, this fails with TreeSet and
succeeds with HashSet
class MyComparable implements Comparable<MyComparable> {
private int number;
public MyComparable(int number) {
this.number = number;
}
public int getNumber() {
return number;
}
@Override
public int compareTo(MyComparable o) {
if ( o == null) {
return - 1;
}
return number - o.getNumber();
}
}
@Test
public void treesetTest() {
MyComparable doc1 = Mockito.mock(MyComparable.class);
MyComparable doc2 = Mockito.mock(MyComparable.class);
Set<MyComparable> docs = new TreeSet<>();
docs.add(doc1);
docs.add(doc2);
Assert.assertTrue(docs.contains(doc1));
}
Original comment by dieter.t...@googlemail.com
on 23 May 2013 at 12:30
Part:
- while adding different mocks into a TreeSet works ok after the fix for 184,
adding the same mock multiple times, does not. In fact, if you add a mock to a
TreeSet now, the TreeSet will deny that it contains that mock
Fixed in #467
Original comment by albers...@gmail.com
on 8 Jan 2014 at 12:11
Thanks to alberskib for is work on issue 467
Original comment by brice.du...@gmail.com
on 22 Jan 2014 at 5:37
Original issue reported on code.google.com by
midle...@gmail.com
on 26 Apr 2012 at 7:55