1 package dot.junit.opcodes.if_nez; 2 3 import dot.junit.DxTestCase; 4 import dot.junit.DxUtil; 5 import dot.junit.opcodes.if_nez.d.T_if_nez_1; 6 import dot.junit.opcodes.if_nez.d.T_if_nez_2; 7 import dot.junit.opcodes.if_nez.d.T_if_nez_3; 8 import dot.junit.opcodes.if_nez.d.T_if_nez_4; 9 10 public class Test_if_nez extends DxTestCase { 11 12 /** 13 * @title Argument = 5 and -5 14 */ 15 public void testN1() { 16 T_if_nez_1 t = new T_if_nez_1(); 17 assertEquals(1, t.run(5)); 18 assertEquals(1, t.run(-5)); 19 } 20 21 /** 22 * @title Arguments = null 23 */ 24 public void testN2() { 25 T_if_nez_2 t = new T_if_nez_2(); 26 String str = null; 27 assertEquals(1234, t.run(str)); 28 } 29 30 /** 31 * @title Arguments = not null 32 */ 33 public void testN3() { 34 T_if_nez_2 t = new T_if_nez_2(); 35 String str = "abc"; 36 assertEquals(1, t.run(str)); 37 } 38 39 /** 40 * @title Arguments = Integer.MAX_VALUE 41 */ 42 public void testB1() { 43 T_if_nez_1 t = new T_if_nez_1(); 44 assertEquals(1, t.run(Integer.MAX_VALUE)); 45 } 46 47 /** 48 * @title Arguments = Integer.MIN_VALUE 49 */ 50 public void testB2() { 51 T_if_nez_1 t = new T_if_nez_1(); 52 assertEquals(1, t.run(Integer.MIN_VALUE)); 53 } 54 55 /** 56 * @title Arguments = 0 57 */ 58 public void testB3() { 59 T_if_nez_1 t = new T_if_nez_1(); 60 assertEquals(1234, t.run(0)); 61 } 62 63 /** 64 * @title Compare reference with null 65 */ 66 public void testB4() { 67 T_if_nez_4 t = new T_if_nez_4(); 68 assertEquals(1234, t.run(null)); 69 } 70 71 /** 72 * @constraint A23 73 * @title number of registers 74 */ 75 public void testVFE1() { 76 try { 77 Class.forName("dot.junit.opcodes.if_nez.d.T_if_nez_5"); 78 fail("expected a verification exception"); 79 } catch (Throwable t) { 80 DxUtil.checkVerifyException(t); 81 } 82 } 83 84 85 /** 86 * @constraint B1 87 * @title types of arguments - double 88 */ 89 public void testVFE2() { 90 try { 91 Class.forName("dot.junit.opcodes.if_nez.d.T_if_nez_6"); 92 fail("expected a verification exception"); 93 } catch (Throwable t) { 94 DxUtil.checkVerifyException(t); 95 } 96 } 97 98 /** 99 * @constraint B1 100 * @title types of arguments - long 101 */ 102 public void testVFE3() { 103 try { 104 Class.forName("dot.junit.opcodes.if_nez.d.T_if_nez_7"); 105 fail("expected a verification exception"); 106 } catch (Throwable t) { 107 DxUtil.checkVerifyException(t); 108 } 109 } 110 111 /** 112 * @constraint B1 113 * @title Type of argument - float. The verifier checks that ints 114 * and floats are not used interchangeably. 115 */ 116 public void testVFE4() { 117 try { 118 Class.forName("dot.junit.opcodes.if_nez.d.T_if_nez_3"); 119 fail("expected a verification exception"); 120 } catch (Throwable t) { 121 DxUtil.checkVerifyException(t); 122 } 123 } 124 125 /** 126 * @constraint A6 127 * @title branch target shall be inside the method 128 */ 129 public void testVFE5() { 130 try { 131 Class.forName("dot.junit.opcodes.if_nez.d.T_if_nez_9"); 132 fail("expected a verification exception"); 133 } catch (Throwable t) { 134 DxUtil.checkVerifyException(t); 135 } 136 } 137 138 /** 139 * @constraint A6 140 * @title branch target shall not be "inside" instruction 141 */ 142 public void testVFE6() { 143 try { 144 Class.forName("dot.junit.opcodes.if_nez.d.T_if_nez_10"); 145 fail("expected a verification exception"); 146 } catch (Throwable t) { 147 DxUtil.checkVerifyException(t); 148 } 149 } 150 151 /** 152 * @constraint n/a 153 * @title branch must not be 0 154 */ 155 public void testVFE7() { 156 try { 157 Class.forName("dot.junit.opcodes.if_nez.d.T_if_nez_11"); 158 fail("expected a verification exception"); 159 } catch (Throwable t) { 160 DxUtil.checkVerifyException(t); 161 } 162 } 163 } 164