1 package dot.junit.opcodes.if_ne; 2 3 import dot.junit.DxTestCase; 4 import dot.junit.DxUtil; 5 import dot.junit.opcodes.if_ne.d.T_if_ne_1; 6 import dot.junit.opcodes.if_ne.d.T_if_ne_2; 7 import dot.junit.opcodes.if_ne.d.T_if_ne_4; 8 9 public class Test_if_ne extends DxTestCase { 10 11 /** 12 * @title Arguments = 5, 6 13 */ 14 public void testN1() { 15 T_if_ne_1 t = new T_if_ne_1(); 16 assertEquals(1, t.run(5, 6)); 17 } 18 19 /** 20 * @title Arguments = 0x0f0e0d0c, 0x0f0e0d0c 21 */ 22 public void testN2() { 23 T_if_ne_1 t = new T_if_ne_1(); 24 assertEquals(1234, t.run(0x0f0e0d0c, 0x0f0e0d0c)); 25 } 26 27 /** 28 * @title Arguments = 5, -5 29 */ 30 public void testN3() { 31 T_if_ne_1 t = new T_if_ne_1(); 32 assertEquals(1, t.run(5, -5)); 33 } 34 35 /** 36 * @title Arguments = 0x01001234, 0x1234 37 */ 38 public void testN4() { 39 T_if_ne_1 t = new T_if_ne_1(); 40 assertEquals(1, t.run(0x01001234, 0x1234)); 41 } 42 43 /** 44 * @title compare references 45 */ 46 public void testN5() { 47 T_if_ne_2 t = new T_if_ne_2(); 48 String a = "a"; 49 String b = "b"; 50 assertEquals(1, t.run(a, b)); 51 } 52 53 /** 54 * @title compare references 55 */ 56 public void testN6() { 57 T_if_ne_2 t = new T_if_ne_2(); 58 String a = "a"; 59 assertEquals(1234, t.run(a, a)); 60 } 61 62 /** 63 * @title Types of arguments - int, float. Dalvik doens't distinguish 32-bits types internally, 64 * so this operation of int and float makes no sense but shall not crash the VM. 65 */ 66 public void testN7() { 67 T_if_ne_4 t = new T_if_ne_4(); 68 assertEquals(1, t.run(1f, 1)); 69 } 70 71 /** 72 * @title Arguments = Integer.MAX_VALUE, Integer.MAX_VALUE 73 */ 74 public void testB1() { 75 T_if_ne_1 t = new T_if_ne_1(); 76 assertEquals(1234, t.run(Integer.MAX_VALUE, Integer.MAX_VALUE)); 77 } 78 79 /** 80 * @title Arguments = Integer.MIN_VALUE, Integer.MIN_VALUE 81 */ 82 public void testB2() { 83 T_if_ne_1 t = new T_if_ne_1(); 84 assertEquals(1234, t.run(Integer.MIN_VALUE, Integer.MIN_VALUE)); 85 } 86 87 /** 88 * @title Arguments = 0, 1234567 89 */ 90 public void testB3() { 91 T_if_ne_1 t = new T_if_ne_1(); 92 assertEquals(1, t.run(0, 1234567)); 93 } 94 95 /** 96 * @title Arguments = 0, 0 97 */ 98 public void testB4() { 99 T_if_ne_1 t = new T_if_ne_1(); 100 assertEquals(1234, t.run(0, 0)); 101 } 102 103 /** 104 * @title Compare with null 105 */ 106 public void testB5() { 107 T_if_ne_2 t = new T_if_ne_2(); 108 String a = "a"; 109 assertEquals(1, t.run(null, a)); 110 } 111 112 /** 113 * @constraint A23 114 * @title number of registers 115 */ 116 public void testVFE1() { 117 try { 118 Class.forName("dot.junit.opcodes.if_ne.d.T_if_ne_5"); 119 fail("expected a verification exception"); 120 } catch (Throwable t) { 121 DxUtil.checkVerifyException(t); 122 } 123 } 124 125 126 127 /** 128 * @constraint B1 129 * @title types of arguments - int, double 130 */ 131 public void testVFE2() { 132 try { 133 Class.forName("dot.junit.opcodes.if_ne.d.T_if_ne_7"); 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 - long, int 143 */ 144 public void testVFE3() { 145 try { 146 Class.forName("dot.junit.opcodes.if_ne.d.T_if_ne_8"); 147 fail("expected a verification exception"); 148 } catch (Throwable t) { 149 DxUtil.checkVerifyException(t); 150 } 151 } 152 153 /** 154 * @constraint B1 155 * @title types of arguments - int, reference 156 */ 157 public void testVFE4() { 158 try { 159 Class.forName("dot.junit.opcodes.if_ne.d.T_if_ne_9"); 160 fail("expected a verification exception"); 161 } catch (Throwable t) { 162 DxUtil.checkVerifyException(t); 163 } 164 } 165 166 /** 167 * @constraint A6 168 * @title branch target shall be inside the method 169 */ 170 public void testVFE5() { 171 try { 172 Class.forName("dot.junit.opcodes.if_ne.d.T_if_ne_10"); 173 fail("expected a verification exception"); 174 } catch (Throwable t) { 175 DxUtil.checkVerifyException(t); 176 } 177 } 178 179 /** 180 * @constraint A6 181 * @title branch target shall not be "inside" instruction 182 */ 183 public void testVFE6() { 184 try { 185 Class.forName("dot.junit.opcodes.if_ne.d.T_if_ne_11"); 186 fail("expected a verification exception"); 187 } catch (Throwable t) { 188 DxUtil.checkVerifyException(t); 189 } 190 } 191 192 /** 193 * @constraint n/a 194 * @title branch target shall not be 0 195 */ 196 public void testVFE7() { 197 try { 198 Class.forName("dot.junit.opcodes.if_ne.d.T_if_ne_12"); 199 fail("expected a verification exception"); 200 } catch (Throwable t) { 201 DxUtil.checkVerifyException(t); 202 } 203 } 204 205 } 206