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