HIGUCHI Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 1 | package org.onlab.graph; |
| 2 | |
| 3 | import static org.junit.Assert.*; |
| 4 | |
| 5 | import org.junit.Test; |
| 6 | |
| 7 | import com.google.common.collect.ImmutableList; |
| 8 | import com.google.common.testing.EqualsTester; |
| 9 | |
| 10 | /** |
| 11 | * Test of DisjointPathPair. |
| 12 | */ |
| 13 | public class DisjointPathPairTest { |
| 14 | |
| 15 | private static final TestVertex A = new TestVertex("A"); |
| 16 | private static final TestVertex B = new TestVertex("B"); |
| 17 | private static final TestVertex C = new TestVertex("C"); |
| 18 | private static final TestVertex D = new TestVertex("D"); |
| 19 | |
| 20 | private static final TestEdge AB = new TestEdge(A, B, 1.0); |
| 21 | private static final TestEdge BC = new TestEdge(B, C, 1.0); |
| 22 | private static final TestEdge AD = new TestEdge(A, D, 1.0); |
| 23 | private static final TestEdge DC = new TestEdge(D, C, 1.0); |
| 24 | |
| 25 | private static final Path<TestVertex, TestEdge> ABC |
| 26 | = new DefaultPath<>(ImmutableList.of(AB, BC), 1.0); |
| 27 | private static final Path<TestVertex, TestEdge> ADC |
| 28 | = new DefaultPath<>(ImmutableList.of(AD, DC), 1.0); |
| 29 | |
| 30 | @Test |
| 31 | public void testSwappingPrimarySecondaryDoesntImpactHashCode() { |
| 32 | assertEquals(new DisjointPathPair<>(ABC, ADC).hashCode(), |
| 33 | new DisjointPathPair<>(ADC, ABC).hashCode()); |
| 34 | } |
| 35 | |
| 36 | @Test |
| 37 | public void testSwappingPrimarySecondaryDoesntImpactEquality() { |
| 38 | new EqualsTester() |
| 39 | .addEqualityGroup(new DisjointPathPair<>(ABC, ADC), |
| 40 | new DisjointPathPair<>(ADC, ABC)); |
| 41 | } |
| 42 | |
| 43 | } |