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 dot.junit.opcodes.add_int_lit16; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_16; 22 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_5; 23 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_1; 24 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_10; 25 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_11; 26 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_12; 27 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_2; 28 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_3; 29 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_4; 30 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_6; 31 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_7; 32 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_8; 33 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_9; 34 35 public class Test_add_int_lit16 extends DxTestCase { 36 /** 37 * @title Arguments = 8 + 4 38 */ 39 public void testN1() { 40 T_add_int_lit16_1 t = new T_add_int_lit16_1(); 41 assertEquals(12, t.run()); 42 } 43 44 /** 45 * @title Arguments = 0 + 255 46 */ 47 public void testN2() { 48 T_add_int_lit16_2 t = new T_add_int_lit16_2(); 49 assertEquals(255, t.run()); 50 } 51 52 /** 53 * @title Arguments = 0 + (-32768) 54 */ 55 public void testN3() { 56 T_add_int_lit16_3 t = new T_add_int_lit16_3(); 57 assertEquals(-32768, t.run()); 58 } 59 60 /** 61 * @title Arguments = (-2147483647) + 0 62 */ 63 public void testN4() { 64 T_add_int_lit16_4 t = new T_add_int_lit16_4(); 65 assertEquals(-2147483647, t.run()); 66 } 67 68 /** 69 * @title Arguments = 0x7ffffffe + 2 70 */ 71 public void testN5() { 72 T_add_int_lit16_5 t = new T_add_int_lit16_5(); 73 assertEquals(-2147483648, t.run()); 74 } 75 76 /** 77 * @title Arguments = -1 + 1 78 */ 79 public void testN6() { 80 T_add_int_lit16_6 t = new T_add_int_lit16_6(); 81 assertEquals(0, t.run()); 82 } 83 84 /** 85 * @title Arguments = 0 + Short.MAX_VALUE 86 */ 87 public void testB1() { 88 T_add_int_lit16_7 t = new T_add_int_lit16_7(); 89 assertEquals(Short.MAX_VALUE, t.run()); 90 } 91 92 /** 93 * @title Arguments = Integer.MAX_VALUE + Short.MAX_VALUE 94 */ 95 public void testB2() { 96 T_add_int_lit16_8 t = new T_add_int_lit16_8(); 97 assertEquals(-2147450882, t.run()); 98 } 99 100 /** 101 * @title Arguments = Integer.MAX_VALUE + 1 102 */ 103 public void testB3() { 104 T_add_int_lit16_9 t = new T_add_int_lit16_9(); 105 assertEquals(Integer.MIN_VALUE, t.run()); 106 } 107 108 /** 109 * @title Arguments = Integer.MIN_VALUE + 1 110 */ 111 public void testB4() { 112 T_add_int_lit16_10 t = new T_add_int_lit16_10(); 113 assertEquals(-2147483647, t.run()); 114 } 115 116 /** 117 * @title Arguments = 0 + 0 118 */ 119 public void testB5() { 120 T_add_int_lit16_11 t = new T_add_int_lit16_11(); 121 assertEquals(0, t.run()); 122 } 123 124 /** 125 * @title Arguments = Short.MIN_VALUE + Short.MIN_VALUE 126 */ 127 public void testB6() { 128 T_add_int_lit16_12 t = new T_add_int_lit16_12(); 129 assertEquals(-65536, t.run()); 130 } 131 132 133 134 135 /** 136 * @constraint B1 137 * @title types of arguments - int, double 138 */ 139 public void testVFE1() { 140 try { 141 Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_13"); 142 fail("expected a verification exception"); 143 } catch (Throwable t) { 144 DxUtil.checkVerifyException(t); 145 } 146 } 147 148 /** 149 * @constraint B1 150 * @title types of arguments - long, int 151 */ 152 public void testVFE2() { 153 try { 154 Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_14"); 155 fail("expected a verification exception"); 156 } catch (Throwable t) { 157 DxUtil.checkVerifyException(t); 158 } 159 } 160 161 /** 162 * @constraint B1 163 * @title types of arguments - reference, int 164 */ 165 public void testVFE3() { 166 try { 167 Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_15"); 168 fail("expected a verification exception"); 169 } catch (Throwable t) { 170 DxUtil.checkVerifyException(t); 171 } 172 } 173 174 /** 175 * @constraint A23 176 * @title number of registers 177 */ 178 public void testVFE4() { 179 try { 180 Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_17"); 181 fail("expected a verification exception"); 182 } catch (Throwable t) { 183 DxUtil.checkVerifyException(t); 184 } 185 } 186 187 /** 188 * @constraint B1 189 * @title Types of arguments - int, float. The verifier checks that ints 190 * and floats are not used interchangeably. 191 */ 192 public void testVFE5() { 193 try { 194 Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_16"); 195 fail("expected a verification exception"); 196 } catch (Throwable t) { 197 DxUtil.checkVerifyException(t); 198 } 199 } 200 } 201