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