• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package dot.junit.opcodes.shl_int;
2 
3 import dot.junit.DxTestCase;
4 import dot.junit.DxUtil;
5 import dot.junit.opcodes.shl_int.d.T_shl_int_1;
6 import dot.junit.opcodes.shl_int.d.T_shl_int_6;
7 
8 public class Test_shl_int extends DxTestCase {
9 
10     /**
11      * @title 15 << 1
12      */
testN1()13     public void testN1() {
14         T_shl_int_1 t = new T_shl_int_1();
15         assertEquals(30, t.run(15, 1));
16     }
17 
18     /**
19      * @title 33 << 2
20      */
testN2()21     public void testN2() {
22         T_shl_int_1 t = new T_shl_int_1();
23         assertEquals(132, t.run(33, 2));
24     }
25 
26     /**
27      * @title -15 << 1
28      */
testN3()29     public void testN3() {
30         T_shl_int_1 t = new T_shl_int_1();
31         assertEquals(-30, t.run(-15, 1));
32     }
33 
34     /**
35      * @title Arguments = 1 & -1
36      */
testN4()37     public void testN4() {
38         T_shl_int_1 t = new T_shl_int_1();
39         assertEquals(0x80000000, t.run(1, -1));
40     }
41 
42     /**
43      * @title Verify that shift distance is actually in range 0 to 32.
44      */
testN5()45     public void testN5() {
46         T_shl_int_1 t = new T_shl_int_1();
47         assertEquals(66, t.run(33, 33));
48     }
49 
50     /**
51      * @title Types of arguments - float, float. Dalvik doens't distinguish 32-bits types internally,
52      * so this operation float parameters makes no sense but shall not crash the VM.
53      */
testN6()54     public void testN6() {
55         T_shl_int_6 t = new T_shl_int_6();
56         try {
57             t.run(3.14f, 1.2f);
58         } catch (Throwable e) {
59         }
60     }
61 
62 
63     /**
64      * @title Arguments = 0 & -1
65      */
testB1()66     public void testB1() {
67         T_shl_int_1 t = new T_shl_int_1();
68         assertEquals(0, t.run(0, -1));
69     }
70 
71     /**
72      * @title Arguments = Integer.MAX_VALUE & 1
73      */
testB2()74     public void testB2() {
75         T_shl_int_1 t = new T_shl_int_1();
76         assertEquals(0xfffffffe, t.run(Integer.MAX_VALUE, 1));
77     }
78 
79     /**
80      * @title Arguments = Integer.MIN_VALUE & 1
81      */
testB3()82     public void testB3() {
83         T_shl_int_1 t = new T_shl_int_1();
84         assertEquals(0, t.run(Integer.MIN_VALUE, 1));
85     }
86 
87     /**
88      * @title Arguments = 1 & 0
89      */
testB4()90     public void testB4() {
91         T_shl_int_1 t = new T_shl_int_1();
92         assertEquals(1, t.run(1, 0));
93     }
94 
95     /**
96      * @constraint A23
97      * @title number of registers
98      */
testVFE1()99     public void testVFE1() {
100         try {
101             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_2");
102             fail("expected a verification exception");
103         } catch (Throwable t) {
104             DxUtil.checkVerifyException(t);
105         }
106     }
107 
108 
109 
110     /**
111      * @constraint B1
112      * @title types of arguments - double & int
113      */
testVFE2()114     public void testVFE2() {
115         try {
116             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_3");
117             fail("expected a verification exception");
118         } catch (Throwable t) {
119             DxUtil.checkVerifyException(t);
120         }
121     }
122 
123     /**
124      * @constraint B1
125      * @title types of arguments - long & int
126      */
testVFE3()127     public void testVFE3() {
128         try {
129             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_4");
130             fail("expected a verification exception");
131         } catch (Throwable t) {
132             DxUtil.checkVerifyException(t);
133         }
134     }
135 
136     /**
137      * @constraint B1
138      * @title types of arguments - reference & int
139      */
testVFE4()140     public void testVFE4() {
141         try {
142             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_5");
143             fail("expected a verification exception");
144         } catch (Throwable t) {
145             DxUtil.checkVerifyException(t);
146         }
147     }
148 
149 }
150