1 /* 2 * Copyright (C) 2008 The Android Open Source Project 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 dxc.junit.opcodes.if_acmpeq; 18 19 import dxc.junit.DxTestCase; 20 import dxc.junit.DxUtil; 21 import dxc.junit.opcodes.if_acmpeq.jm.T_if_acmpeq_1; 22 23 public class Test_if_acmpeq extends DxTestCase { 24 25 /** 26 * @title normal test 27 */ 28 public void testN1() { 29 T_if_acmpeq_1 t = new T_if_acmpeq_1(); 30 String a = "a"; 31 String b = "b"; 32 33 /* 34 * Compare with 1234 to check that in case of failed comparison 35 * execution proceeds at the address following if_acmpeq instruction 36 */ 37 assertEquals(1234, t.run(a, b)); 38 } 39 40 /** 41 * @title normal test 42 */ 43 public void testN2() { 44 T_if_acmpeq_1 t = new T_if_acmpeq_1(); 45 String a = "a"; 46 assertEquals(1, t.run(a, a)); 47 } 48 49 /** 50 * @title Compare with null 51 */ 52 public void testB1() { 53 T_if_acmpeq_1 t = new T_if_acmpeq_1(); 54 String a = "a"; 55 assertEquals(1234, t.run(null, a)); 56 } 57 58 /** 59 * @constraint 4.8.2.1 60 * @title number of arguments 61 */ 62 public void testVFE1() { 63 try { 64 Class.forName("dxc.junit.opcodes.if_acmpeq.jm.T_if_acmpeq_2"); 65 fail("expected a verification exception"); 66 } catch (Throwable t) { 67 DxUtil.checkVerifyException(t); 68 } 69 } 70 71 /** 72 * @constraint 4.8.2.1 73 * @title types of arguments - reference, double 74 */ 75 public void testVFE2() { 76 try { 77 Class.forName("dxc.junit.opcodes.if_acmpeq.jm.T_if_acmpeq_3"); 78 fail("expected a verification exception"); 79 } catch (Throwable t) { 80 DxUtil.checkVerifyException(t); 81 } 82 } 83 84 /** 85 * @constraint 4.8.2.1 86 * @title types of arguments - reference, 87 * integer 88 */ 89 public void testVFE3() { 90 try { 91 Class.forName("dxc.junit.opcodes.if_acmpeq.jm.T_if_acmpeq_4"); 92 fail("expected a verification exception"); 93 } catch (Throwable t) { 94 DxUtil.checkVerifyException(t); 95 } 96 } 97 98 /** 99 * @constraint 4.8.1.7 100 * @title branch target shall be inside the 101 * method 102 */ 103 public void testVFE4() { 104 try { 105 Class.forName("dxc.junit.opcodes.if_acmpeq.jm.T_if_acmpeq_5"); 106 fail("expected a verification exception"); 107 } catch (Throwable t) { 108 DxUtil.checkVerifyException(t); 109 } 110 } 111 112 /** 113 * @constraint 4.8.1.7 114 * @title branch target shall not be "inside" wide 115 * instruction 116 */ 117 public void testVFE5() { 118 try { 119 Class.forName("dxc.junit.opcodes.if_acmpeq.jm.T_if_acmpeq_6"); 120 fail("expected a verification exception"); 121 } catch (Throwable t) { 122 DxUtil.checkVerifyException(t); 123 } 124 } 125 } 126