• 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 dot.junit.opcodes.mul_int;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.mul_int.d.T_mul_int_1;
22 import dot.junit.opcodes.mul_int.d.T_mul_int_6;
23 
24 public class Test_mul_int extends DxTestCase {
25 
26     /**
27      * @title Arguments = 8, 4
28      */
testN1()29     public void testN1() {
30         T_mul_int_1 t = new T_mul_int_1();
31         assertEquals(32, t.run(8, 4));
32     }
33 
34     /**
35      * @title Arguments = -2, 255
36      */
testN2()37     public void testN2() {
38         T_mul_int_1 t = new T_mul_int_1();
39         assertEquals(-510, t.run(-2, 255));
40     }
41 
42     /**
43      * @title Arguments = 0x7ffffffe, 2
44      */
testN3()45     public void testN3() {
46         T_mul_int_1 t = new T_mul_int_1();
47         assertEquals(-4, t.run(0x7ffffffe, 2));
48     }
49 
50     /**
51      * @title Arguments = 4, 0x80000001
52      */
testN4()53     public void testN4() {
54         T_mul_int_1 t = new T_mul_int_1();
55         assertEquals(4, t.run(4, 0x80000001));
56     }
57 
58     /**
59      * @title Types of arguments - int, float. Dalvik doens't distinguish 32-bits types internally,
60      * so this multiplication of float and int makes no sense but shall not crash the VM.
61      */
testN5()62     public void testN5() {
63         T_mul_int_6 t = new T_mul_int_6();
64         try {
65             t.run(1, 3.14f);
66         } catch (Throwable e) {
67         }
68     }
69 
70     /**
71      * @title Arguments = 0, Integer.MAX_VALUE
72      */
testB1()73     public void testB1() {
74         T_mul_int_1 t = new T_mul_int_1();
75         assertEquals(0, t.run(0, Integer.MAX_VALUE));
76     }
77 
78     /**
79      * @title Arguments = Integer.MAX_VALUE, 1
80      */
testB2()81     public void testB2() {
82         T_mul_int_1 t = new T_mul_int_1();
83         assertEquals(Integer.MAX_VALUE, t.run(Integer.MAX_VALUE, 1));
84     }
85 
86     /**
87      * @title Arguments = Integer.MIN_VALUE, 1
88      */
testB3()89     public void testB3() {
90         T_mul_int_1 t = new T_mul_int_1();
91         assertEquals(Integer.MIN_VALUE, t.run(Integer.MIN_VALUE, 1));
92     }
93 
94     /**
95      * @title Arguments = Integer.MAX_VALUE, Integer.MIN_VALUE
96      */
testB4()97     public void testB4() {
98         T_mul_int_1 t = new T_mul_int_1();
99         assertEquals(Integer.MIN_VALUE, t.run(Integer.MAX_VALUE,
100                 Integer.MIN_VALUE));
101     }
102 
103     /**
104      * @title Arguments = 0, 0
105      */
testB5()106     public void testB5() {
107         T_mul_int_1 t = new T_mul_int_1();
108         assertEquals(0, t.run(0, 0));
109     }
110 
111     /**
112      * @constraint A23
113      * @title number of registers
114      */
testVFE1()115     public void testVFE1() {
116         try {
117             Class.forName("dot.junit.opcodes.mul_int.d.T_mul_int_2");
118             fail("expected a verification exception");
119         } catch (Throwable t) {
120             DxUtil.checkVerifyException(t);
121         }
122     }
123 
124 
125 
126     /**
127      * @constraint B1
128      * @title types of arguments - int, double
129      */
testVFE2()130     public void testVFE2() {
131         try {
132             Class.forName("dot.junit.opcodes.mul_int.d.T_mul_int_3");
133             fail("expected a verification exception");
134         } catch (Throwable t) {
135             DxUtil.checkVerifyException(t);
136         }
137     }
138 
139     /**
140      * @constraint B1
141      * @title types of arguments - long, int
142      */
testVFE3()143     public void testVFE3() {
144         try {
145             Class.forName("dot.junit.opcodes.mul_int.d.T_mul_int_4");
146             fail("expected a verification exception");
147         } catch (Throwable t) {
148             DxUtil.checkVerifyException(t);
149         }
150     }
151 
152     /**
153      * @constraint B1
154      * @title types of arguments - reference, int
155      */
testVFE4()156     public void testVFE4() {
157         try {
158             Class.forName("dot.junit.opcodes.mul_int.d.T_mul_int_5");
159             fail("expected a verification exception");
160         } catch (Throwable t) {
161             DxUtil.checkVerifyException(t);
162         }
163     }
164 }
165