• 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.rem_int_lit8;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_1;
22 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_2;
23 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_3;
24 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_4;
25 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_5;
26 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_6;
27 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_7;
28 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_8;
29 import dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_9;
30 
31 public class Test_rem_int_lit8 extends DxTestCase {
32 
33     /**
34      * @title Arguments = 8, 4
35      */
testN1()36     public void testN1() {
37         T_rem_int_lit8_1 t = new T_rem_int_lit8_1();
38         assertEquals(0, t.run(8));
39     }
40 
41     /**
42      * @title Arguments = 123, 4
43      */
testN2()44     public void testN2() {
45         T_rem_int_lit8_1 t = new T_rem_int_lit8_1();
46         assertEquals(3, t.run(123));
47     }
48 
49     /**
50      * @title Dividend = 0
51      */
testN3()52     public void testN3() {
53         T_rem_int_lit8_1 t = new T_rem_int_lit8_1();
54         assertEquals(0, t.run(0));
55     }
56 
57     /**
58      * @title Dividend is negative
59      */
testN4()60     public void testN4() {
61         T_rem_int_lit8_1 t = new T_rem_int_lit8_1();
62         assertEquals(-2, t.run(-10));
63     }
64 
65     /**
66      * @title Divisor is negative
67      */
testN5()68     public void testN5() {
69         T_rem_int_lit8_2 t = new T_rem_int_lit8_2();
70         assertEquals(0, t.run(123));
71     }
72 
73     /**
74      * @title Both Dividend and divisor are negative
75      */
testN6()76     public void testN6() {
77         T_rem_int_lit8_3 t = new T_rem_int_lit8_3();
78         assertEquals(-3, t.run(-123));
79     }
80 
81     /**
82      * @title Arguments = Byte.MIN_VALUE, -1
83      */
testB1()84     public void testB1() {
85         T_rem_int_lit8_5 t = new T_rem_int_lit8_5();
86         assertEquals(0, t.run(Byte.MIN_VALUE));
87     }
88 
89     /**
90      * @title Arguments = Byte.MIN_VALUE, 1
91      */
testB2()92     public void testB2() {
93         T_rem_int_lit8_6 t = new T_rem_int_lit8_6();
94         assertEquals(0, t.run(Byte.MIN_VALUE));
95     }
96 
97     /**
98      * @title Arguments = Byte.MAX_VALUE, 1
99      */
testB3()100     public void testB3() {
101         T_rem_int_lit8_6 t = new T_rem_int_lit8_6();
102         assertEquals(0, t.run(Byte.MAX_VALUE));
103     }
104 
105     /**
106      * @title Arguments = Short.MIN_VALUE, 127
107      */
testB4()108     public void testB4() {
109         T_rem_int_lit8_7 t = new T_rem_int_lit8_7();
110         assertEquals(-2, t.run(Short.MIN_VALUE));
111     }
112 
113     /**
114      * @title Arguments = 1, 127
115      */
testB5()116     public void testB5() {
117         T_rem_int_lit8_7 t = new T_rem_int_lit8_7();
118         assertEquals(1, t.run(1));
119     }
120 
121     /**
122      * @title Arguments = 1, -128
123      */
testB6()124     public void testB6() {
125         T_rem_int_lit8_8 t = new T_rem_int_lit8_8();
126         assertEquals(1, t.run(1));
127     }
128 
129     /**
130      * @title Divisor is 0
131      */
testE1()132     public void testE1() {
133         T_rem_int_lit8_9 t = new T_rem_int_lit8_9();
134         try {
135             t.run(1);
136             fail("expected ArithmeticException");
137         } catch (ArithmeticException ae) {
138             // expected
139         }
140     }
141 
142     /**
143      * @constraint A23
144      * @title number of registers
145      */
testVFE1()146     public void testVFE1() {
147         try {
148             Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_10");
149             fail("expected a verification exception");
150         } catch (Throwable t) {
151             DxUtil.checkVerifyException(t);
152         }
153     }
154 
155 
156 
157     /**
158      * @constraint B1
159      * @title types of arguments - int, double
160      */
testVFE2()161     public void testVFE2() {
162         try {
163             Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_11");
164             fail("expected a verification exception");
165         } catch (Throwable t) {
166             DxUtil.checkVerifyException(t);
167         }
168     }
169 
170     /**
171      * @constraint B1
172      * @title types of arguments - long, int
173      */
testVFE3()174     public void testVFE3() {
175         try {
176             Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_12");
177             fail("expected a verification exception");
178         } catch (Throwable t) {
179             DxUtil.checkVerifyException(t);
180         }
181     }
182 
183     /**
184      * @constraint B1
185      * @title types of arguments - reference, int
186      */
testVFE4()187     public void testVFE4() {
188         try {
189             Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_13");
190             fail("expected a verification exception");
191         } catch (Throwable t) {
192             DxUtil.checkVerifyException(t);
193         }
194     }
195 
196     /**
197      * @constraint B1
198      * @title Types of arguments - float, int. The verifier checks that ints
199      * and floats are not used interchangeably.
200      */
testVFE5()201     public void testVFE5() {
202         try {
203             Class.forName("dot.junit.opcodes.rem_int_lit8.d.T_rem_int_lit8_4");
204             fail("expected a verification exception");
205         } catch (Throwable t) {
206             DxUtil.checkVerifyException(t);
207         }
208     }
209 
210 }
211