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