• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 // Simple test for field accesses.
18 
19 public class Main extends TestCase {
main(String[] args)20   public static void main(String[] args) {
21     $opt$testAll();
22   }
23 
$opt$testAll()24   static void $opt$testAll() {
25     AllFields fields = new AllFields();
26 
27     assertEquals(false, fields.iZ);
28     assertEquals(0, fields.iB);
29     assertEquals(0, fields.iC);
30     assertEquals(0, fields.iI);
31     assertEquals(0, fields.iJ);
32     assertEquals(0, fields.iS);
33     assertEquals(0.0f, fields.iF);
34     assertEquals(0.0, fields.iD);
35     assertNull(fields.iObject);
36 
37     long longValue = -1122198787987987987L;
38     fields.iZ = true;
39     fields.iB = -2;
40     fields.iC = 'c';
41     fields.iI = 42;
42     fields.iJ = longValue;
43     fields.iS = 68;
44     fields.iObject = fields;
45     fields.iF = 2.3f;
46     fields.iD = 5.3;
47 
48     assertEquals(true, fields.iZ);
49     assertEquals(-2, fields.iB);
50     assertEquals('c', fields.iC);
51     assertEquals(42, fields.iI);
52     assertEquals(longValue, fields.iJ);
53     assertEquals(68, fields.iS);
54     assertEquals(fields, fields.iObject);
55     assertEquals(2.3f, fields.iF);
56     assertEquals(5.3, fields.iD);
57   }
58 
59   static class AllFields {
60     boolean iZ;
61     byte iB;
62     char iC;
63     double iD;
64     float iF;
65     int iI;
66     long iJ;
67     short iS;
68     Object iObject;
69   }
70 }
71