1 package dot.junit.opcodes.shr_int_lit8; 2 3 import dot.junit.DxTestCase; 4 import dot.junit.DxUtil; 5 import dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_1; 6 import dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_2; 7 import dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_3; 8 import dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_4; 9 import dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_5; 10 import dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_6; 11 12 public class Test_shr_int_lit8 extends DxTestCase { 13 14 /** 15 * @title 15 >> 1 16 */ testN1()17 public void testN1() { 18 T_shr_int_lit8_1 t = new T_shr_int_lit8_1(); 19 assertEquals(7, t.run(15)); 20 } 21 22 /** 23 * @title 33 >> 2 24 */ testN2()25 public void testN2() { 26 T_shr_int_lit8_2 t = new T_shr_int_lit8_2(); 27 assertEquals(8, t.run(33)); 28 } 29 30 /** 31 * @title -15 >> 1 32 */ testN3()33 public void testN3() { 34 T_shr_int_lit8_1 t = new T_shr_int_lit8_1(); 35 assertEquals(-8, t.run(-15)); 36 } 37 38 /** 39 * @title Arguments = 1 & -1 40 */ testN4()41 public void testN4() { 42 T_shr_int_lit8_3 t = new T_shr_int_lit8_3(); 43 assertEquals(0, t.run(1)); 44 } 45 46 /** 47 * @title Verify that shift distance is actually in range 0 to 32. 48 */ testN5()49 public void testN5() { 50 T_shr_int_lit8_4 t = new T_shr_int_lit8_4(); 51 assertEquals(16, t.run(33)); 52 } 53 54 /** 55 * @title Types of arguments - float. Dalvik doens't distinguish 32-bits types internally, 56 * so this operation of float makes no sense but shall not crash the VM. 57 */ testN6()58 public void testN6() { 59 T_shr_int_lit8_6 t = new T_shr_int_lit8_6(); 60 try { 61 t.run(3.14f); 62 } catch (Throwable e) { 63 } 64 } 65 66 67 /** 68 * @title Arguments = 0 & -1 69 */ testB1()70 public void testB1() { 71 T_shr_int_lit8_3 t = new T_shr_int_lit8_3(); 72 assertEquals(0, t.run(0)); 73 } 74 75 /** 76 * @title Arguments = Integer.MAX_VALUE & 1 77 */ testB2()78 public void testB2() { 79 T_shr_int_lit8_1 t = new T_shr_int_lit8_1(); 80 assertEquals(0x3FFFFFFF, t.run(Integer.MAX_VALUE)); 81 } 82 83 /** 84 * @title Arguments = Integer.MIN_VALUE & 1 85 */ testB3()86 public void testB3() { 87 T_shr_int_lit8_1 t = new T_shr_int_lit8_1(); 88 assertEquals(0xc0000000, t.run(Integer.MIN_VALUE)); 89 } 90 91 /** 92 * @title Arguments = 1 & 0 93 */ testB4()94 public void testB4() { 95 T_shr_int_lit8_5 t = new T_shr_int_lit8_5(); 96 assertEquals(1, t.run(1)); 97 } 98 99 /** 100 * @constraint A23 101 * @title number of registers 102 */ testVFE1()103 public void testVFE1() { 104 try { 105 Class.forName("dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_7"); 106 fail("expected a verification exception"); 107 } catch (Throwable t) { 108 DxUtil.checkVerifyException(t); 109 } 110 } 111 112 113 114 /** 115 * @constraint B1 116 * @title types of arguments - double, int 117 */ testVFE2()118 public void testVFE2() { 119 try { 120 Class.forName("dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_8"); 121 fail("expected a verification exception"); 122 } catch (Throwable t) { 123 DxUtil.checkVerifyException(t); 124 } 125 } 126 127 /** 128 * @constraint B1 129 * @title types of arguments - long, int 130 */ testVFE3()131 public void testVFE3() { 132 try { 133 Class.forName("dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_9"); 134 fail("expected a verification exception"); 135 } catch (Throwable t) { 136 DxUtil.checkVerifyException(t); 137 } 138 } 139 140 /** 141 * @constraint B1 142 * @title types of arguments - reference, int 143 */ testVFE4()144 public void testVFE4() { 145 try { 146 Class.forName("dot.junit.opcodes.shr_int_lit8.d.T_shr_int_lit8_10"); 147 fail("expected a verification exception"); 148 } catch (Throwable t) { 149 DxUtil.checkVerifyException(t); 150 } 151 } 152 } 153