Home | History | Annotate | Download | only in fdiv
      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.fdiv;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.fdiv.jm.T_fdiv_1;
     22 
     23 public class Test_fdiv extends DxTestCase {
     24 
     25     /**
     26      * @title Arguments = 2.7f, 3.14f
     27      */
     28     public void testN1() {
     29         T_fdiv_1 t = new T_fdiv_1();
     30         assertEquals(0.8598726f, t.run(2.7f, 3.14f));
     31     }
     32 
     33     /**
     34      * @title  Dividend = 0
     35      */
     36     public void testN2() {
     37         T_fdiv_1 t = new T_fdiv_1();
     38         assertEquals(0f, t.run(0, 3.14f));
     39     }
     40 
     41     /**
     42      * @title  Dividend is negative
     43      */
     44     public void testN3() {
     45         T_fdiv_1 t = new T_fdiv_1();
     46         assertEquals(-1.162963f, t.run(-3.14f, 2.7f));
     47     }
     48 
     49     /**
     50      * @title  Arguments = Float.MAX_VALUE, Float.NaN
     51      */
     52     public void testB1() {
     53         T_fdiv_1 t = new T_fdiv_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_fdiv_1 t = new T_fdiv_1();
     63         assertEquals(Float.NaN, t.run(Float.POSITIVE_INFINITY,
     64                 Float.NEGATIVE_INFINITY));
     65     }
     66 
     67     /**
     68      * @title  Arguments = Float.POSITIVE_INFINITY, -2.7f
     69      */
     70     public void testB3() {
     71         T_fdiv_1 t = new T_fdiv_1();
     72         assertEquals(Float.NEGATIVE_INFINITY, t.run(Float.POSITIVE_INFINITY,
     73                 -2.7f));
     74     }
     75 
     76     /**
     77      * @title  Arguments = -2.7f, Float.NEGATIVE_INFINITY
     78      */
     79     public void testB4() {
     80         T_fdiv_1 t = new T_fdiv_1();
     81         assertEquals(0f, t.run(-2.7f, Float.NEGATIVE_INFINITY));
     82     }
     83 
     84     /**
     85      * @title  Arguments = 0, 0
     86      */
     87     public void testB5() {
     88         T_fdiv_1 t = new T_fdiv_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_fdiv_1 t = new T_fdiv_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_fdiv_1 t = new T_fdiv_1();
    105         assertEquals(Float.NEGATIVE_INFINITY, t.run(-2.7f, 0));
    106     }
    107 
    108     /**
    109      * @title  Arguments = 1, Float.MAX_VALUE
    110      */
    111     public void testB8() {
    112         T_fdiv_1 t = new T_fdiv_1();
    113         assertEquals(Float.POSITIVE_INFINITY, t.run(1, Float.MIN_VALUE));
    114     }
    115 
    116     /**
    117      * @title  Arguments = Float.MAX_VALUE, -1E-9f
    118      */
    119     public void testB9() {
    120         T_fdiv_1 t = new T_fdiv_1();
    121         assertEquals(Float.NEGATIVE_INFINITY, t.run(Float.MAX_VALUE, -1E-9f));
    122     }
    123 
    124     /**
    125      * @constraint 4.8.2.1
    126      * @title number of arguments
    127      */
    128     public void testVFE1() {
    129         try {
    130             Class.forName("dxc.junit.opcodes.fdiv.jm.T_fdiv_2");
    131             fail("expected a verification exception");
    132         } catch (Throwable t) {
    133             DxUtil.checkVerifyException(t);
    134         }
    135     }
    136 
    137     /**
    138      * @constraint 4.8.2.1
    139      * @title types of arguments - float / double
    140      */
    141     public void testVFE2() {
    142         try {
    143             Class.forName("dxc.junit.opcodes.fdiv.jm.T_fdiv_3");
    144             fail("expected a verification exception");
    145         } catch (Throwable t) {
    146             DxUtil.checkVerifyException(t);
    147         }
    148     }
    149 
    150     /**
    151      * @constraint 4.8.2.1
    152      * @title types of arguments - long / float
    153      */
    154     public void testVFE3() {
    155         try {
    156             Class.forName("dxc.junit.opcodes.fdiv.jm.T_fdiv_4");
    157             fail("expected a verification exception");
    158         } catch (Throwable t) {
    159             DxUtil.checkVerifyException(t);
    160         }
    161     }
    162 
    163     /**
    164      * @constraint 4.8.2.1
    165      * @title types of arguments - reference / float
    166      */
    167     public void testVFE4() {
    168         try {
    169             Class.forName("dxc.junit.opcodes.fdiv.jm.T_fdiv_5");
    170             fail("expected a verification exception");
    171         } catch (Throwable t) {
    172             DxUtil.checkVerifyException(t);
    173         }
    174     }
    175 
    176 }
    177