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