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