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