• 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.aget_boolean;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.aget_boolean.d.T_aget_boolean_1;
22 import dot.junit.opcodes.aget_boolean.d.T_aget_boolean_8;
23 
24 public class Test_aget_boolean extends DxTestCase {
25     /**
26      * @title get boolean from array
27      */
testN1()28     public void testN1() {
29         T_aget_boolean_1 t = new T_aget_boolean_1();
30         boolean[] arr = new boolean[2];
31         arr[1] = true;
32         assertEquals(true, t.run(arr, 1));
33     }
34 
35     /**
36      * @title get boolean from array
37      */
testN2()38     public void testN2() {
39         T_aget_boolean_1 t = new T_aget_boolean_1();
40         boolean[] arr = new boolean[2];
41         arr[0] = true;
42         assertEquals(true, t.run(arr, 0));
43     }
44 
45     /**
46      * @title Type of index argument - float. Dalvik doens't distinguish 32-bits types internally,
47      * so this array[float] makes no sense but shall not crash the VM.
48      */
49 
testN3()50     public void testN3() {
51         boolean[] arr = new boolean[2];
52         T_aget_boolean_8 t = new T_aget_boolean_8();
53         try {
54             t.run(arr, 3.14f);
55         } catch (Throwable e) {
56         }
57     }
58 
59     /**
60      * @title expected ArrayIndexOutOfBoundsException
61      */
testE1()62     public void testE1() {
63         T_aget_boolean_1 t = new T_aget_boolean_1();
64         boolean[] arr = new boolean[2];
65         try {
66             t.run(arr, 2);
67             fail("expected ArrayIndexOutOfBoundsException");
68         } catch (ArrayIndexOutOfBoundsException aie) {
69             // expected
70         }
71     }
72 
73     /**
74      * @title expected NullPointerException
75      */
testE2()76     public void testE2() {
77         T_aget_boolean_1 t = new T_aget_boolean_1();
78         try {
79             t.run(null, 2);
80             fail("expected NullPointerException");
81         } catch (NullPointerException aie) {
82             // expected
83         }
84     }
85 
86     /**
87      * @title expected ArrayIndexOutOfBoundsException (negative index)
88      */
testE3()89     public void testE3() {
90         T_aget_boolean_1 t = new T_aget_boolean_1();
91         boolean[] arr = new boolean[2];
92         try {
93             t.run(arr, -1);
94             fail("expected ArrayIndexOutOfBoundsException");
95         } catch (ArrayIndexOutOfBoundsException aie) {
96             // expected
97         }
98     }
99 
100 
101 
102     /**
103      * @constraint B1
104      * @title types of arguments - array, double
105      */
testVFE1()106     public void testVFE1() {
107         try {
108             Class.forName("dot.junit.opcodes.aget_boolean.d.T_aget_boolean_2");
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 - array, long
118      */
testVFE2()119     public void testVFE2() {
120         try {
121             Class.forName("dot.junit.opcodes.aget_boolean.d.T_aget_boolean_3");
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 - Object, int
131      */
testVFE3()132     public void testVFE3() {
133         try {
134             Class.forName("dot.junit.opcodes.aget_boolean.d.T_aget_boolean_4");
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 - double[], int
144      */
testVFE4()145     public void testVFE4() {
146         try {
147             Class.forName("dot.junit.opcodes.aget_boolean.d.T_aget_boolean_5");
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 - long[], int
157      */
testVFE5()158     public void testVFE5() {
159         try {
160             Class.forName("dot.junit.opcodes.aget_boolean.d.T_aget_boolean_6");
161             fail("expected a verification exception");
162         } catch (Throwable t) {
163             DxUtil.checkVerifyException(t);
164         }
165     }
166 
167     /**
168      * @constraint B1
169      * @title types of arguments - array, reference
170      */
testVFE6()171     public void testVFE6() {
172         try {
173             Class.forName("dot.junit.opcodes.aget_boolean.d.T_aget_boolean_7");
174             fail("expected a verification exception");
175         } catch (Throwable t) {
176             DxUtil.checkVerifyException(t);
177         }
178     }
179 
180     /**
181      * @constraint A23
182      * @title number of registers
183      */
testVFE7()184     public void testVFE7() {
185         try {
186             Class.forName("dot.junit.opcodes.aget_boolean.d.T_aget_boolean_9");
187             fail("expected a verification exception");
188         } catch (Throwable t) {
189             DxUtil.checkVerifyException(t);
190         }
191     }
192 }
193