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.rsub_int_lit8; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_1; 22 import dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_2; 23 import dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_3; 24 import dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_4; 25 import dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_5; 26 import dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_6; 27 import dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_7; 28 import dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_12; 29 30 public class Test_rsub_int_lit8 extends DxTestCase { 31 32 /** 33 * @title normal test - check different values 34 */ testN1()35 public void testN1() { 36 T_rsub_int_lit8_1 t = new T_rsub_int_lit8_1(); 37 assertEquals("Subtest_1 is failed", -4, t.run(8)); 38 assertEquals("Subtest_2 is failed",45, t.run1(15)); 39 assertEquals("Subtest_3 is failed",0, t.run2(20)); 40 assertEquals("Subtest_4 is failed",-35, t.run3(10)); 41 assertEquals("Subtest_5 is failed",-20, t.run4(-50)); 42 assertEquals("Subtest_6 is failed",20, t.run5(-70)); 43 } 44 45 /** 46 * @title normal test - check different values 47 */ testN2()48 public void testN2() { 49 T_rsub_int_lit8_2 t = new T_rsub_int_lit8_2(); 50 assertEquals("Subtest_1 is failed",123, t.run(0)); 51 assertEquals("Subtest_2 is failed",-123, t.run1(0)); 52 assertEquals("Subtest_3 is failed",-15, t.run2(15)); 53 assertEquals("Subtest_4 is failed",85, t.run2(-85)); 54 } 55 56 /** 57 * @title 58 * 1: a = Integer.MAX_VALUE, b = 0, b-a = -Integer.MAX_VALUE 59 * 2: a = Byte.MAX_VALUE, b = 0, b-a = -Byte.MAX_VALUE 60 */ testB1()61 public void testB1() { 62 T_rsub_int_lit8_3 t = new T_rsub_int_lit8_3(); 63 assertEquals(-Integer.MAX_VALUE, t.run(Integer.MAX_VALUE)); 64 assertEquals(-Byte.MAX_VALUE, t.run(Byte.MAX_VALUE)); 65 } 66 67 /** 68 * @title 69 * 1: a = Integer.MIN_VALUE, b = 0, b-a = Integer.MIN_VALUE 70 * 2: a = Byte.MIN_VALUE, b = 0, b-a = 128 71 */ testB2()72 public void testB2() { 73 T_rsub_int_lit8_3 t = new T_rsub_int_lit8_3(); 74 assertEquals(Integer.MIN_VALUE, t.run(Integer.MIN_VALUE)); 75 assertEquals(128, t.run(Byte.MIN_VALUE)); 76 } 77 78 /** 79 * @title (a = 0, b = 0, b-a = 0) 80 */ testB3()81 public void testB3() { 82 T_rsub_int_lit8_3 t = new T_rsub_int_lit8_3(); 83 assertEquals(0, t.run(0)); 84 } 85 86 /** 87 * @title 88 * 1: a = 0, b = Byte.MAX_VALUE, b-a = Byte.MAX_VALUE 89 * 2: a = 1, b = Byte.MAX_VALUE, b-a = 126 90 * 3: a = -1, b = Byte.MAX_VALUE, b-a = 128 91 */ testB4()92 public void testB4() { 93 T_rsub_int_lit8_4 t = new T_rsub_int_lit8_4(); 94 assertEquals(Byte.MAX_VALUE, t.run(0)); 95 assertEquals(126, t.run(1)); 96 assertEquals(128, t.run(-1)); 97 } 98 99 /** 100 * @title 101 * 1: a = Integer.MIN_VALUE, b = Byte.MAX_VALUE, b-a = -2147483521 102 * 2: a = Integer.MAX_VALUE, b = Byte.MAX_VALUE, b-a = -2147483520 103 * 3: a = Byte.MIN_VALUE, b = Byte.MAX_VALUE, b-a = 255 104 */ testB5()105 public void testB5() { 106 T_rsub_int_lit8_4 t = new T_rsub_int_lit8_4(); 107 assertEquals(-2147483521, t.run(Integer.MIN_VALUE)); 108 assertEquals(-2147483520, t.run(Integer.MAX_VALUE)); 109 assertEquals(255, t.run(Byte.MIN_VALUE)); 110 } 111 112 /** 113 * @title 114 * 1: a = 0, b = Byte.MIN_VALUE, b-a = Byte.MIN_VALUE 115 * 2: a = 1, b = Byte.MIN_VALUE, b-a = -129 116 * 3: a = -1, b = Byte.MIN_VALUE, b-a = -127 117 */ testB6()118 public void testB6() { 119 T_rsub_int_lit8_5 t = new T_rsub_int_lit8_5(); 120 assertEquals(Byte.MIN_VALUE, t.run(0)); 121 assertEquals(-129, t.run(1)); 122 assertEquals(-127, t.run(-1)); 123 } 124 125 /** 126 * @title 127 * 1: a = Integer.MAX_VALUE, b = Byte.MIN_VALUE, b-a = 2147483521 128 * 2: a = Integer.MIN_VALUE, b = Byte.MIN_VALUE, b-a = 2147483520 129 * 3: a = Byte.MAX_VALUE, b = Byte.MIN_VALUE, b-a = -255 130 */ testB7()131 public void testB7() { 132 T_rsub_int_lit8_5 t = new T_rsub_int_lit8_5(); 133 assertEquals(2147483521, t.run(Integer.MAX_VALUE)); 134 assertEquals(2147483520, t.run(Integer.MIN_VALUE)); 135 assertEquals(-255, t.run(Byte.MAX_VALUE)); 136 } 137 138 /** 139 * @title 140 * 1: a = Integer.MIN_VALUE, b = -1, b-a = Integer.MAX_VALUE 141 * 2: a = Byte.MIN_VALUE, b = -1, b-a = Byte.MAX_VALUE 142 */ testB8()143 public void testB8() { 144 T_rsub_int_lit8_6 t = new T_rsub_int_lit8_6(); 145 assertEquals(Integer.MAX_VALUE, t.run(Integer.MIN_VALUE)); 146 assertEquals(Byte.MAX_VALUE, t.run(Byte.MIN_VALUE)); 147 } 148 149 /** 150 * @title 151 * 1: a = Integer.MAX_VALUE, b = -1, b-a = Integer.MIN_VALUE 152 * 2: a = Byte.MAX_VALUE, b = -1, b-a = Byte.MIN_VALUE 153 */ testB9()154 public void testB9() { 155 T_rsub_int_lit8_6 t = new T_rsub_int_lit8_6(); 156 assertEquals(Integer.MIN_VALUE, t.run(Integer.MAX_VALUE)); 157 assertEquals(Byte.MIN_VALUE, t.run(Byte.MAX_VALUE)); 158 } 159 160 /** 161 * @title 162 * 1: a = Integer.MIN_VALUE, b = 1, b-a = -Integer.MAX_VALUE 163 * 2: a = Integer.MAX_VALUE, b = 1, b-a = -2147483646 164 */ testB10()165 public void testB10() { 166 T_rsub_int_lit8_7 t = new T_rsub_int_lit8_7(); 167 assertEquals(-Integer.MAX_VALUE, t.run(Integer.MIN_VALUE)); 168 assertEquals(-2147483646, t.run(Integer.MAX_VALUE)); 169 } 170 171 /** 172 * @title 173 * 1: a = Byte.MIN_VALUE, b = 1, b-a = 129 174 * 2: a = Byte.MAX_VALUE, b = 1, b-a = -126 175 */ testB11()176 public void testB11() { 177 T_rsub_int_lit8_7 t = new T_rsub_int_lit8_7(); 178 assertEquals(129, t.run(Byte.MIN_VALUE)); 179 assertEquals(-126, t.run(Byte.MAX_VALUE)); 180 } 181 182 /** 183 * @title (a = 1, b = 1, b-a = 0) 184 */ testB12()185 public void testB12() { 186 T_rsub_int_lit8_7 t = new T_rsub_int_lit8_7(); 187 assertEquals(0, t.run(1)); 188 } 189 190 /** 191 * @constraint A23 192 * @title number of registers 193 */ testVFE1()194 public void testVFE1() { 195 load("dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_8", VerifyError.class); 196 } 197 198 199 200 /** 201 * @constraint B1 202 * @title types of arguments - double, int 203 */ testVFE2()204 public void testVFE2() { 205 load("dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_9", VerifyError.class); 206 } 207 208 /** 209 * @constraint B1 210 * @title types of arguments - long, int 211 */ testVFE3()212 public void testVFE3() { 213 load("dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_10", VerifyError.class); 214 } 215 216 /** 217 * @constraint B1 218 * @title types of arguments - reference, int 219 */ testVFE4()220 public void testVFE4() { 221 load("dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_11", VerifyError.class); 222 } 223 224 /** 225 * @constraint B1 226 * @title Types of arguments - float, int. The verifier checks that ints 227 * and floats are not used interchangeably. 228 */ testVFE5()229 public void testVFE5() { 230 load("dot.junit.opcodes.rsub_int_lit8.d.T_rsub_int_lit8_12", VerifyError.class); 231 } 232 } 233