• 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_wide;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.aget_wide.d.T_aget_wide_1;
22 import dot.junit.opcodes.aget_wide.d.T_aget_wide_10;
23 import dot.junit.opcodes.aget_wide.d.T_aget_wide_2;
24 
25 
26 public class Test_aget_wide extends DxTestCase {
27 
28     /**
29      * @title get long from array
30      */
testN1()31     public void testN1() {
32         T_aget_wide_1 t = new T_aget_wide_1();
33         long[] arr = new long[2];
34         arr[1] = 1000000000000000000l;
35         assertEquals(1000000000000000000l, t.run(arr, 1));
36     }
37 
38     /**
39      * @title get long from array
40      */
testN2()41     public void testN2() {
42         T_aget_wide_1 t = new T_aget_wide_1();
43         long[] arr = new long[2];
44         arr[0] = 1000000000000000000l;
45         assertEquals(1000000000000000000l, t.run(arr, 0));
46     }
47 
48     /**
49      * @title get double from array
50      */
testN3()51     public void testN3() {
52         T_aget_wide_2 t = new T_aget_wide_2();
53         double[] arr = new double[2];
54         arr[0] = 3.1415d;
55         assertEquals(3.1415d, t.run(arr, 0));
56     }
57 
58     /**
59      * @title expected ArrayIndexOutOfBoundsException
60      */
testE1()61     public void testE1() {
62         loadAndRun("dot.junit.opcodes.aget_wide.d.T_aget_wide_1",
63                    ArrayIndexOutOfBoundsException.class, new long[2], 2);
64     }
65 
66     /**
67      * @title expected NullPointerException
68      */
testE2()69     public void testE2() {
70         loadAndRun("dot.junit.opcodes.aget_wide.d.T_aget_wide_1", NullPointerException.class,
71                    null, 2);
72     }
73 
74     /**
75      * @title expected ArrayIndexOutOfBoundsException (negative index)
76      */
testE3()77     public void testE3() {
78         loadAndRun("dot.junit.opcodes.aget_wide.d.T_aget_wide_1",
79                    ArrayIndexOutOfBoundsException.class, new long[2], -1);
80     }
81 
82     /**
83      * @constraint B1
84      * @title types of arguments - array, double
85      */
testVFE1()86     public void testVFE1() {
87         load("dot.junit.opcodes.aget_wide.d.T_aget_wide_3", VerifyError.class);
88     }
89 
90     /**
91      * @constraint B1
92      * @title types of arguments - array, long
93      */
testVFE2()94     public void testVFE2() {
95         load("dot.junit.opcodes.aget_wide.d.T_aget_wide_5", VerifyError.class);
96     }
97 
98     /**
99      * @constraint B1
100      * @title types of arguments - Object, int
101      */
testVFE3()102     public void testVFE3() {
103         load("dot.junit.opcodes.aget_wide.d.T_aget_wide_6", VerifyError.class);
104     }
105 
106     /**
107      * @constraint B1
108      * @title types of arguments - int[], int
109      */
testVFE4()110     public void testVFE4() {
111         load("dot.junit.opcodes.aget_wide.d.T_aget_wide_7", VerifyError.class);
112     }
113 
114     /**
115      * @constraint B1
116      * @title types of arguments - array, reference
117      */
testVFE5()118     public void testVFE5() {
119         load("dot.junit.opcodes.aget_wide.d.T_aget_wide_8", VerifyError.class);
120     }
121 
122     /**
123      * @constraint A23
124      * @title number of registers
125      */
testVFE6()126     public void testVFE6() {
127         load("dot.junit.opcodes.aget_wide.d.T_aget_wide_9", VerifyError.class);
128     }
129 
130     /**
131      * @constraint A24
132      * @title number of registers
133      */
testVFE7()134     public void testVFE7() {
135         load("dot.junit.opcodes.aget_wide.d.T_aget_wide_11", VerifyError.class);
136     }
137 
138     /**
139      * @constraint B1
140      * @title Type of index argument - float. The verifier checks that ints
141      * and floats are not used interchangeably.
142      */
testVFE8()143     public void testVFE8() {
144         load("dot.junit.opcodes.aget_wide.d.T_aget_wide_10", VerifyError.class);
145     }
146 }
147