1 /* 2 * Copyright (C) 2014 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.graph; 18 19 import java.util.Arrays; 20 import java.util.Collection; 21 import org.junit.runner.RunWith; 22 import org.junit.runners.Parameterized; 23 import org.junit.runners.Parameterized.Parameters; 24 25 /** Tests for an undirected {@link StandardMutableGraph}. */ 26 @AndroidIncompatible 27 @RunWith(Parameterized.class) 28 public final class StandardImmutableUndirectedGraphTest 29 extends AbstractStandardUndirectedGraphTest { 30 31 @Parameters(name = "allowsSelfLoops={0}") parameters()32 public static Collection<Object[]> parameters() { 33 return Arrays.asList(new Object[][] {{false}, {true}}); 34 } 35 36 private final boolean allowsSelfLoops; 37 private ImmutableGraph.Builder<Integer> graphBuilder; 38 StandardImmutableUndirectedGraphTest(boolean allowsSelfLoops)39 public StandardImmutableUndirectedGraphTest(boolean allowsSelfLoops) { 40 this.allowsSelfLoops = allowsSelfLoops; 41 } 42 43 @Override createGraph()44 public Graph<Integer> createGraph() { 45 graphBuilder = GraphBuilder.undirected().allowsSelfLoops(allowsSelfLoops).immutable(); 46 return graphBuilder.build(); 47 } 48 49 @Override addNode(Integer n)50 final void addNode(Integer n) { 51 graphBuilder.addNode(n); 52 graph = graphBuilder.build(); 53 } 54 55 @Override putEdge(Integer n1, Integer n2)56 final void putEdge(Integer n1, Integer n2) { 57 graphBuilder.putEdge(n1, n2); 58 graph = graphBuilder.build(); 59 } 60 } 61