Home | History | Annotate | Download | only in add_int_lit16
      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_lit16;
     18 
     19 import dot.junit.DxTestCase;
     20 import dot.junit.DxUtil;
     21 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_16;
     22 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_5;
     23 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_1;
     24 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_10;
     25 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_11;
     26 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_12;
     27 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_2;
     28 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_3;
     29 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_4;
     30 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_6;
     31 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_7;
     32 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_8;
     33 import dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_9;
     34 
     35 public class Test_add_int_lit16 extends DxTestCase {
     36     /**
     37      * @title Arguments = 8 + 4
     38      */
     39     public void testN1() {
     40         T_add_int_lit16_1 t = new T_add_int_lit16_1();
     41         assertEquals(12, t.run());
     42     }
     43 
     44     /**
     45      * @title Arguments = 0 + 255
     46      */
     47     public void testN2() {
     48         T_add_int_lit16_2 t = new T_add_int_lit16_2();
     49         assertEquals(255, t.run());
     50     }
     51 
     52     /**
     53      * @title Arguments = 0 + (-32768)
     54      */
     55     public void testN3() {
     56         T_add_int_lit16_3 t = new T_add_int_lit16_3();
     57         assertEquals(-32768, t.run());
     58     }
     59 
     60     /**
     61      * @title Arguments = (-2147483647) + 0
     62      */
     63     public void testN4() {
     64         T_add_int_lit16_4 t = new T_add_int_lit16_4();
     65         assertEquals(-2147483647, t.run());
     66     }
     67 
     68     /**
     69      * @title Arguments = 0x7ffffffe + 2
     70      */
     71     public void testN5() {
     72         T_add_int_lit16_5 t = new T_add_int_lit16_5();
     73         assertEquals(-2147483648, t.run());
     74     }
     75 
     76     /**
     77      * @title Arguments = -1 + 1
     78      */
     79     public void testN6() {
     80         T_add_int_lit16_6 t = new T_add_int_lit16_6();
     81         assertEquals(0, t.run());
     82     }
     83 
     84     /**
     85      * @title Types of arguments - int, float. Dalvik doens't distinguish 32-bits types internally,
     86      * so this sum of float and int makes no sense but shall not crash the VM.
     87      */
     88 
     89     public void testN7() {
     90         T_add_int_lit16_16 t = new T_add_int_lit16_16();
     91         try {
     92             t.run(3.14f);
     93         } catch (Throwable e) {
     94         }
     95     }
     96 
     97     /**
     98      * @title Arguments = 0 + Short.MAX_VALUE
     99      */
    100     public void testB1() {
    101         T_add_int_lit16_7 t = new T_add_int_lit16_7();
    102         assertEquals(Short.MAX_VALUE, t.run());
    103     }
    104 
    105     /**
    106      * @title Arguments = Integer.MAX_VALUE + Short.MAX_VALUE
    107      */
    108     public void testB2() {
    109         T_add_int_lit16_8 t = new T_add_int_lit16_8();
    110         assertEquals(-2147450882, t.run());
    111     }
    112 
    113     /**
    114      * @title Arguments = Integer.MAX_VALUE + 1
    115      */
    116     public void testB3() {
    117         T_add_int_lit16_9 t = new T_add_int_lit16_9();
    118         assertEquals(Integer.MIN_VALUE, t.run());
    119     }
    120 
    121     /**
    122      * @title Arguments = Integer.MIN_VALUE + 1
    123      */
    124     public void testB4() {
    125         T_add_int_lit16_10 t = new T_add_int_lit16_10();
    126         assertEquals(-2147483647, t.run());
    127     }
    128 
    129     /**
    130      * @title Arguments = 0 + 0
    131      */
    132     public void testB5() {
    133         T_add_int_lit16_11 t = new T_add_int_lit16_11();
    134         assertEquals(0, t.run());
    135     }
    136 
    137     /**
    138      * @title Arguments = Short.MIN_VALUE + Short.MIN_VALUE
    139      */
    140     public void testB6() {
    141         T_add_int_lit16_12 t = new T_add_int_lit16_12();
    142         assertEquals(-65536, t.run());
    143     }
    144 
    145 
    146 
    147 
    148     /**
    149      * @constraint B1
    150      * @title types of arguments - int, double
    151      */
    152     public void testVFE1() {
    153         try {
    154             Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_13");
    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 - long, int
    164      */
    165     public void testVFE2() {
    166         try {
    167             Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_14");
    168             fail("expected a verification exception");
    169         } catch (Throwable t) {
    170             DxUtil.checkVerifyException(t);
    171         }
    172     }
    173 
    174     /**
    175      * @constraint B1
    176      * @title types of arguments - reference, int
    177      */
    178     public void testVFE3() {
    179         try {
    180             Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_15");
    181             fail("expected a verification exception");
    182         } catch (Throwable t) {
    183             DxUtil.checkVerifyException(t);
    184         }
    185     }
    186 
    187     /**
    188      * @constraint A23
    189      * @title  number of registers
    190      */
    191     public void testVFE4() {
    192         try {
    193             Class.forName("dot.junit.opcodes.add_int_lit16.d.T_add_int_lit16_17");
    194             fail("expected a verification exception");
    195         } catch (Throwable t) {
    196             DxUtil.checkVerifyException(t);
    197         }
    198     }
    199 }
    200