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.ushr_int_lit8; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_1; 22 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_13; 23 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_2; 24 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_3; 25 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_4; 26 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_5; 27 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_6; 28 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_7; 29 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_8; 30 import dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_9; 31 32 33 public class Test_ushr_int_lit8 extends DxTestCase { 34 /** 35 * @title 15 >> 1 36 */ 37 public void testN1() { 38 T_ushr_int_lit8_1 t = new T_ushr_int_lit8_1(); 39 assertEquals(7, t.run()); 40 } 41 42 /** 43 * @title 33 >> 2 44 */ 45 public void testN2() { 46 T_ushr_int_lit8_2 t = new T_ushr_int_lit8_2(); 47 assertEquals(8, t.run()); 48 } 49 50 /** 51 * @title -15 >> 1 52 */ 53 public void testN3() { 54 T_ushr_int_lit8_3 t = new T_ushr_int_lit8_3(); 55 assertEquals(0x7FFFFFF8, t.run()); 56 } 57 58 /** 59 * @title Arguments = 1 & -1 60 */ 61 public void testN4() { 62 T_ushr_int_lit8_4 t = new T_ushr_int_lit8_4(); 63 assertEquals(0, t.run()); 64 } 65 66 /** 67 * @title Verify that shift distance is actually in range 0 to 32. 68 */ 69 public void testN5() { 70 T_ushr_int_lit8_5 t = new T_ushr_int_lit8_5(); 71 assertEquals(16, t.run()); 72 } 73 74 75 /** 76 * @title Arguments = 0 & -1 77 */ 78 public void testB1() { 79 T_ushr_int_lit8_6 t = new T_ushr_int_lit8_6(); 80 assertEquals(0, t.run()); 81 } 82 83 /** 84 * @title Arguments = Integer.MAX_VALUE & 1 85 */ 86 public void testB2() { 87 T_ushr_int_lit8_7 t = new T_ushr_int_lit8_7(); 88 assertEquals(0x3FFFFFFF, t.run()); 89 } 90 91 /** 92 * @title Arguments = Integer.MIN_VALUE & 1 93 */ 94 public void testB3() { 95 T_ushr_int_lit8_8 t = new T_ushr_int_lit8_8(); 96 assertEquals(0x40000000, t.run()); 97 } 98 99 /** 100 * @title Arguments = 1 & 0 101 */ 102 public void testB4() { 103 T_ushr_int_lit8_9 t = new T_ushr_int_lit8_9(); 104 assertEquals(1, t.run()); 105 } 106 107 108 109 /** 110 * @constraint B1 111 * @title types of arguments - double, int 112 */ 113 public void testVFE1() { 114 try { 115 Class.forName("dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_10"); 116 fail("expected a verification exception"); 117 } catch (Throwable t) { 118 DxUtil.checkVerifyException(t); 119 } 120 } 121 122 /** 123 * @constraint B1 124 * @title types of arguments - long, int 125 */ 126 public void testVFE2() { 127 try { 128 Class.forName("dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_11"); 129 fail("expected a verification exception"); 130 } catch (Throwable t) { 131 DxUtil.checkVerifyException(t); 132 } 133 } 134 135 /** 136 * @constraint B1 137 * @title types of arguments - reference, int 138 */ 139 public void testVFE3() { 140 try { 141 Class.forName("dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_12"); 142 fail("expected a verification exception"); 143 } catch (Throwable t) { 144 DxUtil.checkVerifyException(t); 145 } 146 } 147 148 /** 149 * @constraint A23 150 * @title number of registers 151 */ 152 public void testVFE4() { 153 try { 154 Class.forName("dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_14"); 155 fail("expected a verification exception"); 156 } catch (Throwable t) { 157 DxUtil.checkVerifyException(t); 158 } 159 } 160 161 /** 162 * @constraint B1 163 * @title Type of argument - float. The verifier checks that ints 164 * and floats are not used interchangeably. 165 */ 166 public void testVFE5() { 167 try { 168 Class.forName("dot.junit.opcodes.ushr_int_lit8.d.T_ushr_int_lit8_13"); 169 fail("expected a verification exception"); 170 } catch (Throwable t) { 171 DxUtil.checkVerifyException(t); 172 } 173 } 174 175 } 176