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