Home | History | Annotate | Download | only in dneg
      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 dxc.junit.opcodes.dneg;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.dneg.jm.T_dneg_1;
     22 
     23 public class Test_dneg extends DxTestCase {
     24 
     25     /**
     26      * @title  Argument = 1
     27      */
     28     public void testN1() {
     29         T_dneg_1 t = new T_dneg_1();
     30         assertEquals(-1d, t.run(1d));
     31     }
     32 
     33     /**
     34      * @title  Argument = -1
     35      */
     36     public void testN2() {
     37         T_dneg_1 t = new T_dneg_1();
     38         assertEquals(1d, t.run(-1d));
     39     }
     40 
     41     /**
     42      * @title  Argument = +0
     43      */
     44     public void testN3() {
     45         T_dneg_1 t = new T_dneg_1();
     46         assertEquals(-0d, t.run(+0d));
     47     }
     48 
     49     /**
     50      * @title  Argument = -2.7
     51      */
     52     public void testN4() {
     53         T_dneg_1 t = new T_dneg_1();
     54         assertEquals(2.7d, t.run(-2.7d));
     55     }
     56 
     57 
     58     /**
     59      * @title  Argument = Double.NaN
     60      */
     61     public void testB1() {
     62         T_dneg_1 t = new T_dneg_1();
     63         assertEquals(Double.NaN, t.run(Double.NaN));
     64     }
     65 
     66     /**
     67      * @title  Argument = Double.NEGATIVE_INFINITY
     68      */
     69     public void testB2() {
     70         T_dneg_1 t = new T_dneg_1();
     71         assertEquals(Double.POSITIVE_INFINITY, t.run(Double.NEGATIVE_INFINITY));
     72     }
     73 
     74     /**
     75      * @title  Argument = Double.POSITIVE_INFINITY
     76      */
     77     public void testB3() {
     78         T_dneg_1 t = new T_dneg_1();
     79         assertEquals(Double.NEGATIVE_INFINITY, t.run(Double.POSITIVE_INFINITY));
     80     }
     81 
     82     /**
     83      * @title  Argument = Double.MAX_VALUE
     84      */
     85     public void testB4() {
     86         T_dneg_1 t = new T_dneg_1();
     87         assertEquals(-1.7976931348623157E308d, t.run(Double.MAX_VALUE));
     88     }
     89 
     90     /**
     91      * @title  Argument = Double.MIN
     92      */
     93     public void testB5() {
     94         T_dneg_1 t = new T_dneg_1();
     95         assertEquals(-4.9E-324d, t.run(Double.MIN_VALUE));
     96     }
     97 
     98     /**
     99      * @constraint 4.8.2.1
    100      * @title number of arguments
    101      */
    102     public void testVFE1() {
    103         try {
    104             Class.forName("dxc.junit.opcodes.dneg.jm.T_dneg_2");
    105             fail("expected a verification exception");
    106         } catch (Throwable t) {
    107             DxUtil.checkVerifyException(t);
    108         }
    109     }
    110 
    111     /**
    112      * @constraint 4.8.2.1
    113      * @title type of argument - float
    114      */
    115     public void testVFE2() {
    116         try {
    117             Class.forName("dxc.junit.opcodes.dneg.jm.T_dneg_3");
    118             fail("expected a verification exception");
    119         } catch (Throwable t) {
    120             DxUtil.checkVerifyException(t);
    121         }
    122     }
    123 
    124     /**
    125      * @constraint 4.8.2.1
    126      * @title type of argument - long
    127      */
    128     public void testVFE3() {
    129         try {
    130             Class.forName("dxc.junit.opcodes.dneg.jm.T_dneg_4");
    131             fail("expected a verification exception");
    132         } catch (Throwable t) {
    133             DxUtil.checkVerifyException(t);
    134         }
    135     }
    136 
    137     /**
    138      * @constraint 4.8.2.1
    139      * @title type of argument - reference
    140      */
    141     public void testVFE4() {
    142         try {
    143             Class.forName("dxc.junit.opcodes.dneg.jm.T_dneg_5");
    144             fail("expected a verification exception");
    145         } catch (Throwable t) {
    146             DxUtil.checkVerifyException(t);
    147         }
    148     }
    149 
    150 }
    151