• 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.filled_new_array_range;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_1;
22 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_2;
23 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_9;
24 
25 public class Test_filled_new_array_range extends DxTestCase {
26     /**
27      * @title array of ints
28      */
testN1()29     public void testN1() {
30         T_filled_new_array_range_1 t = new T_filled_new_array_range_1();
31         int[] arr = t.run(1, 2, 3, 4, 5);
32         assertNotNull(arr);
33         assertEquals(5, arr.length);
34         for(int i = 0; i < 5; i++)
35             assertEquals(i + 1, arr[i]);
36      }
37 
38     /**
39      * @title array of objects
40      */
testN2()41     public void testN2() {
42         T_filled_new_array_range_2 t = new T_filled_new_array_range_2();
43         String s = "android";
44         Object[] arr = t.run(t, s);
45         assertNotNull(arr);
46         assertEquals(2, arr.length);
47         assertEquals(t, arr[0]);
48         assertEquals(s, arr[1]);
49     }
50 
51     /**
52      * @constraint A18
53      * @title invalid constant pool index
54      */
testVFE1()55     public void testVFE1() {
56         try {
57             Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_3");
58             fail("expected a verification exception");
59         } catch (Throwable t) {
60             DxUtil.checkVerifyException(t);
61         }
62     }
63 
64     /**
65      * @constraint A23
66      * @title  number of registers
67      */
testVFE2()68     public void testVFE2() {
69         try {
70             Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_4");
71             fail("expected a verification exception");
72         } catch (Throwable t) {
73             DxUtil.checkVerifyException(t);
74         }
75     }
76 
77     /**
78      * @constraint B1
79      * @title try to pass obj ref instead of int
80      */
testVFE3()81     public void testVFE3() {
82         try {
83             Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_5");
84             fail("expected a verification exception");
85         } catch (Throwable t) {
86             DxUtil.checkVerifyException(t);
87         }
88     }
89 
90     /**
91      * @constraint B1
92      * @title try to pass long instead of int
93      */
testVFE4()94     public void testVFE4() {
95         try {
96             Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_6");
97             fail("expected a verification exception");
98         } catch (Throwable t) {
99             DxUtil.checkVerifyException(t);
100         }
101     }
102 
103     /**
104      * @constraint B1
105      * @title try to create non-array type
106      */
testVFE5()107     public void testVFE5() {
108         try {
109             Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_7");
110             fail("expected a verification exception");
111         } catch (Throwable t) {
112             DxUtil.checkVerifyException(t);
113         }
114     }
115 
116     /**
117      * @constraint B1
118      * @title invalid arg count
119      */
testVFE6()120     public void testVFE6() {
121         try {
122             Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_8");
123             fail("expected a verification exception");
124         } catch (Throwable t) {
125             DxUtil.checkVerifyException(t);
126         }
127     }
128 
129     /**
130      * @constraint n/a
131      * @title attempt to instantiate String[] and fill it with reference to assignment-incompatible class
132      */
testVFE7()133     public void testVFE7() {
134         try {
135         	Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_9");
136         	fail("expected a verification exception");
137         } catch(Throwable t) {
138         	DxUtil.checkVerifyException(t);
139         }
140     }
141 
142     /**
143      * @constraint n/a
144      * @title attempt to instantiate array of non-existent class
145      */
testVFE8()146     public void testVFE8() {
147         try {
148         	Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_10");
149         	fail("expected a verification exception");
150         } catch(Throwable t) {
151         	DxUtil.checkVerifyException(t);
152         }
153     }
154 
155     /**
156      * @constraint n/a
157      * @title attempt to instantiate array of inaccessible class
158      */
testVFE9()159     public void testVFE9() {
160     	//@uses dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_11
161         //@uses dot.junit.opcodes.filled_new_array_range.TestStubs
162         try {
163         	Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_11");
164         	fail("expected a verification exception");
165         } catch(Throwable t) {
166         	DxUtil.checkVerifyException(t);
167         }
168     }
169 
170 }
171