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