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_icmpeq; 18 19 import dxc.junit.DxTestCase; 20 import dxc.junit.DxUtil; 21 import dxc.junit.opcodes.if_icmpeq.jm.T_if_icmpeq_1; 22 23 public class Test_if_icmpeq extends DxTestCase { 24 25 /** 26 * @title Arguments = 5, 6 27 */ 28 public void testN1() { 29 T_if_icmpeq_1 t = new T_if_icmpeq_1(); 30 /* 31 * Compare with 1234 to check that in case of failed comparison 32 * execution proceeds at the address following if_acmpeq instruction 33 */ 34 assertEquals(1234, t.run(5, 6)); 35 } 36 37 /** 38 * @title Arguments = 0x0f0e0d0c, 0x0f0e0d0c 39 */ 40 public void testN2() { 41 T_if_icmpeq_1 t = new T_if_icmpeq_1(); 42 assertEquals(1, t.run(0x0f0e0d0c, 0x0f0e0d0c)); 43 } 44 45 /** 46 * @title Arguments = 5, -5 47 */ 48 public void testN3() { 49 T_if_icmpeq_1 t = new T_if_icmpeq_1(); 50 assertEquals(1234, t.run(5, -5)); 51 } 52 53 /** 54 * @title Arguments = 0x01001234, 0x1234 55 */ 56 public void testN4() { 57 T_if_icmpeq_1 t = new T_if_icmpeq_1(); 58 assertEquals(1234, t.run(0x01001234, 0x1234)); 59 } 60 61 /** 62 * @title Arguments = Integer.MAX_VALUE, Integer.MAX_VALUE 63 */ 64 public void testB1() { 65 T_if_icmpeq_1 t = new T_if_icmpeq_1(); 66 assertEquals(1, t.run(Integer.MAX_VALUE, Integer.MAX_VALUE)); 67 } 68 69 /** 70 * @title Arguments = Integer.MIN_VALUE, Integer.MIN_VALUE 71 */ 72 public void testB2() { 73 T_if_icmpeq_1 t = new T_if_icmpeq_1(); 74 assertEquals(1, t.run(Integer.MIN_VALUE, Integer.MIN_VALUE)); 75 } 76 77 /** 78 * @title Arguments = 0, 1234567 79 */ 80 public void testB3() { 81 T_if_icmpeq_1 t = new T_if_icmpeq_1(); 82 assertEquals(1234, t.run(0, 1234567)); 83 } 84 85 /** 86 * @title Arguments = 0, 0 87 */ 88 public void testB4() { 89 T_if_icmpeq_1 t = new T_if_icmpeq_1(); 90 assertEquals(1, t.run(0, 0)); 91 } 92 93 /** 94 * @constraint 4.8.2.1 95 * @title number of arguments 96 */ 97 public void testVFE1() { 98 try { 99 Class.forName("dxc.junit.opcodes.if_icmpeq.jm.T_if_icmpeq_2"); 100 fail("expected a verification exception"); 101 } catch (Throwable t) { 102 DxUtil.checkVerifyException(t); 103 } 104 } 105 106 /** 107 * @constraint 4.8.2.1 108 * @title types of arguments - int, double 109 */ 110 public void testVFE2() { 111 try { 112 Class.forName("dxc.junit.opcodes.if_icmpeq.jm.T_if_icmpeq_3"); 113 fail("expected a verification exception"); 114 } catch (Throwable t) { 115 DxUtil.checkVerifyException(t); 116 } 117 } 118 119 /** 120 * @constraint 4.8.2.1 121 * @title types of arguments - long, int 122 */ 123 public void testVFE3() { 124 try { 125 Class.forName("dxc.junit.opcodes.if_icmpeq.jm.T_if_icmpeq_4"); 126 fail("expected a verification exception"); 127 } catch (Throwable t) { 128 DxUtil.checkVerifyException(t); 129 } 130 } 131 132 /** 133 * @constraint 4.8.1.7 134 * @title branch target shall be inside the 135 * method 136 */ 137 public void testVFE4() { 138 try { 139 Class.forName("dxc.junit.opcodes.if_icmpeq.jm.T_if_icmpeq_5"); 140 fail("expected a verification exception"); 141 } catch (Throwable t) { 142 DxUtil.checkVerifyException(t); 143 } 144 } 145 146 /** 147 * @constraint 4.8.1.7 148 * @title branch target shall not be "inside" wide 149 * instruction 150 */ 151 public void testVFE5() { 152 try { 153 Class.forName("dxc.junit.opcodes.if_icmpeq.jm.T_if_icmpeq_6"); 154 fail("expected a verification exception"); 155 } catch (Throwable t) { 156 DxUtil.checkVerifyException(t); 157 } 158 } 159 160 /** 161 * @constraint 4.8.2.1 162 * @title types of arguments - int, reference 163 */ 164 public void testVFE6() { 165 try { 166 Class.forName("dxc.junit.opcodes.if_icmpeq.jm.T_if_icmpeq_7"); 167 fail("expected a verification exception"); 168 } catch (Throwable t) { 169 DxUtil.checkVerifyException(t); 170 } 171 } 172 173 } 174