blob: 334d79f96f141508525dea1b3b99b6de9dd37c87 [file] [log] [blame]
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -07001/*
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
17package dot.junit.opcodes.rsub_int;
18
19import dot.junit.DxTestCase;
20import dot.junit.DxUtil;
21import dot.junit.opcodes.rsub_int.d.T_rsub_int_1;
22import dot.junit.opcodes.rsub_int.d.T_rsub_int_2;
23import dot.junit.opcodes.rsub_int.d.T_rsub_int_3;
24import dot.junit.opcodes.rsub_int.d.T_rsub_int_4;
25import dot.junit.opcodes.rsub_int.d.T_rsub_int_5;
26import dot.junit.opcodes.rsub_int.d.T_rsub_int_6;
27import dot.junit.opcodes.rsub_int.d.T_rsub_int_7;
28import dot.junit.opcodes.rsub_int.d.T_rsub_int_12;
29
30public class Test_rsub_int extends DxTestCase {
31
32 /**
33 * @title normal test - check different values
34 */
35 public void testN1() {
36 T_rsub_int_1 t = new T_rsub_int_1();
37 assertEquals("Subtest_1 is failed", -4, t.run(8));
38 assertEquals("Subtest_2 is failed",45, t.run1(15));
39 assertEquals("Subtest_3 is failed",0, t.run2(20));
40 assertEquals("Subtest_4 is failed",-35, t.run3(10));
41 assertEquals("Subtest_5 is failed",-20, t.run4(-50));
42 assertEquals("Subtest_6 is failed",20, t.run5(-70));
43 }
44
45 /**
46 * @title normal test - check different values
47 */
48 public void testN2() {
49 T_rsub_int_2 t = new T_rsub_int_2();
50 assertEquals("Subtest_1 is failed",255, t.run(0));
51 assertEquals("Subtest_2 is failed",-32768, t.run1(0));
52 assertEquals("Subtest_3 is failed",-15, t.run2(15));
53 assertEquals("Subtest_4 is failed",123, t.run2(-123));
54 }
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -070055
56 /**
57 * @title
58 * 1: a = Integer.MAX_VALUE, b = 0, b-a = -Integer.MAX_VALUE
59 * 2: a = Short.MAX_VALUE, b = 0, b-a = -Short.MAX_VALUE
60 */
61 public void testB1() {
62 T_rsub_int_3 t = new T_rsub_int_3();
63 assertEquals(-Integer.MAX_VALUE, t.run(Integer.MAX_VALUE));
64 assertEquals(-Short.MAX_VALUE, t.run(Short.MAX_VALUE));
65 }
66
67 /**
68 * @title
69 * 1: a = Integer.MIN_VALUE, b = 0, b-a = Integer.MIN_VALUE
70 * 2: a = Short.MIN_VALUE, b = 0, b-a = 32768
71 */
72 public void testB2() {
73 T_rsub_int_3 t = new T_rsub_int_3();
74 assertEquals(Integer.MIN_VALUE, t.run(Integer.MIN_VALUE));
75 assertEquals(32768, t.run(Short.MIN_VALUE));
76 }
77
78 /**
79 * @title (a = 0, b = 0, b-a = 0)
80 */
81 public void testB3() {
82 T_rsub_int_3 t = new T_rsub_int_3();
83 assertEquals(0, t.run(0));
84 }
85
86 /**
87 * @title
88 * 1: a = 0, b = Short.MAX_VALUE, b-a = Short.MAX_VALUE
89 * 2: a = 1, b = Short.MAX_VALUE, b-a = 32766
90 * 3: a = -1, b = Short.MAX_VALUE, b-a = 32768
91 */
92 public void testB4() {
93 T_rsub_int_4 t = new T_rsub_int_4();
94 assertEquals(Short.MAX_VALUE, t.run(0));
95 assertEquals(32766, t.run(1));
96 assertEquals(32768, t.run(-1));
97 }
98
99 /**
100 * @title
101 * 1: a = Integer.MIN_VALUE, b = Short.MAX_VALUE, b-a = -2147450881
102 * 2: a = Integer.MAX_VALUE, b = Short.MAX_VALUE, b-a = -2147450880
103 * 3: a = Short.MIN_VALUE, b = Short.MAX_VALUE, b-a = 65535
104 */
105 public void testB5() {
106 T_rsub_int_4 t = new T_rsub_int_4();
107 assertEquals(-2147450881, t.run(Integer.MIN_VALUE));
108 assertEquals(-2147450880, t.run(Integer.MAX_VALUE));
109 assertEquals(65535, t.run(Short.MIN_VALUE));
110 }
111
112 /**
113 * @title
114 * 1: a = 0, b = Short.MIN_VALUE, b-a = Short.MIN_VALUE
115 * 2: a = 1, b = Short.MIN_VALUE, b-a = -32769
116 * 3: a = -1, b = Short.MIN_VALUE, b-a = -32767
117 */
118 public void testB6() {
119 T_rsub_int_5 t = new T_rsub_int_5();
120 assertEquals(Short.MIN_VALUE, t.run(0));
121 assertEquals(-32769, t.run(1));
122 assertEquals(-32767, t.run(-1));
123 }
124
125 /**
126 * @title
127 * 1: a = Integer.MAX_VALUE, b = Short.MIN_VALUE, b-a = 2147450881
128 * 2: a = Integer.MIN_VALUE, b = Short.MIN_VALUE, b-a = 2147450880
129 * 3: a = Short.MAX_VALUE, b = Short.MIN_VALUE, b-a = -65535
130 */
131 public void testB7() {
132 T_rsub_int_5 t = new T_rsub_int_5();
133 assertEquals(2147450881, t.run(Integer.MAX_VALUE));
134 assertEquals(2147450880, t.run(Integer.MIN_VALUE));
135 assertEquals(-65535, t.run(Short.MAX_VALUE));
136 }
137
138 /**
139 * @title
140 * 1: a = Integer.MIN_VALUE, b = -1, b-a = Integer.MAX_VALUE
141 * 2: a = Short.MIN_VALUE, b = -1, b-a = Short.MAX_VALUE
142 */
143 public void testB8() {
144 T_rsub_int_6 t = new T_rsub_int_6();
145 assertEquals(Integer.MAX_VALUE, t.run(Integer.MIN_VALUE));
146 assertEquals(Short.MAX_VALUE, t.run(Short.MIN_VALUE));
147 }
148
149 /**
150 * @title
151 * 1: a = Integer.MAX_VALUE, b = -1, b-a = Integer.MIN_VALUE
152 * 2: a = Short.MAX_VALUE, b = -1, b-a = -32768
153 */
154 public void testB9() {
155 T_rsub_int_6 t = new T_rsub_int_6();
156 assertEquals(Integer.MIN_VALUE, t.run(Integer.MAX_VALUE));
157 assertEquals(-32768, t.run(Short.MAX_VALUE));
158 }
159
160 /**
161 * @title
162 * 1: a = Integer.MIN_VALUE, b = 1, b-a = -Integer.MAX_VALUE
163 * 2: a = Integer.MAX_VALUE, b = 1, b-a = -2147483646
164 */
165 public void testB10() {
166 T_rsub_int_7 t = new T_rsub_int_7();
167 assertEquals(-Integer.MAX_VALUE, t.run(Integer.MIN_VALUE));
168 assertEquals(-2147483646, t.run(Integer.MAX_VALUE));
169 }
170
171 /**
172 * @title
173 * 1: a = Short.MIN_VALUE, b = 1, b-a = 32769
174 * 2: a = Short.MAX_VALUE, b = 1, b-a = -32766
175 */
176 public void testB11() {
177 T_rsub_int_7 t = new T_rsub_int_7();
178 assertEquals(32769, t.run(Short.MIN_VALUE));
179 assertEquals(-32766, t.run(Short.MAX_VALUE));
180 }
181
182 /**
183 * @title (a = 1, b = 1, b-a = 0)
184 */
185 public void testB12() {
186 T_rsub_int_7 t = new T_rsub_int_7();
187 assertEquals(0, t.run(1));
188 }
189
190 /**
191 * @constraint A23
192 * @title number of registers
193 */
194 public void testVFE1() {
195 try {
196 Class.forName("dot.junit.opcodes.rsub_int.d.T_rsub_int_8");
197 fail("expected a verification exception");
198 } catch (Throwable t) {
199 DxUtil.checkVerifyException(t);
200 }
201 }
202
203
204
205 /**
206 * @constraint B1
207 * @title types of arguments - double, int
208 */
209 public void testVFE2() {
210 try {
211 Class.forName("dot.junit.opcodes.rsub_int.d.T_rsub_int_9");
212 fail("expected a verification exception");
213 } catch (Throwable t) {
214 DxUtil.checkVerifyException(t);
215 }
216 }
217
218 /**
219 * @constraint B1
220 * @title types of arguments - long, int
221 */
222 public void testVFE3() {
223 try {
224 Class.forName("dot.junit.opcodes.rsub_int.d.T_rsub_int_10");
225 fail("expected a verification exception");
226 } catch (Throwable t) {
227 DxUtil.checkVerifyException(t);
228 }
229 }
230
231 /**
232 * @constraint B1
233 * @title types of arguments - reference, int
234 */
235 public void testVFE4() {
236 try {
237 Class.forName("dot.junit.opcodes.rsub_int.d.T_rsub_int_11");
238 fail("expected a verification exception");
239 } catch (Throwable t) {
240 DxUtil.checkVerifyException(t);
241 }
242 }
jeffhao4fda9ca2011-10-04 19:20:23 -0700243
244 /**
245 * @constraint B1
246 * @title Types of arguments - float, int. The verifier checks that ints
247 * and floats are not used interchangeably.
248 */
249 public void testVFE5() {
250 try {
251 Class.forName("dot.junit.opcodes.rsub_int.d.T_rsub_int_12");
252 fail("expected a verification exception");
253 } catch (Throwable t) {
254 DxUtil.checkVerifyException(t);
255 }
256 }
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700257}