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