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