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