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