blob: d5b18fe85f60f4c260c244d796042ca0edf8e8ba [file] [log] [blame]
tom144de692014-08-29 11:38:44 -07001package org.onlab.graph;
2
3import org.junit.Test;
4
5import static com.google.common.collect.ImmutableSet.of;
6import static org.junit.Assert.assertEquals;
7
8/**
9 * Base for all graph search tests.
10 */
11public abstract class AbstractGraphPathSearchTest extends GraphTest {
12
13 /**
14 * Creates a test-specific graph search to exercise.
15 *
16 * @return graph search
17 */
18 protected abstract AbstractGraphPathSearch<TestVertex, TestEdge> graphSearch();
19
20 @Test(expected = IllegalArgumentException.class)
21 public void noSuchSourceArgument() {
22 graphSearch().search(new AdjacencyListsGraph<>(of(B, C),
23 of(new TestEdge(B, C, 1))),
24 A, H, weight);
25 }
26
27 @Test(expected = NullPointerException.class)
28 public void nullGraphArgument() {
29 graphSearch().search(null, A, H, weight);
30 }
31
32 @Test(expected = NullPointerException.class)
33 public void nullSourceArgument() {
34 graphSearch().search(new AdjacencyListsGraph<>(of(B, C),
35 of(new TestEdge(B, C, 1))),
36 null, H, weight);
37 }
38
39 @Test
40 public void samenessThreshold() {
41 AbstractGraphPathSearch<TestVertex, TestEdge> search = graphSearch();
42 search.setSamenessThreshold(0.3);
43 assertEquals("incorrect threshold", 0.3, search.samenessThreshold(), 0.01);
44 }
45
46}