• 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.iput_char;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.iput_char.d.T_iput_char_1;
22 import dot.junit.opcodes.iput_char.d.T_iput_char_10;
23 import dot.junit.opcodes.iput_char.d.T_iput_char_11;
24 import dot.junit.opcodes.iput_char.d.T_iput_char_12;
25 import dot.junit.opcodes.iput_char.d.T_iput_char_13;
26 import dot.junit.opcodes.iput_char.d.T_iput_char_14;
27 import dot.junit.opcodes.iput_char.d.T_iput_char_15;
28 import dot.junit.opcodes.iput_char.d.T_iput_char_17;
29 import dot.junit.opcodes.iput_char.d.T_iput_char_7;
30 import dot.junit.opcodes.iput_char.d.T_iput_char_8;
31 import dot.junit.opcodes.iput_char.d.T_iput_char_9;
32 
33 public class Test_iput_char extends DxTestCase {
34     /**
35      * @title put char into field
36      */
testN1()37     public void testN1() {
38         T_iput_char_1 t = new T_iput_char_1();
39         assertEquals(0, t.st_i1);
40         t.run();
41         assertEquals(77, t.st_i1);
42     }
43 
44 
45     /**
46      * @title modification of final field
47      */
testN2()48     public void testN2() {
49         T_iput_char_12 t = new T_iput_char_12();
50         assertEquals(0, t.st_i1);
51         t.run();
52         assertEquals(77, t.st_i1);
53     }
54 
55     /**
56      * @title modification of protected field from subclass
57      */
testN4()58     public void testN4() {
59         //@uses dot.junit.opcodes.iput_char.d.T_iput_char_1
60         //@uses dot.junit.opcodes.iput_char.d.T_iput_char_14
61         T_iput_char_14 t = new T_iput_char_14();
62         assertEquals(0, t.getProtectedField());
63         t.run();
64         assertEquals(77, t.getProtectedField());
65     }
66 
67     /**
68      * @title expected NullPointerException
69      */
testE2()70     public void testE2() {
71         loadAndRun("dot.junit.opcodes.iput_char.d.T_iput_char_13", NullPointerException.class);
72     }
73 
74 
75     /**
76      * @constraint A11
77      * @title constant pool index
78      */
testVFE1()79     public void testVFE1() {
80         load("dot.junit.opcodes.iput_char.d.T_iput_char_3", VerifyError.class);
81     }
82 
83     /**
84      *
85      * @constraint A23
86      * @title number of registers
87      */
testVFE2()88     public void testVFE2() {
89         load("dot.junit.opcodes.iput_char.d.T_iput_char_4", VerifyError.class);
90     }
91 
92 
93     /**
94      *
95      * @constraint B14
96      * @title put char into long field - only field with same name but
97      * different type exists
98      */
testVFE5()99     public void testVFE5() {
100         loadAndRun("dot.junit.opcodes.iput_char.d.T_iput_char_17", NoSuchFieldError.class);
101     }
102 
103     /**
104      *
105      * @constraint B14
106      * @title type of field doesn't match opcode - attempt to modify double
107      * field with single-width register
108      */
testVFE7()109     public void testVFE7() {
110         load("dot.junit.opcodes.iput_char.d.T_iput_char_18", VerifyError.class);
111     }
112 
113     /**
114      *
115      * @constraint A11
116      * @title Attempt to set static field.
117      */
testVFE8()118     public void testVFE8() {
119         loadAndRun("dot.junit.opcodes.iput_char.d.T_iput_char_7",
120                    IncompatibleClassChangeError.class);
121     }
122 
123     /**
124      * @constraint B12
125      * @title Attempt to modify inaccessible protected field.
126      */
testVFE9()127     public void testVFE9() {
128         //@uses dot.junit.opcodes.iput_char.TestStubs
129         loadAndRun("dot.junit.opcodes.iput_char.d.T_iput_char_8", IllegalAccessError.class);
130     }
131 
132     /**
133      * @constraint n/a
134      * @title Attempt to modify field of undefined class.
135      */
testVFE10()136     public void testVFE10() {
137         loadAndRun("dot.junit.opcodes.iput_char.d.T_iput_char_9", NoClassDefFoundError.class);
138     }
139 
140 
141     /**
142      * @constraint n/a
143      * @title Attempt to modify undefined field.
144      */
testVFE11()145     public void testVFE11() {
146         loadAndRun("dot.junit.opcodes.iput_char.d.T_iput_char_10", NoSuchFieldError.class);
147     }
148 
149 
150 
151     /**
152      * @constraint n/a
153      * @title Attempt to modify superclass' private field from subclass.
154      */
testVFE12()155     public void testVFE12() {
156         //@uses dot.junit.opcodes.iput_char.d.T_iput_char_1
157         loadAndRun("dot.junit.opcodes.iput_char.d.T_iput_char_15", IllegalAccessError.class);
158     }
159 
160 
161     /**
162      * @constraint B1
163      * @title iput-char shall not work for wide numbers
164      */
testVFE13()165     public void testVFE13() {
166         load("dot.junit.opcodes.iput_char.d.T_iput_char_2", VerifyError.class);
167     }
168 
169     /**
170      *
171      * @constraint B1
172      * @title iput-char shall not work for reference fields
173      */
testVFE14()174     public void testVFE14() {
175         load("dot.junit.opcodes.iput_char.d.T_iput_char_20", VerifyError.class);
176     }
177 
178     /**
179      *
180      * @constraint B1
181      * @title iput-char shall not work for short fields
182      */
testVFE15()183     public void testVFE15() {
184         load("dot.junit.opcodes.iput_char.d.T_iput_char_21", VerifyError.class);
185     }
186 
187     /**
188      *
189      * @constraint B1
190      * @title iput-char shall not work for int fields
191      */
testVFE16()192     public void testVFE16() {
193         load("dot.junit.opcodes.iput_char.d.T_iput_char_22", VerifyError.class);
194     }
195 
196     /**
197      *
198      * @constraint B1
199      * @title iput-char shall not work for byte fields
200      */
testVFE17()201     public void testVFE17() {
202         load("dot.junit.opcodes.iput_char.d.T_iput_char_23", VerifyError.class);
203     }
204 
205     /**
206      *
207      * @constraint B1
208      * @title iput-char shall not work for boolean fields
209      */
testVFE18()210     public void testVFE18() {
211         load("dot.junit.opcodes.iput_char.d.T_iput_char_24", VerifyError.class);
212     }
213 
214 
215     /**
216      * @constraint B6
217      * @title instance fields may only be accessed on already initialized instances.
218      */
testVFE30()219     public void testVFE30() {
220         load("dot.junit.opcodes.iput_char.d.T_iput_char_30", VerifyError.class);
221     }
222 
223     /**
224      * @constraint N/A
225      * @title instance fields may only be accessed on reference registers.
226      */
testVFE31()227     public void testVFE31() {
228         load("dot.junit.opcodes.iput_char.d.T_iput_char_31", VerifyError.class);
229     }
230 
231     /**
232      * @constraint n/a
233      * @title Modification of final field in other class
234      */
testVFE19()235     public void testVFE19() {
236         //@uses dot.junit.opcodes.iput_char.TestStubs
237         loadAndRun("dot.junit.opcodes.iput_char.d.T_iput_char_11", IllegalAccessError.class);
238     }
239 
240 }
241 
242