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