• 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.iget_byte;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.iget_byte.d.T_iget_byte_1;
22 import dot.junit.opcodes.iget_byte.d.T_iget_byte_11;
23 import dot.junit.opcodes.iget_byte.d.T_iget_byte_12;
24 import dot.junit.opcodes.iget_byte.d.T_iget_byte_13;
25 import dot.junit.opcodes.iget_byte.d.T_iget_byte_21;
26 import dot.junit.opcodes.iget_byte.d.T_iget_byte_5;
27 import dot.junit.opcodes.iget_byte.d.T_iget_byte_6;
28 import dot.junit.opcodes.iget_byte.d.T_iget_byte_7;
29 import dot.junit.opcodes.iget_byte.d.T_iget_byte_8;
30 import dot.junit.opcodes.iget_byte.d.T_iget_byte_9;
31 
32 public class Test_iget_byte extends DxTestCase {
33 
34     /**
35      * @title get byte from field
36      */
testN1()37     public void testN1() {
38         T_iget_byte_1 t = new T_iget_byte_1();
39         assertEquals(77, t.run());
40     }
41 
42     /**
43      * @title access protected field from subclass
44      */
testN3()45     public void testN3() {
46         //@uses dot.junit.opcodes.iget_byte.d.T_iget_byte_1
47         //@uses dot.junit.opcodes.iget_byte.d.T_iget_byte_11
48         T_iget_byte_11 t = new T_iget_byte_11();
49         assertEquals(77, t.run());
50     }
51 
52     /**
53      * @title expected NullPointerException
54      */
testE2()55     public void testE2() {
56         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_9", NullPointerException.class);
57     }
58 
59     /**
60      * @constraint A11
61      * @title  constant pool index
62      */
testVFE1()63     public void testVFE1() {
64         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_4", VerifyError.class);
65     }
66 
67     /**
68      * @constraint A23
69      * @title number of registers
70      */
testVFE2()71     public void testVFE2() {
72         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_3", VerifyError.class);
73     }
74 
75     /**
76      * @constraint B13
77      * @title read byte from long field - only field with same name but
78      * different type exists
79      */
testVFE3()80     public void testVFE3() {
81         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_13", NoSuchFieldError.class);
82     }
83 
84     /**
85      * @constraint n/a
86      * @title Attempt to read inaccessible field.
87      */
testVFE4()88     public void testVFE4() {
89         //@uses dot.junit.opcodes.iget_byte.TestStubs
90         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_6", IllegalAccessError.class);
91     }
92 
93     /**
94      * @constraint n/a
95      * @title Attempt to read field of undefined class.
96      */
testVFE5()97     public void testVFE5() {
98         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_7", NoClassDefFoundError.class);
99     }
100 
101     /**
102      * @constraint n/a
103      * @title Attempt to read undefined field.
104      */
testVFE6()105     public void testVFE6() {
106         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_8", NoSuchFieldError.class);
107     }
108 
109     /**
110      * @constraint n/a
111      * @title Attempt to read superclass' private field from subclass.
112      */
testVFE7()113     public void testVFE7() {
114         //@uses dot.junit.opcodes.iget_byte.d.T_iget_byte_1
115         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_12", IllegalAccessError.class);
116     }
117 
118     /**
119      * @constraint B1
120      * @title iget_byte shall not work for reference fields
121      */
testVFE8()122     public void testVFE8() {
123         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_14", VerifyError.class);
124     }
125 
126     /**
127      * @constraint B1
128      * @title iget_byte shall not work for short fields
129      */
testVFE9()130     public void testVFE9() {
131         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_15", VerifyError.class);
132     }
133 
134     /**
135      * @constraint B1
136      * @title iget_byte shall not work for int fields
137      */
testVFE10()138     public void testVFE10() {
139         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_16", VerifyError.class);
140     }
141 
142     /**
143      * @constraint B1
144      * @title iget_byte shall not work for char fields
145      */
testVFE11()146     public void testVFE11() {
147         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_17", VerifyError.class);
148     }
149 
150     /**
151      * @constraint B1
152      * @title iget_byte shall not work for boolean fields
153      */
testVFE12()154     public void testVFE12() {
155         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_18", VerifyError.class);
156     }
157 
158     /**
159      * @constraint B1
160      * @title iget_byte shall not work for double fields
161      */
testVFE13()162     public void testVFE13() {
163         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_19", VerifyError.class);
164     }
165 
166     /**
167      * @constraint B1
168      * @title iget_byte shall not work for long fields
169      */
testVFE14()170     public void testVFE14() {
171         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_20", VerifyError.class);
172     }
173 
174     /**
175      * @constraint B12
176      * @title Attempt to read inaccessible protected field.
177      */
testVFE15()178     public void testVFE15() {
179         //@uses dot.junit.opcodes.iget_byte.TestStubs
180         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_21", IllegalAccessError.class);
181     }
182 
183     /**
184      * @constraint A11
185      * @title Attempt to read static  field.
186      */
testVFE16()187     public void testVFE16() {
188         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_5",
189                    IncompatibleClassChangeError.class);
190     }
191 
192     /**
193      * @constraint B6
194      * @title instance fields may only be accessed on already initialized instances.
195      */
testVFE30()196     public void testVFE30() {
197         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_30", VerifyError.class);
198     }
199 
200     /**
201      * @constraint N/A
202      * @title instance fields may only be accessed on reference values.
203      */
testVFE31()204     public void testVFE31() {
205         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_31", VerifyError.class);
206     }
207 
208     /**
209      * @constraint N/A
210      * @title Attempt to read inaccessible protected field on uninitialized reference.
211      */
testVFE35()212     public void testVFE35() {
213         //@uses dot.junit.opcodes.iget_byte.TestStubs
214         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_35", VerifyError.class);
215     }
216 }
217