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