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