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