• 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.div_int_lit8;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_17;
22 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_1;
23 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_10;
24 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_11;
25 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_12;
26 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_13;
27 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_2;
28 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_3;
29 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_4;
30 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_5;
31 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_6;
32 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_7;
33 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_8;
34 import dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_9;
35 
36 public class Test_div_int_lit8 extends DxTestCase {
37      /**
38      * @title Arguments = 8 / 4
39      */
testN1()40     public void testN1() {
41         T_div_int_lit8_1 t = new T_div_int_lit8_1();
42         assertEquals(2, t.run());
43     }
44 
45     /**
46      * @title Rounding
47      */
testN2()48     public void testN2() {
49         T_div_int_lit8_2 t = new T_div_int_lit8_2();
50         assertEquals(268435455, t.run());
51     }
52 
53     /**
54      * @title Dividend = 0
55      */
testN3()56     public void testN3() {
57         T_div_int_lit8_3 t = new T_div_int_lit8_3();
58         assertEquals(0, t.run());
59     }
60 
61     /**
62      * @title Dividend is negative
63      */
testN4()64     public void testN4() {
65         T_div_int_lit8_4 t = new T_div_int_lit8_4();
66         assertEquals(-3, t.run());
67     }
68 
69     /**
70      * @title Divisor is negative
71      */
testN5()72     public void testN5() {
73         T_div_int_lit8_5 t = new T_div_int_lit8_5();
74         assertEquals(-357913941, t.run());
75     }
76 
77     /**
78      * @title Both Dividend and divisor are negative
79      */
testN6()80     public void testN6() {
81         T_div_int_lit8_6 t = new T_div_int_lit8_6();
82         assertEquals(596523, t.run());
83     }
84 
85     /**
86      * @title Arguments = Integer.MIN_VALUE / -1
87      */
testB1()88     public void testB1() {
89         T_div_int_lit8_7 t = new T_div_int_lit8_7();
90         // result is MIN_VALUE because overflow occurs in this case
91         assertEquals(Integer.MIN_VALUE, t.run());
92     }
93 
94     /**
95      * @title Arguments = Integer.MIN_VALUE / 1
96      */
testB2()97     public void testB2() {
98         T_div_int_lit8_8 t = new T_div_int_lit8_8();
99         assertEquals(Integer.MIN_VALUE, t.run());
100     }
101 
102     /**
103      * @title Arguments = Integer.MAX_VALUE / 1
104      */
testB3()105     public void testB3() {
106         T_div_int_lit8_9 t = new T_div_int_lit8_9();
107         assertEquals(Integer.MAX_VALUE, t.run());
108     }
109 
110     /**
111      * @title Arguments = Integer.MIN_VALUE / Byte.MAX_VALUE
112      */
testB4()113     public void testB4() {
114         T_div_int_lit8_10 t = new T_div_int_lit8_10();
115         assertEquals(-16909320, t.run());
116     }
117 
118     /**
119      * @title Arguments = 1 / Byte.MAX_VALUE
120      */
testB5()121     public void testB5() {
122         T_div_int_lit8_11 t = new T_div_int_lit8_11();
123         assertEquals(0, t.run());
124     }
125 
126     /**
127      * @title Arguments = 1 / Byte.MIN_VALUE
128      */
testB6()129     public void testB6() {
130         T_div_int_lit8_12 t = new T_div_int_lit8_12();
131         assertEquals(0, t.run());
132     }
133 
134     /**
135      * @title Divisor is 0
136      */
testE1()137     public void testE1() {
138         loadAndRun("dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_13", ArithmeticException.class);
139     }
140 
141 
142 
143     /**
144      * @constraint B1
145      * @title types of arguments - int / double
146      */
testVFE1()147     public void testVFE1() {
148         load("dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_14", VerifyError.class);
149     }
150 
151     /**
152      * @constraint B1
153      * @title types of arguments - long / int
154      */
testVFE2()155     public void testVFE2() {
156         load("dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_15", VerifyError.class);
157     }
158 
159     /**
160      * @constraint B1
161      * @title types of arguments - reference / int
162      */
testVFE3()163     public void testVFE3() {
164         load("dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_16", VerifyError.class);
165     }
166 
167     /**
168      * @constraint A23
169      * @title  number of registers
170      */
testVFE4()171     public void testVFE4() {
172         load("dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_18", VerifyError.class);
173     }
174 
175     /**
176      * @constraint B1
177      * @title Types of arguments - int, float. The verifier checks that ints
178      * and floats are not used interchangeably.
179      */
testVFE5()180     public void testVFE5() {
181         load("dot.junit.opcodes.div_int_lit8.d.T_div_int_lit8_17", VerifyError.class);
182     }
183 }
184