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