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_float; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.rem_float.d.T_rem_float_1; 22 import dot.junit.opcodes.rem_float.d.T_rem_float_6; 23 24 public class Test_rem_float extends DxTestCase { 25 26 /** 27 * @title Arguments = 2.7f, 3.14f 28 */ 29 public void testN1() { 30 T_rem_float_1 t = new T_rem_float_1(); 31 assertEquals(2.7f, t.run(2.7f, 3.14f)); 32 } 33 34 /** 35 * @title Dividend = 0 36 */ 37 public void testN2() { 38 T_rem_float_1 t = new T_rem_float_1(); 39 assertEquals(0f, t.run(0, 3.14f)); 40 } 41 42 /** 43 * @title Dividend is negative 44 */ 45 public void testN3() { 46 T_rem_float_1 t = new T_rem_float_1(); 47 assertEquals(-0.44000006f, t.run(-3.14f, 2.7f)); 48 } 49 50 /** 51 * @title Arguments = Float.MAX_VALUE, Float.NaN 52 */ 53 public void testB1() { 54 T_rem_float_1 t = new T_rem_float_1(); 55 assertEquals(Float.NaN, t.run(Float.MAX_VALUE, Float.NaN)); 56 } 57 58 /** 59 * @title Arguments = Float.POSITIVE_INFINITY, 60 * Float.NEGATIVE_INFINITY 61 */ 62 public void testB2() { 63 T_rem_float_1 t = new T_rem_float_1(); 64 assertEquals(Float.NaN, t.run(Float.POSITIVE_INFINITY, 65 Float.NEGATIVE_INFINITY)); 66 } 67 68 /** 69 * @title Arguments = Float.POSITIVE_INFINITY, -2.7f 70 */ 71 public void testB3() { 72 T_rem_float_1 t = new T_rem_float_1(); 73 assertEquals(Float.NaN, t.run(Float.POSITIVE_INFINITY, -2.7f)); 74 } 75 76 /** 77 * @title Arguments = -2.7f, Float.NEGATIVE_INFINITY 78 */ 79 public void testB4() { 80 T_rem_float_1 t = new T_rem_float_1(); 81 assertEquals(-2.7f, t.run(-2.7f, Float.NEGATIVE_INFINITY)); 82 } 83 84 /** 85 * @title Arguments = 0, 0 86 */ 87 public void testB5() { 88 T_rem_float_1 t = new T_rem_float_1(); 89 assertEquals(Float.NaN, t.run(0, 0)); 90 } 91 92 /** 93 * @title Arguments = 0, -2.7 94 */ 95 public void testB6() { 96 T_rem_float_1 t = new T_rem_float_1(); 97 assertEquals(0f, t.run(0, -2.7f)); 98 } 99 100 /** 101 * @title Arguments = -2.7, 0 102 */ 103 public void testB7() { 104 T_rem_float_1 t = new T_rem_float_1(); 105 assertEquals(Float.NaN, t.run(-2.7f, 0)); 106 } 107 108 /** 109 * @title Arguments = 1, Float.MAX_VALUE 110 */ 111 public void testB8() { 112 T_rem_float_1 t = new T_rem_float_1(); 113 assertEquals(0f, t.run(1, Float.MIN_VALUE)); 114 } 115 116 /** 117 * @title Arguments = Float.MAX_VALUE, -1E-9f 118 */ 119 public void testB9() { 120 T_rem_float_1 t = new T_rem_float_1(); 121 assertEquals(7.2584893E-10f, t.run(Float.MAX_VALUE, -1E-9f)); 122 } 123 124 /** 125 * @constraint A23 126 * @title number of registers 127 */ 128 public void testVFE1() { 129 try { 130 Class.forName("dot.junit.opcodes.rem_float.d.T_rem_float_2"); 131 fail("expected a verification exception"); 132 } catch (Throwable t) { 133 DxUtil.checkVerifyException(t); 134 } 135 } 136 137 138 139 /** 140 * @constraint B1 141 * @title types of arguments - float, double 142 */ 143 public void testVFE2() { 144 try { 145 Class.forName("dot.junit.opcodes.rem_float.d.T_rem_float_3"); 146 fail("expected a verification exception"); 147 } catch (Throwable t) { 148 DxUtil.checkVerifyException(t); 149 } 150 } 151 152 /** 153 * @constraint B1 154 * @title types of arguments - long, float 155 */ 156 public void testVFE3() { 157 try { 158 Class.forName("dot.junit.opcodes.rem_float.d.T_rem_float_4"); 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 - reference, float 168 */ 169 public void testVFE4() { 170 try { 171 Class.forName("dot.junit.opcodes.rem_float.d.T_rem_float_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 - float, int. The verifier checks that ints 181 * and floats are not used interchangeably. 182 */ 183 public void testVFE5() { 184 try { 185 Class.forName("dot.junit.opcodes.rem_float.d.T_rem_float_6"); 186 fail("expected a verification exception"); 187 } catch (Throwable t) { 188 DxUtil.checkVerifyException(t); 189 } 190 } 191 } 192