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.add_double;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.add_double.d.T_add_double_1;
22 import dot.junit.opcodes.add_double.d.T_add_double_3;
23 
24 public class Test_add_double extends DxTestCase {
25 
26     /**
27      * @title Arguments = 2.7d, 3.14d
28      */
testN1()29     public void testN1() {
30         T_add_double_1 t = new T_add_double_1();
31         assertEquals(5.84d, t.run(2.7d, 3.14d));
32     }
33 
34     /**
35      * @title Arguments = 0, -3.14d
36      */
testN2()37     public void testN2() {
38         T_add_double_1 t = new T_add_double_1();
39         assertEquals(-3.14d, t.run(0, -3.14d));
40     }
41 
42     /**
43      * @title Arguments = -3.14d, -2.7d
44      */
testN3()45     public void testN3() {
46         //@uses dot.junit.opcodes.add_double.d.T_add_double_2
47         //@uses dot.junit.opcodes.add_double.d.T_add_double_3
48         T_add_double_1 t = new T_add_double_1();
49         assertEquals(-5.84d, t.run(-3.14d, -2.7d));
50     }
51 
52     /**
53      * @title Arguments = Double.MAX_VALUE, Double.NaN
54      */
testB1()55     public void testB1() {
56         T_add_double_1 t = new T_add_double_1();
57         assertEquals(Double.NaN, t.run(Double.MAX_VALUE, Double.NaN));
58     }
59 
60     /**
61      * @title Arguments = Double.POSITIVE_INFINITY,
62      * Double.NEGATIVE_INFINITY
63      */
testB2()64     public void testB2() {
65         T_add_double_1 t = new T_add_double_1();
66         assertEquals(Double.NaN, t.run(Double.POSITIVE_INFINITY,
67                 Double.NEGATIVE_INFINITY));
68     }
69 
70     /**
71      * @title Arguments = Double.POSITIVE_INFINITY,
72      * Double.POSITIVE_INFINITY
73      */
testB3()74     public void testB3() {
75         T_add_double_1 t = new T_add_double_1();
76         assertEquals(Double.POSITIVE_INFINITY, t.run(Double.POSITIVE_INFINITY,
77                 Double.POSITIVE_INFINITY));
78     }
79 
80     /**
81      * @title Arguments = Double.POSITIVE_INFINITY, -2.7d
82      */
testB4()83     public void testB4() {
84         T_add_double_1 t = new T_add_double_1();
85         assertEquals(Double.POSITIVE_INFINITY, t.run(Double.POSITIVE_INFINITY,
86                 -2.7d));
87     }
88 
89     /**
90      * @title Arguments = +0, -0
91      */
testB5()92     public void testB5() {
93         T_add_double_1 t = new T_add_double_1();
94         assertEquals(+0d, t.run(+0d, -0d));
95     }
96 
97     /**
98      * @title Arguments = -0d, -0d
99      */
testB6()100     public void testB6() {
101         T_add_double_1 t = new T_add_double_1();
102         assertEquals(-0d, t.run(-0d, -0d));
103     }
104 
105     /**
106      * @title Arguments = -2.7d, 2.7d
107      */
testB7()108     public void testB7() {
109         T_add_double_1 t = new T_add_double_1();
110         assertEquals(+0d, t.run(-2.7d, 2.7d));
111     }
112 
113     /**
114      * @title Arguments = Double.MAX_VALUE, Double.MAX_VALUE
115      */
testB8()116     public void testB8() {
117         T_add_double_1 t = new T_add_double_1();
118         assertEquals(Double.POSITIVE_INFINITY, t.run(Double.MAX_VALUE,
119                 Double.MAX_VALUE));
120     }
121 
122     /**
123      * @title Arguments = Double.MIN_VALUE, -4.9E-324
124      */
testB9()125     public void testB9() {
126         T_add_double_1 t = new T_add_double_1();
127         assertEquals(0d, t.run(Double.MIN_VALUE, -4.9E-324));
128     }
129 
130     /**
131      * @constraint B1
132      * @title  types of arguments - float, double
133      */
testVFE1()134     public void testVFE1() {
135         load("dot.junit.opcodes.add_double.d.T_add_double_2", VerifyError.class);
136     }
137 
138 
139     /**
140      * @constraint B1
141      * @title  types of arguments - double, reference
142      */
testVFE2()143     public void testVFE2() {
144         load("dot.junit.opcodes.add_double.d.T_add_double_4", VerifyError.class);
145     }
146 
147     /**
148      * @constraint A24
149      * @title  number of registers
150      */
testVFE3()151     public void testVFE3() {
152         load("dot.junit.opcodes.add_double.d.T_add_double_5", VerifyError.class);
153     }
154 
155     /**
156      * @constraint B1
157      * @title  types of arguments - int, int
158      */
testVFE4()159     public void testVFE4() {
160         load("dot.junit.opcodes.add_double.d.T_add_double_6", VerifyError.class);
161     }
162 
163     /**
164      * @constraint B1
165      * @title Types of arguments - long, double. The verifier checks that longs
166      * and doubles are not used interchangeably.
167      */
testVFE5()168     public void testVFE5() {
169         load("dot.junit.opcodes.add_double.d.T_add_double_3", VerifyError.class);
170     }
171 }
172