Home | History | Annotate | Download | only in frem
      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.frem;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.frem.jm.T_frem_1;
     22 
     23 public class Test_frem extends DxTestCase {
     24 
     25     /**
     26      * @title Arguments = 2.7f, 3.14f
     27      */
     28     public void testN1() {
     29         T_frem_1 t = new T_frem_1();
     30         assertEquals(2.7f, t.run(2.7f, 3.14f));
     31     }
     32 
     33     /**
     34      * @title  Dividend = 0
     35      */
     36     public void testN2() {
     37         T_frem_1 t = new T_frem_1();
     38         assertEquals(0f, t.run(0, 3.14f));
     39     }
     40 
     41     /**
     42      * @title  Dividend is negative
     43      */
     44     public void testN3() {
     45         T_frem_1 t = new T_frem_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_frem_1 t = new T_frem_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_frem_1 t = new T_frem_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_frem_1 t = new T_frem_1();
     72         assertEquals(Float.NaN, t.run(Float.POSITIVE_INFINITY, -2.7f));
     73     }
     74 
     75     /**
     76      * @title  Arguments = -2.7f, Float.NEGATIVE_INFINITY
     77      */
     78     public void testB4() {
     79         T_frem_1 t = new T_frem_1();
     80         assertEquals(-2.7f, t.run(-2.7f, Float.NEGATIVE_INFINITY));
     81     }
     82 
     83     /**
     84      * @title  Arguments = 0, 0
     85      */
     86     public void testB5() {
     87         T_frem_1 t = new T_frem_1();
     88         assertEquals(Float.NaN, t.run(0, 0));
     89     }
     90 
     91     /**
     92      * @title  Arguments = 0, -2.7
     93      */
     94     public void testB6() {
     95         T_frem_1 t = new T_frem_1();
     96         assertEquals(0f, t.run(0, -2.7f));
     97     }
     98 
     99     /**
    100      * @title  Arguments = -2.7, 0
    101      */
    102     public void testB7() {
    103         T_frem_1 t = new T_frem_1();
    104         assertEquals(Float.NaN, t.run(-2.7f, 0));
    105     }
    106 
    107     /**
    108      * @title  Arguments = 1, Float.MAX_VALUE
    109      */
    110     public void testB8() {
    111         T_frem_1 t = new T_frem_1();
    112         assertEquals(0f, t.run(1, Float.MIN_VALUE));
    113     }
    114 
    115     /**
    116      * @title  Arguments = Float.MAX_VALUE, -1E-9f
    117      */
    118     public void testB9() {
    119         T_frem_1 t = new T_frem_1();
    120         assertEquals(7.2584893E-10f, t.run(Float.MAX_VALUE, -1E-9f));
    121     }
    122 
    123     /**
    124      * @constraint 4.8.2.1
    125      * @title number of arguments
    126      */
    127     public void testVFE1() {
    128         try {
    129             Class.forName("dxc.junit.opcodes.frem.jm.T_frem_2");
    130             fail("expected a verification exception");
    131         } catch (Throwable t) {
    132             DxUtil.checkVerifyException(t);
    133         }
    134     }
    135 
    136     /**
    137      * @constraint 4.8.2.1
    138      * @title types of arguments - float, double
    139      */
    140     public void testVFE2() {
    141         try {
    142             Class.forName("dxc.junit.opcodes.frem.jm.T_frem_3");
    143             fail("expected a verification exception");
    144         } catch (Throwable t) {
    145             DxUtil.checkVerifyException(t);
    146         }
    147     }
    148 
    149     /**
    150      * @constraint 4.8.2.1
    151      * @title types of arguments - long, float
    152      */
    153     public void testVFE3() {
    154         try {
    155             Class.forName("dxc.junit.opcodes.frem.jm.T_frem_4");
    156             fail("expected a verification exception");
    157         } catch (Throwable t) {
    158             DxUtil.checkVerifyException(t);
    159         }
    160     }
    161 
    162     /**
    163      * @constraint 4.8.2.1
    164      * @title types of arguments - reference, float
    165      */
    166     public void testVFE4() {
    167         try {
    168             Class.forName("dxc.junit.opcodes.frem.jm.T_frem_5");
    169             fail("expected a verification exception");
    170         } catch (Throwable t) {
    171             DxUtil.checkVerifyException(t);
    172         }
    173     }
    174 
    175 }
    176