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.neg_double; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.neg_double.d.T_neg_double_1; 22 import dot.junit.opcodes.neg_double.d.T_neg_double_4; 23 24 public class Test_neg_double extends DxTestCase { 25 26 /** 27 * @title Argument = 1 28 */ 29 public void testN1() { 30 T_neg_double_1 t = new T_neg_double_1(); 31 assertEquals(-1d, t.run(1d)); 32 } 33 34 /** 35 * @title Argument = -1 36 */ 37 public void testN2() { 38 T_neg_double_1 t = new T_neg_double_1(); 39 assertEquals(1d, t.run(-1d)); 40 } 41 42 /** 43 * @title Argument = +0 44 */ 45 public void testN3() { 46 T_neg_double_1 t = new T_neg_double_1(); 47 assertEquals(-0d, t.run(+0d)); 48 } 49 50 /** 51 * @title Argument = -2.7 52 */ 53 public void testN4() { 54 T_neg_double_1 t = new T_neg_double_1(); 55 assertEquals(2.7d, t.run(-2.7d)); 56 } 57 58 /** 59 * @title Types of arguments - long, double. Dalvik doens't distinguish 64-bits types internally, 60 * so this operation of long and double makes no sense but shall not crash the VM. 61 */ 62 63 public void testN5() { 64 T_neg_double_4 t = new T_neg_double_4(); 65 try { 66 t.run(500000l); 67 } catch (Throwable e) { 68 } 69 } 70 71 72 /** 73 * @title Argument = Double.NaN 74 */ 75 public void testB1() { 76 T_neg_double_1 t = new T_neg_double_1(); 77 assertEquals(Double.NaN, t.run(Double.NaN)); 78 } 79 80 /** 81 * @title Argument = Double.NEGATIVE_INFINITY 82 */ 83 public void testB2() { 84 T_neg_double_1 t = new T_neg_double_1(); 85 assertEquals(Double.POSITIVE_INFINITY, t.run(Double.NEGATIVE_INFINITY)); 86 } 87 88 /** 89 * @title Argument = Double.POSITIVE_INFINITY 90 */ 91 public void testB3() { 92 T_neg_double_1 t = new T_neg_double_1(); 93 assertEquals(Double.NEGATIVE_INFINITY, t.run(Double.POSITIVE_INFINITY)); 94 } 95 96 /** 97 * @title Argument = Double.MAX_VALUE 98 */ 99 public void testB4() { 100 T_neg_double_1 t = new T_neg_double_1(); 101 assertEquals(-1.7976931348623157E308d, t.run(Double.MAX_VALUE)); 102 } 103 104 /** 105 * @title Argument = Double.MIN_VALUE 106 */ 107 public void testB5() { 108 T_neg_double_1 t = new T_neg_double_1(); 109 assertEquals(-4.9E-324d, t.run(Double.MIN_VALUE)); 110 } 111 112 /** 113 * @constraint A24 114 * @title number of registers 115 */ 116 public void testVFE1() { 117 try { 118 Class.forName("dot.junit.opcodes.neg_double.d.T_neg_double_2"); 119 fail("expected a verification exception"); 120 } catch (Throwable t) { 121 DxUtil.checkVerifyException(t); 122 } 123 } 124 125 126 127 /** 128 * 129 * @constraint B1 130 * @title type of argument - float 131 */ 132 public void testVFE2() { 133 try { 134 Class.forName("dot.junit.opcodes.neg_double.d.T_neg_double_3"); 135 fail("expected a verification exception"); 136 } catch (Throwable t) { 137 DxUtil.checkVerifyException(t); 138 } 139 } 140 141 /** 142 * 143 * @constraint B1 144 * @title type of argument - int 145 */ 146 public void testVFE3() { 147 try { 148 Class.forName("dot.junit.opcodes.neg_double.d.T_neg_double_5"); 149 fail("expected a verification exception"); 150 } catch (Throwable t) { 151 DxUtil.checkVerifyException(t); 152 } 153 } 154 155 /** 156 * 157 * @constraint B1 158 * @title type of argument - reference 159 */ 160 public void testVFE4() { 161 try { 162 Class.forName("dot.junit.opcodes.neg_double.d.T_neg_double_6"); 163 fail("expected a verification exception"); 164 } catch (Throwable t) { 165 DxUtil.checkVerifyException(t); 166 } 167 } 168 169 } 170