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