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 dxc.junit.opcodes.fadd; 18 19 import dxc.junit.DxTestCase; 20 import dxc.junit.DxUtil; 21 import dxc.junit.opcodes.fadd.jm.T_fadd_1; 22 23 public class Test_fadd extends DxTestCase { 24 25 /** 26 * @title Arguments = 2.7f, 3.14f 27 */ 28 public void testN1() { 29 T_fadd_1 t = new T_fadd_1(); 30 assertEquals(5.84f, t.run(2.7f, 3.14f)); 31 } 32 33 /** 34 * @title Arguments = 0, -3.14f 35 */ 36 public void testN2() { 37 T_fadd_1 t = new T_fadd_1(); 38 assertEquals(-3.14f, t.run(0, -3.14f)); 39 } 40 41 /** 42 * @title Arguments = -3.14f, -2.7f 43 */ 44 public void testN3() { 45 T_fadd_1 t = new T_fadd_1(); 46 assertEquals(-5.84f, t.run(-3.14f, -2.7f)); 47 } 48 49 50 /** 51 * @title Arguments = Float.MAX_VALUE, Float.NaN 52 */ 53 public void testB1() { 54 T_fadd_1 t = new T_fadd_1(); 55 assertEquals(Float.POSITIVE_INFINITY, t.run(3.3028235E38f, 0.11E38f)); 56 } 57 58 /** 59 * @title Arguments = Float.POSITIVE_INFINITY, 60 * Float.NEGATIVE_INFINITY 61 */ 62 public void testB2() { 63 T_fadd_1 t = new T_fadd_1(); 64 assertTrue(Float.isNaN(t.run(Float.POSITIVE_INFINITY, 65 Float.NEGATIVE_INFINITY))); 66 } 67 68 /** 69 * @title Arguments = Float.POSITIVE_INFINITY, 70 * Float.POSITIVE_INFINITY 71 */ 72 public void testB3() { 73 T_fadd_1 t = new T_fadd_1(); 74 assertEquals(Float.POSITIVE_INFINITY, t.run(Float.POSITIVE_INFINITY, 75 Float.POSITIVE_INFINITY)); 76 } 77 78 /** 79 * @title Arguments = Float.POSITIVE_INFINITY, -2.7f 80 */ 81 public void testB4() { 82 T_fadd_1 t = new T_fadd_1(); 83 assertEquals(Float.POSITIVE_INFINITY, t.run(Float.POSITIVE_INFINITY, 84 -2.7f)); 85 } 86 87 /** 88 * @title Arguments = +0, -0f 89 */ 90 public void testB5() { 91 T_fadd_1 t = new T_fadd_1(); 92 assertEquals(+0f, t.run(+0f, -0f)); 93 } 94 95 /** 96 * @title Arguments = -0f, -0f 97 */ 98 public void testB6() { 99 T_fadd_1 t = new T_fadd_1(); 100 assertEquals(-0f, t.run(-0f, -0f)); 101 } 102 103 /** 104 * @title Arguments = -2.7f, 2.7f 105 */ 106 public void testB7() { 107 T_fadd_1 t = new T_fadd_1(); 108 assertEquals(+0f, t.run(-2.7f, 2.7f)); 109 } 110 111 /** 112 * @title Arguments = Float.MAX_VALUE, Float.MAX_VALUE 113 */ 114 public void testB8() { 115 T_fadd_1 t = new T_fadd_1(); 116 assertEquals(Float.POSITIVE_INFINITY, t.run(Float.MAX_VALUE, 117 Float.MAX_VALUE)); 118 } 119 120 /** 121 * @title Arguments = Float.MIN_VALUE, -1.4E-45f 122 */ 123 public void testB9() { 124 T_fadd_1 t = new T_fadd_1(); 125 assertEquals(0f, t.run(Float.MIN_VALUE, -1.4E-45f)); 126 } 127 128 /** 129 * @constraint 4.8.2.1 130 * @title number of arguments 131 */ 132 public void testVFE1() { 133 try { 134 Class.forName("dxc.junit.opcodes.fadd.jm.T_fadd_2"); 135 fail("expected a verification exception"); 136 } catch (Throwable t) { 137 DxUtil.checkVerifyException(t); 138 } 139 } 140 141 /** 142 * @constraint 4.8.2.1 143 * @title types of arguments - float, double 144 */ 145 public void testVFE2() { 146 try { 147 Class.forName("dxc.junit.opcodes.fadd.jm.T_fadd_3"); 148 fail("expected a verification exception"); 149 } catch (Throwable t) { 150 DxUtil.checkVerifyException(t); 151 } 152 } 153 154 /** 155 * @constraint 4.8.2.1 156 * @title types of arguments - long, float 157 */ 158 public void testVFE3() { 159 try { 160 Class.forName("dxc.junit.opcodes.fadd.jm.T_fadd_4"); 161 fail("expected a verification exception"); 162 } catch (Throwable t) { 163 DxUtil.checkVerifyException(t); 164 } 165 } 166 167 /** 168 * @constraint 4.8.2.1 169 * @title types of arguments - float, reference 170 */ 171 public void testVFE4() { 172 try { 173 Class.forName("dxc.junit.opcodes.fadd.jm.T_fadd_5"); 174 fail("expected a verification exception"); 175 } catch (Throwable t) { 176 DxUtil.checkVerifyException(t); 177 } 178 } 179 180 } 181