blob: 96ef2b6d6b792a07fef72e9c7988c1d00253901d [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.aput_byte;
18
19import dot.junit.DxTestCase;
20import dot.junit.DxUtil;
21import dot.junit.opcodes.aput_byte.d.T_aput_byte_1;
22import dot.junit.opcodes.aput_byte.d.T_aput_byte_8;
23
24public class Test_aput_byte extends DxTestCase {
25 /**
26 * @title put byte into array
27 */
28 public void testN1() {
29 T_aput_byte_1 t = new T_aput_byte_1();
30 byte[] arr = new byte[2];
31 t.run(arr, 1, (byte) 100);
32 assertEquals(100, arr[1]);
33 }
34
35 /**
36 * @title put byte into array
37 */
38 public void testN2() {
39 T_aput_byte_1 t = new T_aput_byte_1();
40 byte[] arr = new byte[2];
41 t.run(arr, 0, (byte) 100);
42 assertEquals(100, arr[0]);
43 }
44
45 /**
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -070046 * @title expected ArrayIndexOutOfBoundsException
47 */
48 public void testE1() {
49 T_aput_byte_1 t = new T_aput_byte_1();
50 byte[] arr = new byte[2];
51 try {
52 t.run(arr, 2, (byte) 100);
53 fail("expected ArrayIndexOutOfBoundsException");
54 } catch (ArrayIndexOutOfBoundsException aie) {
55 // expected
56 }
57 }
58
59 /**
60 * @title expected NullPointerException
61 */
62 public void testE2() {
63 T_aput_byte_1 t = new T_aput_byte_1();
64 try {
65 t.run(null, 2, (byte) 100);
66 fail("expected NullPointerException");
67 } catch (NullPointerException aie) {
68 // expected
69 }
70 }
71
72 /**
73 * @title expected ArrayIndexOutOfBoundsException (negative index)
74 */
75 public void testE3() {
76 T_aput_byte_1 t = new T_aput_byte_1();
77 byte[] arr = new byte[2];
78 try {
79 t.run(arr, -1, (byte) 100);
80 fail("expected ArrayIndexOutOfBoundsException");
81 } catch (ArrayIndexOutOfBoundsException aie) {
82 // expected
83 }
84 }
85
86
87
88
89 /**
90 * @constraint B1
91 * @title types of arguments - array, double, short
92 */
93 public void testVFE1() {
94 try {
95 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_2");
96 fail("expected a verification exception");
97 } catch (Throwable t) {
98 DxUtil.checkVerifyException(t);
99 }
100 }
101
102 /**
103 * @constraint B1
104 * @title types of arguments - array, int, long
105 */
106 public void testVFE2() {
107 try {
108 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_3");
109 fail("expected a verification exception");
110 } catch (Throwable t) {
111 DxUtil.checkVerifyException(t);
112 }
113 }
114
115 /**
116 * @constraint B1
117 * @title types of arguments - object, int, short
118 */
119 public void testVFE3() {
120 try {
121 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_4");
122 fail("expected a verification exception");
123 } catch (Throwable t) {
124 DxUtil.checkVerifyException(t);
125 }
126 }
127
128 /**
129 * @constraint B1
130 * @title types of arguments - double[], int, short
131 */
132 public void testVFE4() {
133 try {
134 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_5");
135 fail("expected a verification exception");
136 } catch (Throwable t) {
137 DxUtil.checkVerifyException(t);
138 }
139 }
140
141 /**
142 * @constraint B1
143 * @title types of arguments - long[], int, short
144 */
145 public void testVFE5() {
146 try {
147 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_6");
148 fail("expected a verification exception");
149 } catch (Throwable t) {
150 DxUtil.checkVerifyException(t);
151 }
152 }
153
154 /**
155 * @constraint B1
156 * @title types of arguments - array, reference, short
157 */
158 public void testVFE6() {
159 try {
160 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_7");
161 fail("expected a verification exception");
162 } catch (Throwable t) {
163 DxUtil.checkVerifyException(t);
164 }
165 }
166
167 /**
168 * @constraint A23
169 * @title number of registers
170 */
171 public void testVFE7() {
172 try {
173 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_9");
174 fail("expected a verification exception");
175 } catch (Throwable t) {
176 DxUtil.checkVerifyException(t);
177 }
178 }
179
180 /**
181 * @constraint B15
182 * @title put value 128 into byte array
183 */
184 public void testVFE8() {
185 try {
186 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_10");
187 fail("expected a verification exception");
188 } catch (Throwable t) {
189 DxUtil.checkVerifyException(t);
190 }
191 }
jeffhao4fda9ca2011-10-04 19:20:23 -0700192
193 /**
194 * @constraint B1
195 * @title Type of index argument - float. The verifier checks that ints
196 * and floats are not used interchangeably.
197 */
198 public void testVFE9() {
199 try {
200 Class.forName("dot.junit.opcodes.aput_byte.d.T_aput_byte_8");
201 fail("expected a verification exception");
202 } catch (Throwable t) {
203 DxUtil.checkVerifyException(t);
204 }
205 }
206
Tsu Chiang Chuang9a223d72011-04-27 17:19:46 -0700207}