Home | History | Annotate | Download | only in aaload
      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 dxc.junit.opcodes.aaload;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.aaload.jm.T_aaload_1;
     22 
     23 public class Test_aaload extends DxTestCase {
     24 
     25     /**
     26      * @title Normal test. Trying different indexes
     27      */
     28     public void testN1() {
     29         T_aaload_1 t = new T_aaload_1();
     30         String[] arr = new String[] {"a", "b"};
     31         assertEquals("a", t.run(arr, 0));
     32     }
     33 
     34     /**
     35      * @title Normal test. Trying different indexes
     36      */
     37     public void testN2() {
     38         T_aaload_1 t = new T_aaload_1();
     39         String[] arr = new String[] {"a", "b"};
     40         assertEquals("b", t.run(arr, 1));
     41     }
     42 
     43     /**
     44      * @title ArrayIndexOutOfBoundsException expected
     45      */
     46     public void testE1() {
     47         T_aaload_1 t = new T_aaload_1();
     48         String[] arr = new String[] {"a", "b"};
     49         try {
     50             t.run(arr, 2);
     51             fail("expected ArrayIndexOutOfBoundsException");
     52         } catch (ArrayIndexOutOfBoundsException aioobe) {
     53             // expected
     54         }
     55     }
     56 
     57     /**
     58      * @title Negative index. ArrayIndexOutOfBoundsException expected
     59      */
     60     public void testE2() {
     61         T_aaload_1 t = new T_aaload_1();
     62         String[] arr = new String[] {"a", "b"};
     63         try {
     64             t.run(arr, -1);
     65             fail("expected ArrayIndexOutOfBoundsException");
     66         } catch (ArrayIndexOutOfBoundsException aioobe) {
     67             // expected
     68         }
     69     }
     70 
     71     /**
     72      * @title NullPointerException expected
     73      */
     74     public void testE3() {
     75         T_aaload_1 t = new T_aaload_1();
     76         String[] arr = null;
     77         try {
     78             t.run(arr, 0);
     79             fail("expected NullPointerException");
     80         } catch (NullPointerException npe) {
     81             // expected
     82         }
     83     }
     84 
     85     /**
     86      * @constraint 4.8.2.1
     87      * @title number of arguments
     88      */
     89     public void testVFE1() {
     90         try {
     91             Class.forName("dxc.junit.opcodes.aaload.jm.T_aaload_2");
     92             fail("expected a verification exception");
     93         } catch (Throwable t) {
     94             DxUtil.checkVerifyException(t);
     95         }
     96     }
     97 
     98     /**
     99      * @constraint 4.8.2.1
    100      * @title number of arguments
    101      */
    102     public void testVFE2() {
    103         try {
    104             Class.forName("dxc.junit.opcodes.aaload.jm.T_aaload_3");
    105             fail("expected a verification exception");
    106         } catch (Throwable t) {
    107             DxUtil.checkVerifyException(t);
    108         }
    109     }
    110 
    111     /**
    112      * @constraint 4.8.2.1
    113      * @title types of arguments - array, double
    114      */
    115     public void testVFE3() {
    116         try {
    117             Class.forName("dxc.junit.opcodes.aaload.jm.T_aaload_4");
    118             fail("expected a verification exception");
    119         } catch (Throwable t) {
    120             DxUtil.checkVerifyException(t);
    121         }
    122     }
    123 
    124     /**
    125      * @constraint 4.8.2.1
    126      * @title types of arguments - array, long
    127      */
    128     public void testVFE4() {
    129         try {
    130             Class.forName("dxc.junit.opcodes.aaload.jm.T_aaload_5");
    131             fail("expected a verification exception");
    132         } catch (Throwable t) {
    133             DxUtil.checkVerifyException(t);
    134         }
    135     }
    136 
    137     /**
    138      * @constraint 4.8.2.1
    139      * @title types of arguments - Object, int
    140      */
    141     public void testVFE5() {
    142         try {
    143             Class.forName("dxc.junit.opcodes.aaload.jm.T_aaload_6");
    144             fail("expected a verification exception");
    145         } catch (Throwable t) {
    146             DxUtil.checkVerifyException(t);
    147         }
    148     }
    149 
    150     /**
    151      * @constraint 4.8.2.1
    152      * @title types of arguments - float[], int
    153      */
    154     public void testVFE6() {
    155         try { // opcodes.aastore.jm
    156             Class.forName("dxc.junit.opcodes.aaload.jm.T_aaload_7");
    157             fail("expected a verification exception");
    158         } catch (Throwable t) {
    159             DxUtil.checkVerifyException(t);
    160         }
    161     }
    162 
    163     /**
    164      * @constraint 4.8.2.1
    165      * @title types of arguments - long[], int
    166      */
    167     public void testVFE7() {
    168         try {
    169             Class.forName("dxc.junit.opcodes.aaload.jm.T_aaload_8");
    170             fail("expected a verification exception");
    171         } catch (Throwable t) {
    172             DxUtil.checkVerifyException(t);
    173         }
    174     }
    175 
    176     /**
    177      * @constraint 4.8.2.1
    178      * @title types of arguments - array, reference
    179      */
    180     public void testVFE8() {
    181         try {
    182             Class.forName("dxc.junit.opcodes.aaload.jm.T_aaload_9");
    183             fail("expected a verification exception");
    184         } catch (Throwable t) {
    185             DxUtil.checkVerifyException(t);
    186         }
    187     }
    188 
    189 }
    190