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