1 package dot.junit.opcodes.if_le; 2 3 import dot.junit.DxTestCase; 4 import dot.junit.DxUtil; 5 import dot.junit.opcodes.if_le.d.T_if_le_1; 6 import dot.junit.opcodes.if_le.d.T_if_le_11; 7 8 public class Test_if_le extends DxTestCase { 9 10 /** 11 * @title Case: 5 < 6 12 */ 13 public void testN1() { 14 T_if_le_1 t = new T_if_le_1(); 15 assertEquals(1, t.run(5, 6)); 16 } 17 18 /** 19 * @title Case: 0x0f0e0d0c = 0x0f0e0d0c 20 */ 21 public void testN2() { 22 T_if_le_1 t = new T_if_le_1(); 23 assertEquals(1, t.run(0x0f0e0d0c, 0x0f0e0d0c)); 24 } 25 26 /** 27 * @title Case: 5 > -5 28 */ 29 public void testN3() { 30 T_if_le_1 t = new T_if_le_1(); 31 assertEquals(1234, t.run(5, -5)); 32 } 33 34 /** 35 * @title Types of arguments - int, float. Dalvik doens't distinguish 32-bits types internally, 36 * so this operation of int and float makes no sense but shall not crash the VM. 37 */ 38 public void testN4() { 39 T_if_le_11 t = new T_if_le_11(); 40 assertEquals(1, t.run(1, 1f)); 41 } 42 43 /** 44 * @title Arguments = Integer.MAX_VALUE, Integer.MAX_VALUE 45 */ 46 public void testB1() { 47 T_if_le_1 t = new T_if_le_1(); 48 assertEquals(1, t.run(Integer.MAX_VALUE, Integer.MAX_VALUE)); 49 } 50 51 /** 52 * @title Arguments = Integer.MIN_VALUE, Integer.MAX_VALUE 53 */ 54 public void testB2() { 55 T_if_le_1 t = new T_if_le_1(); 56 assertEquals(1, t.run(Integer.MIN_VALUE, Integer.MAX_VALUE)); 57 } 58 59 /** 60 * @title Arguments = Integer.MAX_VALUE, Integer.MIN_VALUE 61 */ 62 public void testB3() { 63 T_if_le_1 t = new T_if_le_1(); 64 assertEquals(1234, t.run(Integer.MAX_VALUE, Integer.MIN_VALUE)); 65 } 66 67 /** 68 * @title Arguments = 0, Integer.MIN_VALUE 69 */ 70 public void testB4() { 71 T_if_le_1 t = new T_if_le_1(); 72 assertEquals(1234, t.run(0, Integer.MIN_VALUE)); 73 } 74 75 /** 76 * @title Arguments = 0, 0 77 */ 78 public void testB5() { 79 T_if_le_1 t = new T_if_le_1(); 80 assertEquals(1, t.run(0, 0)); 81 } 82 83 /** 84 * @constraint A23 85 * @title number of registers 86 */ 87 public void testVFE1() { 88 try { 89 Class.forName("dot.junit.opcodes.if_le.d.T_if_le_4"); 90 fail("expected a verification exception"); 91 } catch (Throwable t) { 92 DxUtil.checkVerifyException(t); 93 } 94 } 95 96 97 98 /** 99 * @constraint B1 100 * @title types of arguments - int, double 101 */ 102 public void testVFE2() { 103 try { 104 Class.forName("dot.junit.opcodes.if_le.d.T_if_le_5"); 105 fail("expected a verification exception"); 106 } catch (Throwable t) { 107 DxUtil.checkVerifyException(t); 108 } 109 } 110 111 /** 112 * @constraint B1 113 * @title types of arguments - long, int 114 */ 115 public void testVFE3() { 116 try { 117 Class.forName("dot.junit.opcodes.if_le.d.T_if_le_6"); 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, reference 127 */ 128 public void testVFE4() { 129 try { 130 Class.forName("dot.junit.opcodes.if_le.d.T_if_le_7"); 131 fail("expected a verification exception"); 132 } catch (Throwable t) { 133 DxUtil.checkVerifyException(t); 134 } 135 } 136 137 /** 138 * @constraint A6 139 * @title branch target shall be inside the method 140 */ 141 public void testVFE5() { 142 try { 143 Class.forName("dot.junit.opcodes.if_le.d.T_if_le_9"); 144 fail("expected a verification exception"); 145 } catch (Throwable t) { 146 DxUtil.checkVerifyException(t); 147 } 148 } 149 150 /** 151 * @constraint A6 152 * @title branch target shall not be "inside" instruction 153 */ 154 public void testVFE6() { 155 try { 156 Class.forName("dot.junit.opcodes.if_le.d.T_if_le_10"); 157 fail("expected a verification exception"); 158 } catch (Throwable t) { 159 DxUtil.checkVerifyException(t); 160 } 161 } 162 163 /** 164 * @constraint n/a 165 * @title branch target shall not be 0 166 */ 167 public void testVFE7() { 168 try { 169 Class.forName("dot.junit.opcodes.if_le.d.T_if_le_12"); 170 fail("expected a verification exception"); 171 } catch (Throwable t) { 172 DxUtil.checkVerifyException(t); 173 } 174 } 175 } 176 177