Home | History | Annotate | Download | only in aget
      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.aget;
     18 
     19 import dot.junit.DxTestCase;
     20 import dot.junit.DxUtil;
     21 import dot.junit.opcodes.aget.d.T_aget_1;
     22 import dot.junit.opcodes.aget.d.T_aget_8;
     23 
     24 public class Test_aget extends DxTestCase {
     25     /**
     26      * @title get int from array
     27      */
     28     public void testN1() {
     29         T_aget_1 t = new T_aget_1();
     30         int[] arr = new int[2];
     31         arr[1] = 100000000;
     32         assertEquals(100000000, t.run(arr, 1));
     33     }
     34 
     35     /**
     36      * @title get int from array
     37      */
     38     public void testN2() {
     39         T_aget_1 t = new T_aget_1();
     40         int[] arr = new int[2];
     41         arr[0] = 100000000;
     42         assertEquals(100000000, t.run(arr, 0));
     43     }
     44 
     45     /**
     46      * @title expected ArrayIndexOutOfBoundsException
     47      */
     48     public void testE1() {
     49         loadAndRun("dot.junit.opcodes.aget.d.T_aget_1", ArrayIndexOutOfBoundsException.class,
     50                    new int[2], 2);
     51     }
     52 
     53     /**
     54      * @title expected NullPointerException
     55      */
     56     public void testE2() {
     57         loadAndRun("dot.junit.opcodes.aget.d.T_aget_1", NullPointerException.class, null, 2);
     58     }
     59 
     60     /**
     61      * @title expected ArrayIndexOutOfBoundsException (negative index)
     62      */
     63     public void testE3() {
     64         loadAndRun("dot.junit.opcodes.aget.d.T_aget_1", ArrayIndexOutOfBoundsException.class,
     65                    new int[2], -1);
     66     }
     67 
     68     /**
     69      * @constraint B1
     70      * @title types of arguments - array, double
     71      */
     72     public void testVFE1() {
     73         load("dot.junit.opcodes.aget.d.T_aget_2", VerifyError.class);
     74     }
     75 
     76     /**
     77      * @constraint B1
     78      * @title  types of arguments - array, long
     79      */
     80     public void testVFE2() {
     81         load("dot.junit.opcodes.aget.d.T_aget_3", VerifyError.class);
     82     }
     83 
     84     /**
     85      * @constraint B1
     86      * @title  types of arguments - Object, int
     87      */
     88     public void testVFE3() {
     89         load("dot.junit.opcodes.aget.d.T_aget_4", VerifyError.class);
     90     }
     91 
     92     /**
     93      * @constraint B1
     94      * @title  types of arguments - double[], int
     95      */
     96     public void testVFE4() {
     97         load("dot.junit.opcodes.aget.d.T_aget_5", VerifyError.class);
     98     }
     99 
    100     /**
    101      * @constraint B1
    102      * @title types of arguments - long[], int
    103      */
    104     public void testVFE5() {
    105         load("dot.junit.opcodes.aget.d.T_aget_6", VerifyError.class);
    106     }
    107 
    108     /**
    109      * @constraint B1
    110      * @title types of arguments - array, reference
    111      */
    112     public void testVFE6() {
    113         load("dot.junit.opcodes.aget.d.T_aget_7", VerifyError.class);
    114     }
    115 
    116     /**
    117      * @constraint A23
    118      * @title  number of registers
    119      */
    120     public void testVFE7() {
    121         load("dot.junit.opcodes.aget.d.T_aget_9", VerifyError.class);
    122     }
    123 
    124     /**
    125      * @constraint B1
    126      * @title Type of index argument - float. The verifier checks that ints
    127      * and floats are not used interchangeably.
    128      */
    129     public void testVFE8() {
    130         load("dot.junit.opcodes.aget.d.T_aget_8", VerifyError.class);
    131     }
    132 
    133 }
    134