• 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.and_int_lit16;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_5;
22 import dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_1;
23 import dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_2;
24 import dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_3;
25 import dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_4;
26 import dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_9;
27 
28 public class Test_and_int_lit16 extends DxTestCase {
29     /**
30      * @title Arguments = 15 & 8
31      */
testN1()32     public void testN1() {
33         T_and_int_lit16_1 t = new T_and_int_lit16_1();
34         assertEquals(8, t.run());
35     }
36 
37     /**
38      * @title Arguments = 0xfffffff8 & -8
39      */
testN2()40     public void testN2() {
41         T_and_int_lit16_2 t = new T_and_int_lit16_2();
42         assertEquals(-8, t.run());
43     }
44 
45     /**
46      * @title Arguments = 0xcafe & -1
47      */
testN3()48     public void testN3() {
49         T_and_int_lit16_3 t = new T_and_int_lit16_3();
50         assertEquals(0xcafe, t.run());
51     }
52 
53     /**
54      * @title Types of arguments - int, float. Dalvik doens't distinguish 32-bits types internally,
55      * so this (float & int) makes no sense but shall not crash the VM.
56      */
57 
testN4()58     public void testN4() {
59         T_and_int_lit16_9 t = new T_and_int_lit16_9();
60         try {
61             t.run(11.33f);
62         } catch (Throwable e) {
63         }
64     }
65 
66     /**
67      * @title Arguments = 0 & -1
68      */
testB1()69     public void testB1() {
70         T_and_int_lit16_4 t = new T_and_int_lit16_4();
71         assertEquals(0, t.run());
72     }
73 
74     /**
75      * @title Arguments = Short.MAX_VALUE & Short.MIN_VALUE
76      */
testB2()77     public void testB2() {
78         T_and_int_lit16_5 t = new T_and_int_lit16_5();
79         assertEquals(0, t.run());
80     }
81 
82 
83 
84     /**
85      * @constraint B1
86      * @title  types of arguments - double & int
87      */
testVFE1()88     public void testVFE1() {
89         try {
90             Class.forName("dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_6");
91             fail("expected a verification exception");
92         } catch (Throwable t) {
93             DxUtil.checkVerifyException(t);
94         }
95     }
96 
97     /**
98      * @constraint B1
99      * @title types of arguments - long & int
100      */
testVFE2()101     public void testVFE2() {
102         try {
103             Class.forName("dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_7");
104             fail("expected a verification exception");
105         } catch (Throwable t) {
106             DxUtil.checkVerifyException(t);
107         }
108     }
109 
110     /**
111      * @constraint B1
112      * @title types of arguments - int & reference
113      */
testVFE3()114     public void testVFE3() {
115         try {
116             Class.forName("dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_8");
117             fail("expected a verification exception");
118         } catch (Throwable t) {
119             DxUtil.checkVerifyException(t);
120         }
121     }
122 
123     /**
124      * @constraint A23
125      * @title number of registers
126      */
testVFE5()127     public void testVFE5() {
128         try {
129             Class.forName("dot.junit.opcodes.and_int_lit16.d.T_and_int_lit16_10");
130             fail("expected a verification exception");
131         } catch (Throwable t) {
132             DxUtil.checkVerifyException(t);
133         }
134     }
135 
136 }
137