1 package dot.junit.opcodes.shr_long; 2 3 import dot.junit.DxTestCase; 4 import dot.junit.DxUtil; 5 import dot.junit.opcodes.shr_long.d.T_shr_long_1; 6 import dot.junit.opcodes.shr_long.d.T_shr_long_7; 7 8 public class Test_shr_long extends DxTestCase { 9 10 /** 11 * @title Arguments = 40000000000l, 3 12 */ 13 public void testN1() { 14 T_shr_long_1 t = new T_shr_long_1(); 15 assertEquals(5000000000l, t.run(40000000000l, 3)); 16 } 17 18 /** 19 * @title Arguments = 40000000000l, 1 20 */ 21 public void testN2() { 22 T_shr_long_1 t = new T_shr_long_1(); 23 assertEquals(20000000000l, t.run(40000000000l, 1)); 24 } 25 26 /** 27 * @title Arguments = -40000000000l, 1 28 */ 29 public void testN3() { 30 T_shr_long_1 t = new T_shr_long_1(); 31 assertEquals(-20000000000l, t.run(-40000000000l, 1)); 32 } 33 34 /** 35 * @title Arguments = 1 & -1 36 */ 37 public void testN4() { 38 T_shr_long_1 t = new T_shr_long_1(); 39 assertEquals(0l, t.run(1l, -1)); 40 } 41 42 /** 43 * @title Verify that shift distance is actually in range 0 to 64. 44 */ 45 public void testN5() { 46 T_shr_long_1 t = new T_shr_long_1(); 47 assertEquals(32, t.run(65l, 65)); 48 } 49 50 /** 51 * @title Types of arguments - double, int. Dalvik doens't distinguish 64-bits types internally, 52 * so this operation of double and int makes no sense but shall not crash the VM. 53 */ 54 public void testN6() { 55 T_shr_long_7 t = new T_shr_long_7(); 56 try { 57 t.run(4.67d, 1); 58 } catch (Throwable e) { 59 } 60 } 61 62 63 /** 64 * @title Arguments = 0 & -1 65 */ 66 public void testB1() { 67 T_shr_long_1 t = new T_shr_long_1(); 68 assertEquals(0l, t.run(0l, -1)); 69 } 70 71 /** 72 * @title Arguments = 1 & 0 73 */ 74 public void testB2() { 75 T_shr_long_1 t = new T_shr_long_1(); 76 assertEquals(1l, t.run(1l, 0)); 77 } 78 79 /** 80 * @title Arguments = Long.MAX_VALUE & 1 81 */ 82 public void testB3() { 83 T_shr_long_1 t = new T_shr_long_1(); 84 assertEquals(0x3FFFFFFFFFFFFFFFl, t.run(Long.MAX_VALUE, 1)); 85 } 86 87 /** 88 * @title Arguments = Long.MIN_VALUE & 1 89 */ 90 public void testB4() { 91 T_shr_long_1 t = new T_shr_long_1(); 92 assertEquals(0xc000000000000000l, t.run(Long.MIN_VALUE, 1)); 93 } 94 95 96 /** 97 * @constraint A24 98 * @title number of registers 99 */ 100 public void testVFE1() { 101 try { 102 Class.forName("dot.junit.opcodes.shr_long.d.T_shr_long_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 - long, double 114 */ 115 public void testVFE2() { 116 try { 117 Class.forName("dot.junit.opcodes.shr_long.d.T_shr_long_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 - int, int 127 */ 128 public void testVFE3() { 129 try { 130 Class.forName("dot.junit.opcodes.shr_long.d.T_shr_long_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 - float, int 140 */ 141 public void testVFE4() { 142 try { 143 Class.forName("dot.junit.opcodes.shr_long.d.T_shr_long_5"); 144 fail("expected a verification exception"); 145 } catch (Throwable t) { 146 DxUtil.checkVerifyException(t); 147 } 148 } 149 150 /** 151 * @constraint B1 152 * @title types of arguments - reference, int 153 */ 154 public void testVFE5() { 155 try { 156 Class.forName("dot.junit.opcodes.shr_long.d.T_shr_long_6"); 157 fail("expected a verification exception"); 158 } catch (Throwable t) { 159 DxUtil.checkVerifyException(t); 160 } 161 } 162 } 163