• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package dxc.junit.opcodes.iinc;
18 
19 import dxc.junit.DxTestCase;
20 import dxc.junit.DxUtil;
21 import dxc.junit.opcodes.iinc.jm.T_iinc_1;
22 import dxc.junit.opcodes.iinc.jm.T_iinc_1_w;
23 import dxc.junit.opcodes.iinc.jm.T_iinc_2;
24 import dxc.junit.opcodes.iinc.jm.T_iinc_2_w;
25 import dxc.junit.opcodes.iinc.jm.T_iinc_3;
26 import dxc.junit.opcodes.iinc.jm.T_iinc_3_w;
27 import dxc.junit.opcodes.iinc.jm.T_iinc_4;
28 import dxc.junit.opcodes.iinc.jm.T_iinc_4_w;
29 import dxc.junit.opcodes.iinc.jm.T_iinc_5;
30 import dxc.junit.opcodes.iinc.jm.T_iinc_5_w;
31 import dxc.junit.opcodes.iinc.jm.T_iinc_6;
32 import dxc.junit.opcodes.iinc.jm.T_iinc_6_w;
33 
34 public class Test_iinc extends DxTestCase {
35 
36     /*
37      * NORMAL IINC VERSION
38      */
39 
40     /**
41      * @title  Increment by 1
42      */
testN1()43     public void testN1() {
44         T_iinc_1 t = new T_iinc_1();
45         assertEquals(5, t.run(4));
46     }
47 
48     /**
49      * @title  Increment by -1
50      */
testN2()51     public void testN2() {
52         T_iinc_2 t = new T_iinc_2();
53         assertEquals(3, t.run(4));
54     }
55 
56     /**
57      * @title  Increment by 63
58      */
testN3()59     public void testN3() {
60         T_iinc_3 t = new T_iinc_3();
61         assertEquals(67, t.run(4));
62     }
63 
64     /**
65      * @title  Increment by 0
66      */
testB1()67     public void testB1() {
68         T_iinc_4 t = new T_iinc_4();
69         assertEquals(Integer.MAX_VALUE, t.run(Integer.MAX_VALUE));
70     }
71 
72     /**
73      * @title  Increment by 0
74      */
testB2()75     public void testB2() {
76         T_iinc_4 t = new T_iinc_4();
77         assertEquals(Integer.MIN_VALUE, t.run(Integer.MIN_VALUE));
78     }
79 
80     /**
81      * @title  Increment by 127
82      */
testB3()83     public void testB3() {
84         T_iinc_5 t = new T_iinc_5();
85         assertEquals(128, t.run(1));
86     }
87 
88     /**
89      * @title  Increment by 127
90      */
testB4()91     public void testB4() {
92         T_iinc_5 t = new T_iinc_5();
93         assertEquals(126, t.run(-1));
94     }
95 
96     /**
97      * @title  Increment by 127
98      */
testB5()99     public void testB5() {
100         T_iinc_5 t = new T_iinc_5();
101         assertEquals(-2147483521, t.run(Integer.MIN_VALUE));
102     }
103 
104     /**
105      * @title  Increment by -128
106      */
testB6()107     public void testB6() {
108         T_iinc_6 t = new T_iinc_6();
109         assertEquals(-127, t.run(1));
110     }
111 
112     /**
113      * @title  Increment by -128
114      */
testB7()115     public void testB7() {
116         T_iinc_6 t = new T_iinc_6();
117         assertEquals(-128, t.run(0));
118     }
119 
120     /**
121      * @constraint 4.8.1.21
122      * @title index must be no greater than
123      * max_locals-1.
124      */
testVFE1()125     public void testVFE1() {
126         try {
127             Class.forName("dxc.junit.opcodes.iinc.jm.T_iinc_7");
128             fail("expected a verification exception");
129         } catch (Throwable t) {
130             DxUtil.checkVerifyException(t);
131         }
132     }
133 
134     /**
135      * @constraint 4.8.1.21
136      * @title index must be a nonnegative integer.
137      */
testVFE2()138     public void testVFE2() {
139         try {
140             Class.forName("dxc.junit.opcodes.iinc.jm.T_iinc_8");
141             fail("expected a verification exception");
142         } catch (Throwable t) {
143             DxUtil.checkVerifyException(t);
144         }
145     }
146 
147     /**
148      * @constraint 4.8.2.1
149      * @title type of argument - double
150      */
testVFE3()151     public void testVFE3() {
152         try {
153             Class.forName("dxc.junit.opcodes.iinc.jm.T_iinc_9");
154             fail("expected a verification exception");
155         } catch (Throwable t) {
156             DxUtil.checkVerifyException(t);
157         }
158     }
159 
160     /**
161      * @constraint 4.8.2.1
162      * @title type of argument - long
163      */
testVFE4()164     public void testVFE4() {
165         try {
166             Class.forName("dxc.junit.opcodes.iinc.jm.T_iinc_10");
167             fail("expected a verification exception");
168         } catch (Throwable t) {
169             DxUtil.checkVerifyException(t);
170         }
171     }
172 
173     /*
174      * WIDE IINC VERSION
175      */
176 
177     /**
178      * @title  Increment by 1
179      */
testN4()180     public void testN4() {
181         T_iinc_1_w t = new T_iinc_1_w();
182         assertEquals(5, t.run(4));
183     }
184 
185     /**
186      * @title  Increment by -1
187      */
testN5()188     public void testN5() {
189         T_iinc_2_w t = new T_iinc_2_w();
190         assertEquals(3, t.run(4));
191     }
192 
193     /**
194      * @title  Increment by 7763
195      */
testN6()196     public void testN6() {
197         T_iinc_3_w t = new T_iinc_3_w();
198         assertEquals(7767, t.run(4));
199     }
200 
201     /**
202      * @title  Increment by 0
203      */
testB8()204     public void testB8() {
205         T_iinc_4_w t = new T_iinc_4_w();
206         assertEquals(Integer.MAX_VALUE, t.run(Integer.MAX_VALUE));
207     }
208 
209     /**
210      * @title  Increment by 0
211      */
testB9()212     public void testB9() {
213         T_iinc_4_w t = new T_iinc_4_w();
214         assertEquals(Integer.MIN_VALUE, t.run(Integer.MIN_VALUE));
215     }
216 
217     /**
218      * @title  Increment by 32767
219      */
testB10()220     public void testB10() {
221         T_iinc_5_w t = new T_iinc_5_w();
222         assertEquals(32768, t.run(1));
223     }
224 
225     /**
226      * @title  Increment by 32767
227      */
testB11()228     public void testB11() {
229         T_iinc_5_w t = new T_iinc_5_w();
230         assertEquals(32766, t.run(-1));
231     }
232 
233     /**
234      * @title  Increment by 32767
235      */
testB12()236     public void testB12() {
237         T_iinc_5_w t = new T_iinc_5_w();
238         assertEquals(-2147450881, t.run(Integer.MIN_VALUE));
239     }
240 
241     /**
242      * @title  Increment by -32768
243      */
testB13()244     public void testB13() {
245         T_iinc_6_w t = new T_iinc_6_w();
246         assertEquals(-32767, t.run(1));
247     }
248 
249     /**
250      * @title  Increment by -32768
251      */
testB14()252     public void testB14() {
253         T_iinc_6_w t = new T_iinc_6_w();
254         assertEquals(-32768, t.run(0));
255     }
256 
257     /**
258      * @constraint 4.8.1.25
259      * @title index must be no greater than
260      * max_locals-1.
261      */
testVFE5()262     public void testVFE5() {
263         try {
264             Class.forName("dxc.junit.opcodes.iinc.jm.T_iinc_7_w");
265             fail("expected a verification exception");
266         } catch (Throwable t) {
267             DxUtil.checkVerifyException(t);
268         }
269     }
270 
271     /**
272      * @constraint 4.8.1.25
273      * @title index must be a nonnegative integer.
274      */
testVFE6()275     public void testVFE6() {
276         try {
277             Class.forName("dxc.junit.opcodes.iinc.jm.T_iinc_8_w");
278             fail("expected a verification exception");
279         } catch (Throwable t) {
280             DxUtil.checkVerifyException(t);
281         }
282     }
283 
284     /**
285      * @constraint 4.8.2.1
286      * @title type of argument - double
287      */
testVFE7()288     public void testVFE7() {
289         try {
290             Class.forName("dxc.junit.opcodes.iinc.jm.T_iinc_9_w");
291             fail("expected a verification exception");
292         } catch (Throwable t) {
293             DxUtil.checkVerifyException(t);
294         }
295     }
296 
297     /**
298      * @constraint 4.8.2.1
299      * @title type of argument - long
300      */
testVFE8()301     public void testVFE8() {
302         try {
303             Class.forName("dxc.junit.opcodes.iinc.jm.T_iinc_10_w");
304             fail("expected a verification exception");
305         } catch (Throwable t) {
306             DxUtil.checkVerifyException(t);
307         }
308     }
309 }
310