• 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 Types of arguments - float. Dalvik doens't distinguish 32-bits types internally,
36      * so this operation of float makes no sense but shall not crash the VM.
37      */
testN3()38     public void testN3() {
39         T_if_eqz_3 t = new T_if_eqz_3();
40         assertEquals(1234, t.run(3.123f));
41     }
42 
43     /**
44      * @title Arguments = Integer.MAX_VALUE
45      */
testB1()46     public void testB1() {
47         T_if_eqz_1 t = new T_if_eqz_1();
48         assertEquals(1234, t.run(Integer.MAX_VALUE));
49     }
50 
51     /**
52      * @title Arguments = Integer.MIN_VALUE
53      */
testB2()54     public void testB2() {
55         T_if_eqz_1 t = new T_if_eqz_1();
56         assertEquals(1234, t.run(Integer.MIN_VALUE));
57     }
58 
59     /**
60      * @title Arguments = Float.MAX_VALUE
61      */
testB3()62     public void testB3() {
63         T_if_eqz_3 t = new T_if_eqz_3();
64         assertEquals(1234, t.run(Float.MAX_VALUE));
65     }
66 
67     /**
68      * @title Arguments = Float.MIN_VALUE
69      */
testB4()70     public void testB4() {
71         T_if_eqz_3 t = new T_if_eqz_3();
72         assertEquals(1234, t.run(Float.MIN_VALUE));
73     }
74 
75     /**
76      * @title Arguments = 0
77      */
testB5()78     public void testB5() {
79         T_if_eqz_1 t = new T_if_eqz_1();
80         assertEquals(1, t.run(0));
81     }
82 
83     /**
84      * @title Compare with null
85      */
testB6()86     public void testB6() {
87         T_if_eqz_4 t = new T_if_eqz_4();
88         assertEquals(1, t.run(null));
89     }
90 
91     /**
92      * @constraint A23
93      * @title  number of registers
94      */
testVFE1()95     public void testVFE1() {
96         try {
97             Class.forName("dot.junit.opcodes.if_eqz.d.T_if_eqz_5");
98             fail("expected a verification exception");
99         } catch (Throwable t) {
100             DxUtil.checkVerifyException(t);
101         }
102     }
103 
104 
105     /**
106      * @constraint B1
107      * @title  types of arguments - double
108      */
testVFE2()109     public void testVFE2() {
110         try {
111             Class.forName("dot.junit.opcodes.if_eqz.d.T_if_eqz_6");
112             fail("expected a verification exception");
113         } catch (Throwable t) {
114             DxUtil.checkVerifyException(t);
115         }
116     }
117 
118     /**
119      * @constraint B1
120      * @title  types of arguments - long
121      */
testVFE3()122     public void testVFE3() {
123         try {
124             Class.forName("dot.junit.opcodes.if_eqz.d.T_if_eqz_7");
125             fail("expected a verification exception");
126         } catch (Throwable t) {
127             DxUtil.checkVerifyException(t);
128         }
129     }
130 
131     /**
132      * @constraint A6
133      * @title  branch target shall be inside the method
134      */
testVFE4()135     public void testVFE4() {
136         try {
137             Class.forName("dot.junit.opcodes.if_eqz.d.T_if_eqz_9");
138             fail("expected a verification exception");
139         } catch (Throwable t) {
140             DxUtil.checkVerifyException(t);
141         }
142     }
143 
144     /**
145      * @constraint A6
146      * @title  branch target shall not be "inside" instruction
147      */
testVFE5()148     public void testVFE5() {
149         try {
150             Class.forName("dot.junit.opcodes.if_eqz.d.T_if_eqz_10");
151             fail("expected a verification exception");
152         } catch (Throwable t) {
153             DxUtil.checkVerifyException(t);
154         }
155     }
156 
157     /**
158      * @constraint n/a
159      * @title  branch must not be 0
160      */
testVFE6()161     public void testVFE6() {
162         try {
163             Class.forName("dot.junit.opcodes.if_eqz.d.T_if_eqz_11");
164             fail("expected a verification exception");
165         } catch (Throwable t) {
166             DxUtil.checkVerifyException(t);
167         }
168     }
169 }
170