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