Home | History | Annotate | Download | only in array_length
      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.array_length;
     18 
     19 import dot.junit.DxTestCase;
     20 import dot.junit.DxUtil;
     21 import dot.junit.opcodes.array_length.d.T_array_length_1;
     22 import dot.junit.opcodes.array_length.d.T_array_length_4;
     23 
     24 
     25 public class Test_array_length extends DxTestCase {
     26     /**
     27      * @title get length of array of references
     28      */
     29     public void testN1() {
     30         T_array_length_1 t = new T_array_length_1();
     31         String[] a = new String[5];
     32         assertEquals(5, t.run(a));
     33     }
     34 
     35     /**
     36      * @title get length of array of doubles
     37      */
     38     public void testN2() {
     39         T_array_length_4 t = new T_array_length_4();
     40         double[] a = new double[10];
     41         assertEquals(10, t.run(a));
     42     }
     43 
     44     /**
     45      * @title expected NullPointerException
     46      */
     47     public void testNPE1() {
     48         T_array_length_1 t = new T_array_length_1();
     49         try {
     50             t.run(null);
     51             fail("NPE expected");
     52         } catch (NullPointerException npe) {
     53             // expected
     54         }
     55     }
     56 
     57 
     58 
     59     /**
     60      * @constraint B1
     61      * @title types of arguments - Object
     62      */
     63     public void testVFE1() {
     64         try {
     65             Class.forName("dxc.junit.opcodes.array_length.jm.T_array_length_2");
     66             fail("expected a verification exception");
     67         } catch (Throwable t) {
     68             DxUtil.checkVerifyException(t);
     69         }
     70     }
     71 
     72     /**
     73      * @constraint B1
     74      * @title types of arguments - int
     75      */
     76     public void testVFE2() {
     77         try {
     78             Class.forName("dxc.junit.opcodes.array_length.jm.T_array_length_3");
     79             fail("expected a verification exception");
     80         } catch (Throwable t) {
     81             DxUtil.checkVerifyException(t);
     82         }
     83     }
     84 
     85     /**
     86      * @constraint A23
     87      * @title number of registers
     88      */
     89     public void testVFE3() {
     90         try {
     91             Class.forName("dxc.junit.opcodes.array_length.jm.T_array_length_5");
     92             fail("expected a verification exception");
     93         } catch (Throwable t) {
     94             DxUtil.checkVerifyException(t);
     95         }
     96     }
     97 }
     98