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