• 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.sub_float_2addr;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.sub_float_2addr.d.T_sub_float_2addr_1;
22 import dot.junit.opcodes.sub_float_2addr.d.T_sub_float_2addr_5;
23 
24 public class Test_sub_float_2addr extends DxTestCase {
25     /**
26      * @title Arguments = 2.7f, 3.14f
27      */
testN1()28     public void testN1() {
29         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
30         assertEquals(-0.44000006f, t.run(2.7f, 3.14f));
31     }
32 
33     /**
34      * @title Arguments = 0, -3.14f
35      */
testN2()36     public void testN2() {
37         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
38         assertEquals(3.14f, t.run(0, -3.14f));
39     }
40 
41     /**
42      * @title
43      */
testN3()44     public void testN3() {
45         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
46         assertEquals(-0.44000006f, t.run(-3.14f, -2.7f));
47     }
48 
49     /**
50      * @title Types of arguments - int, float. Dalvik doens't distinguish 32-bits types internally,
51      * so this subtraction of float and int makes no sense but shall not crash the VM.
52      */
testN4()53     public void testN4() {
54         T_sub_float_2addr_5 t = new T_sub_float_2addr_5();
55         try {
56             t.run(1, 3.14f);
57         } catch (Throwable e) {
58         }
59     }
60 
61     /**
62      * @title Arguments = Float.MAX_VALUE, Float.NaN
63      */
testB1()64     public void testB1() {
65         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
66         assertEquals(Float.NaN, t.run(Float.MAX_VALUE, Float.NaN));
67     }
68 
69     /**
70      * @title Arguments = Float.POSITIVE_INFINITY,
71      * Float.NEGATIVE_INFINITY
72      */
testB2()73     public void testB2() {
74         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
75         assertEquals(Float.POSITIVE_INFINITY, t.run(Float.POSITIVE_INFINITY,
76                 Float.NEGATIVE_INFINITY));
77     }
78 
79     /**
80      * @title Arguments = Float.POSITIVE_INFINITY,
81      * Float.POSITIVE_INFINITY
82      */
testB3()83     public void testB3() {
84         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
85         assertEquals(Float.NaN, t.run(Float.POSITIVE_INFINITY,
86                 Float.POSITIVE_INFINITY));
87     }
88 
89     /**
90      * @title Arguments = Float.POSITIVE_INFINITY, -2.7f
91      */
testB4()92     public void testB4() {
93         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
94         assertEquals(Float.POSITIVE_INFINITY, t.run(Float.POSITIVE_INFINITY,
95                 -2.7f));
96     }
97 
98     /**
99      * @title Arguments = +0, -0f
100      */
testB5()101     public void testB5() {
102         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
103         assertEquals(+0f, t.run(+0f, -0f));
104     }
105 
106     /**
107      * @title Arguments = -0f, -0f
108      */
testB6()109     public void testB6() {
110         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
111         assertEquals(0f, t.run(-0f, -0f));
112     }
113 
114     /**
115      * @title Arguments = +0f, +0f
116      */
testB7()117     public void testB7() {
118         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
119         assertEquals(+0f, t.run(+0f, +0f));
120     }
121 
122     /**
123      * @title Arguments = 2.7f, 2.7f
124      */
testB8()125     public void testB8() {
126         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
127         assertEquals(0f, t.run(2.7f, 2.7f));
128     }
129 
130     /**
131      * @title Arguments = Float.MAX_VALUE, Float.MAX_VALUE
132      */
testB9()133     public void testB9() {
134         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
135         assertEquals(0f, t.run(Float.MAX_VALUE, Float.MAX_VALUE));
136     }
137 
138     /**
139      * @title Arguments = Float.MIN_VALUE, -1.4E-45f
140      */
testB10()141     public void testB10() {
142         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
143         assertEquals(0f, t.run(Float.MIN_VALUE, 1.4E-45f));
144     }
145 
146     /**
147      * @title Arguments = Float.MAX_VALUE, -Float.MAX_VALUE
148      */
testB11()149     public void testB11() {
150         T_sub_float_2addr_1 t = new T_sub_float_2addr_1();
151         assertEquals(Float.POSITIVE_INFINITY, t.run(Float.MAX_VALUE,
152                 -3.402823E+38F));
153     }
154 
155 
156 
157 
158     /**
159      * @constraint B1
160      * @title types of arguments - float, double
161      */
testVFE2()162     public void testVFE2() {
163         try {
164             Class.forName("dot.junit.opcodes.sub_float_2addr.d.T_sub_float_2addr_2");
165             fail("expected a verification exception");
166         } catch (Throwable t) {
167             DxUtil.checkVerifyException(t);
168         }
169     }
170 
171     /**
172      * @constraint B1
173      * @title types of arguments - long, float
174      */
testVFE3()175     public void testVFE3() {
176         try {
177             Class.forName("dot.junit.opcodes.sub_float_2addr.d.T_sub_float_2addr_3");
178             fail("expected a verification exception");
179         } catch (Throwable t) {
180             DxUtil.checkVerifyException(t);
181         }
182     }
183 
184     /**
185      * @constraint B1
186      * @title types of arguments - reference, float
187      */
testVFE4()188     public void testVFE4() {
189         try {
190             Class.forName("dot.junit.opcodes.sub_float_2addr.d.T_sub_float_2addr_4");
191             fail("expected a verification exception");
192         } catch (Throwable t) {
193             DxUtil.checkVerifyException(t);
194         }
195     }
196 
197     /**
198      * @constraint A23
199      * @title number of registers
200      */
testVFE5()201     public void testVFE5() {
202         try {
203             Class.forName("dot.junit.opcodes.sub_float_2addr.d.T_sub_float_2addr_6");
204             fail("expected a verification exception");
205         } catch (Throwable t) {
206             DxUtil.checkVerifyException(t);
207         }
208     }
209 
210 }
211