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