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