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