-
Notifications
You must be signed in to change notification settings - Fork 11k
Closed
Labels
P3no SLOno SLOpackage=graphstatus=triagedtype=defectBug, not working as expectedBug, not working as expected
Description
Let p
be an EndpointPair<Integer>
. The method AbstractBaseGraph#edges can return a Set<EndpointPair<Integer>> edges
for which edges.contains(p)
is true
, but e.equals(p)
is false
for each element e
. This violates the contract of java.util.Collection#contains:
Returns true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that Objects.equals(o, e).
Note the failing assertion in the following test:
@Test
public void contains_contract_violated() {
MutableGraph<Integer> undirectedGraph = GraphBuilder.undirected().build();
undirectedGraph.putEdge(1, 2);
Set<EndpointPair<Integer>> edges = undirectedGraph.edges();
EndpointPair<Integer> ordered = EndpointPair.ordered(1, 2);
Assertions.assertTrue(edges.contains(ordered));
Assertions.assertTrue(edges.stream().anyMatch(ordered::equals)); // fails
}
jbduncan
Metadata
Metadata
Assignees
Labels
P3no SLOno SLOpackage=graphstatus=triagedtype=defectBug, not working as expectedBug, not working as expected