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