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.rem_int_lit8; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_1; 22 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_2; 23 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_3; 24 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_4; 25 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_5; 26 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_6; 27 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_7; 28 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_8; 29 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_9; 30 31 public class Test_rem_int_lit8 extends DxTestCase { 32 33 /** 34 * @title Arguments = 8, 4 35 */ 36 public void testN1() { 37 T_rem_int_lit8_1 t = new T_rem_int_lit8_1(); 38 assertEquals(0, t.run(8)); 39 } 40 41 /** 42 * @title Arguments = 123, 4 43 */ 44 public void testN2() { 45 T_rem_int_lit8_1 t = new T_rem_int_lit8_1(); 46 assertEquals(3, t.run(123)); 47 } 48 49 /** 50 * @title Dividend = 0 51 */ 52 public void testN3() { 53 T_rem_int_lit8_1 t = new T_rem_int_lit8_1(); 54 assertEquals(0, t.run(0)); 55 } 56 57 /** 58 * @title Dividend is negative 59 */ 60 public void testN4() { 61 T_rem_int_lit8_1 t = new T_rem_int_lit8_1(); 62 assertEquals(-2, t.run(-10)); 63 } 64 65 /** 66 * @title Divisor is negative 67 */ 68 public void testN5() { 69 T_rem_int_lit8_2 t = new T_rem_int_lit8_2(); 70 assertEquals(0, t.run(123)); 71 } 72 73 /** 74 * @title Both Dividend and divisor are negative 75 */ 76 public void testN6() { 77 T_rem_int_lit8_3 t = new T_rem_int_lit8_3(); 78 assertEquals(-3, t.run(-123)); 79 } 80 81 /** 82 * @title Types of arguments - float, int. Dalvik doens't distinguish 32-bits types internally, 83 * so this operation of float and int makes no sense but shall not crash the VM. 84 */ 85 public void testN7() { 86 T_rem_int_lit8_4 t = new T_rem_int_lit8_4(); 87 try { 88 t.run(3.14f); 89 } catch (Throwable e) { 90 } 91 } 92 93 /** 94 * @title Arguments = Byte.MIN_VALUE, -1 95 */ 96 public void testB1() { 97 T_rem_int_lit8_5 t = new T_rem_int_lit8_5(); 98 assertEquals(0, t.run(Byte.MIN_VALUE)); 99 } 100 101 /** 102 * @title Arguments = Byte.MIN_VALUE, 1 103 */ 104 public void testB2() { 105 T_rem_int_lit8_6 t = new T_rem_int_lit8_6(); 106 assertEquals(0, t.run(Byte.MIN_VALUE)); 107 } 108 109 /** 110 * @title Arguments = Byte.MAX_VALUE, 1 111 */ 112 public void testB3() { 113 T_rem_int_lit8_6 t = new T_rem_int_lit8_6(); 114 assertEquals(0, t.run(Byte.MAX_VALUE)); 115 } 116 117 /** 118 * @title Arguments = Short.MIN_VALUE, 127 119 */ 120 public void testB4() { 121 T_rem_int_lit8_7 t = new T_rem_int_lit8_7(); 122 assertEquals(-2, t.run(Short.MIN_VALUE)); 123 } 124 125 /** 126 * @title Arguments = 1, 127 127 */ 128 public void testB5() { 129 T_rem_int_lit8_7 t = new T_rem_int_lit8_7(); 130 assertEquals(1, t.run(1)); 131 } 132 133 /** 134 * @title Arguments = 1, -128 135 */ 136 public void testB6() { 137 T_rem_int_lit8_8 t = new T_rem_int_lit8_8(); 138 assertEquals(1, t.run(1)); 139 } 140 141 /** 142 * @title Divisor is 0 143 */ 144 public void testE1() { 145 T_rem_int_lit8_9 t = new T_rem_int_lit8_9(); 146 try { 147 t.run(1); 148 fail("expected ArithmeticException"); 149 } catch (ArithmeticException ae) { 150 // expected 151 } 152 } 153 154 /** 155 * @constraint A23 156 * @title number of registers 157 */ 158 public void testVFE1() { 159 try { 160 Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_10"); 161 fail("expected a verification exception"); 162 } catch (Throwable t) { 163 DxUtil.checkVerifyException(t); 164 } 165 } 166 167 168 169 /** 170 * @constraint B1 171 * @title types of arguments - int, double 172 */ 173 public void testVFE2() { 174 try { 175 Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_11"); 176 fail("expected a verification exception"); 177 } catch (Throwable t) { 178 DxUtil.checkVerifyException(t); 179 } 180 } 181 182 /** 183 * @constraint B1 184 * @title types of arguments - long, int 185 */ 186 public void testVFE3() { 187 try { 188 Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_12"); 189 fail("expected a verification exception"); 190 } catch (Throwable t) { 191 DxUtil.checkVerifyException(t); 192 } 193 } 194 195 /** 196 * @constraint B1 197 * @title types of arguments - reference, int 198 */ 199 public void testVFE4() { 200 try { 201 Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_13"); 202 fail("expected a verification exception"); 203 } catch (Throwable t) { 204 DxUtil.checkVerifyException(t); 205 } 206 } 207 208 } 209