/testability-explorer/src/test/java/com/google/test/metric/method/op/stack/SwapTest.java

http://testability-explorer.googlecode.com/ · 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. */
  16. package com.google.test.metric.method.op.stack;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import junit.framework.TestCase;
  20. import com.google.test.metric.JavaType;
  21. import com.google.test.metric.Variable;
  22. public class SwapTest extends TestCase {
  23. public void testOperatorCountIs2() throws Exception {
  24. assertEquals(2, new Swap(-1).getOperatorCount());
  25. }
  26. public void testApplySwaps() throws Exception {
  27. Swap swap = new Swap(-1);
  28. Variable first = new Variable(null, JavaType.BOOLEAN, false, false);
  29. Variable second = new Variable(null, JavaType.BOOLEAN, false, false);
  30. List<Variable> inputs = new ArrayList<Variable>();
  31. inputs.add(first);
  32. inputs.add(second);
  33. List<Variable> output = swap.apply(inputs);
  34. assertSame(second, output.get(0));
  35. assertSame(first, output.get(1));
  36. }
  37. public void testToString() {
  38. assertEquals("swap", new Swap(-1).toString());
  39. }
  40. }