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