• 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.aput_char;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.aput_char.d.T_aput_char_1;
22 import dot.junit.opcodes.aput_char.d.T_aput_char_8;
23 
24 
25 public class Test_aput_char extends DxTestCase {
26     /**
27      * @title put char into array
28      */
testN1()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      */
testN2()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     }
45 
46     /**
47      * @title Type of index argument - float. Dalvik doens't distinguish 32-bits types internally,
48      * so this array[float]=value makes no sense but shall not crash the VM.
49      */
50 
testN3()51     public void testN3() {
52         char[] arr = new char[2];
53         T_aput_char_8 t = new T_aput_char_8();
54         try {
55             t.run(arr, 3.14f, 'g');
56         } catch (Throwable e) {
57         }
58     }
59 
60     /**
61      * @title expected ArrayIndexOutOfBoundsException
62      */
testE1()63     public void testE1() {
64         T_aput_char_1 t = new T_aput_char_1();
65         char[] arr = new char[2];
66         try {
67             t.run(arr, 2, 'g');
68             fail("expected ArrayIndexOutOfBoundsException");
69         } catch (ArrayIndexOutOfBoundsException aie) {
70             // expected
71         }
72     }
73 
74     /**
75      * @title expected NullPointerException
76      */
testE2()77     public void testE2() {
78         T_aput_char_1 t = new T_aput_char_1();
79         try {
80             t.run(null, 2, 'g');
81             fail("expected NullPointerException");
82         } catch (NullPointerException aie) {
83             // expected
84         }
85     }
86 
87     /**
88      * @title expected ArrayIndexOutOfBoundsException (negative index)
89      */
testE3()90     public void testE3() {
91         T_aput_char_1 t = new T_aput_char_1();
92         char[] arr = new char[2];
93         try {
94             t.run(arr, -1, 'g');
95             fail("expected ArrayIndexOutOfBoundsException");
96         } catch (ArrayIndexOutOfBoundsException aie) {
97             // expected
98         }
99     }
100 
101 
102 
103 
104     /**
105      * @constraint B1
106      * @title types of arguments - array, double, char
107      */
testVFE1()108     public void testVFE1() {
109         try {
110             Class.forName("dot.junit.opcodes.aput_char.d.T_aput_char_2");
111             fail("expected a verification exception");
112         } catch (Throwable t) {
113             DxUtil.checkVerifyException(t);
114         }
115     }
116 
117     /**
118      * @constraint B1
119      * @title types of arguments - array, int, long
120      */
testVFE2()121     public void testVFE2() {
122         try {
123             Class.forName("dot.junit.opcodes.aput_char.d.T_aput_char_3");
124             fail("expected a verification exception");
125         } catch (Throwable t) {
126             DxUtil.checkVerifyException(t);
127         }
128     }
129 
130     /**
131      * @constraint B1
132      * @title types of arguments - object, int, char
133      */
testVFE3()134     public void testVFE3() {
135         try {
136             Class.forName("dot.junit.opcodes.aput_char.d.T_aput_char_4");
137             fail("expected a verification exception");
138         } catch (Throwable t) {
139             DxUtil.checkVerifyException(t);
140         }
141     }
142 
143     /**
144      * @constraint B1
145      * @title types of arguments - double[], int, char
146      */
testVFE4()147     public void testVFE4() {
148         try {
149             Class.forName("dot.junit.opcodes.aput_char.d.T_aput_char_5");
150             fail("expected a verification exception");
151         } catch (Throwable t) {
152             DxUtil.checkVerifyException(t);
153         }
154     }
155 
156     /**
157      * @constraint B1
158      * @title types of arguments - long[], int, char
159      */
testVFE5()160     public void testVFE5() {
161         try {
162             Class.forName("dot.junit.opcodes.aput_char.d.T_aput_char_6");
163             fail("expected a verification exception");
164         } catch (Throwable t) {
165             DxUtil.checkVerifyException(t);
166         }
167     }
168 
169     /**
170      * @constraint B1
171      * @title types of arguments - array, reference, char
172      */
testVFE6()173     public void testVFE6() {
174         try {
175             Class.forName("dot.junit.opcodes.aput_char.d.T_aput_char_7");
176             fail("expected a verification exception");
177         } catch (Throwable t) {
178             DxUtil.checkVerifyException(t);
179         }
180     }
181 
182     /**
183      * @constraint A23
184      * @title number of registers
185      */
testVFE7()186     public void testVFE7() {
187         try {
188             Class.forName("dot.junit.opcodes.aput_char.d.T_aput_char_9");
189             fail("expected a verification exception");
190         } catch (Throwable t) {
191             DxUtil.checkVerifyException(t);
192         }
193     }
194 
195     /**
196      * @constraint B15
197      * @title put value 65536 into char array
198      */
testVFE9()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     }
207 
208 }
209