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