Home | History | Annotate | Download | only in arraylength
      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.arraylength;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.arraylength.jm.T_arraylength_1;
     22 
     23 public class Test_arraylength extends DxTestCase {
     24 
     25     /**
     26      * @title normal test
     27      */
     28     public void testN1() {
     29         T_arraylength_1 t = new T_arraylength_1();
     30         String[] a = new String[5];
     31         assertEquals(5, t.run(a));
     32     }
     33 
     34     /**
     35      * @title NullPointerException expected
     36      */
     37     public void testNPE1() {
     38         T_arraylength_1 t = new T_arraylength_1();
     39         try {
     40             t.run(null);
     41             fail("NPE expected");
     42         } catch (NullPointerException npe) {
     43             // expected
     44         }
     45     }
     46 
     47     /**
     48      * @constraint 4.8.2.1
     49      * @title types of arguments - Object
     50      */
     51     public void testVFE2() {
     52         try {
     53             Class.forName("dxc.junit.opcodes.arraylength.jm.T_arraylength_2");
     54             fail("expected a verification exception");
     55         } catch (Throwable t) {
     56             DxUtil.checkVerifyException(t);
     57         }
     58     }
     59 
     60     /**
     61      * @constraint 4.8.2.1
     62      * @title types of arguments - int
     63      */
     64     public void testVFE1() {
     65         try {
     66             Class.forName("dxc.junit.opcodes.arraylength.jm.T_arraylength_3");
     67             fail("expected a verification exception");
     68         } catch (Throwable t) {
     69             DxUtil.checkVerifyException(t);
     70         }
     71     }
     72 
     73 }
     74