/testability-explorer/src/test/java/com/google/test/metric/method/op/stack/SwapTest.java
Java | 48 lines | 25 code | 8 blank | 15 comment | 0 complexity | 63c93ecb63ba23edd04f5f3f4167ead7 MD5 | raw file
1/* 2 * Copyright 2007 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16package com.google.test.metric.method.op.stack; 17 18import java.util.ArrayList; 19import java.util.List; 20 21import junit.framework.TestCase; 22 23import com.google.test.metric.JavaType; 24import com.google.test.metric.Variable; 25 26public class SwapTest extends TestCase { 27 28 public void testOperatorCountIs2() throws Exception { 29 assertEquals(2, new Swap(-1).getOperatorCount()); 30 } 31 32 public void testApplySwaps() throws Exception { 33 Swap swap = new Swap(-1); 34 Variable first = new Variable(null, JavaType.BOOLEAN, false, false); 35 Variable second = new Variable(null, JavaType.BOOLEAN, false, false); 36 List<Variable> inputs = new ArrayList<Variable>(); 37 inputs.add(first); 38 inputs.add(second); 39 List<Variable> output = swap.apply(inputs); 40 assertSame(second, output.get(0)); 41 assertSame(first, output.get(1)); 42 } 43 44 public void testToString() { 45 assertEquals("swap", new Swap(-1).toString()); 46 } 47 48}