Home | History | Annotate | Download | only in ifnull
      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.ifnull;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.ifnull.jm.T_ifnull_1;
     22 
     23 public class Test_ifnull extends DxTestCase {
     24 
     25     /**
     26      * @title  Argument = this
     27      */
     28     public void testN1() {
     29         T_ifnull_1 t = new T_ifnull_1();
     30         /*
     31          * Compare with 1234 to check that in case of failed comparison
     32          * execution proceeds at the address following if_acmpeq instruction
     33          */
     34         assertEquals(1234, t.run(this));
     35     }
     36 
     37     /**
     38      * @title  Argument = null
     39      */
     40     public void testN2() {
     41         T_ifnull_1 t = new T_ifnull_1();
     42         assertEquals(1, t.run(null));
     43     }
     44 
     45     /**
     46      * @constraint 4.8.2.1
     47      * @title number of arguments
     48      */
     49     public void testVFE1() {
     50         try {
     51             Class.forName("dxc.junit.opcodes.ifnull.jm.T_ifnull_2");
     52             fail("expected a verification exception");
     53         } catch (Throwable t) {
     54             DxUtil.checkVerifyException(t);
     55         }
     56     }
     57 
     58     /**
     59      * @constraint 4.8.2.1
     60      * @title types of arguments - double
     61      */
     62     public void testVFE2() {
     63         try {
     64             Class.forName("dxc.junit.opcodes.ifnull.jm.T_ifnull_3");
     65             fail("expected a verification exception");
     66         } catch (Throwable t) {
     67             DxUtil.checkVerifyException(t);
     68         }
     69     }
     70 
     71     /**
     72      * @constraint 4.8.2.1
     73      * @title types of arguments - long
     74      */
     75     public void testVFE3() {
     76         try {
     77             Class.forName("dxc.junit.opcodes.ifnull.jm.T_ifnull_4");
     78             fail("expected a verification exception");
     79         } catch (Throwable t) {
     80             DxUtil.checkVerifyException(t);
     81         }
     82     }
     83 
     84     /**
     85      * @constraint 4.8.1.7
     86      * @title branch target shall be inside the
     87      * method
     88      */
     89     public void testVFE4() {
     90         try {
     91             Class.forName("dxc.junit.opcodes.ifnull.jm.T_ifnull_5");
     92             fail("expected a verification exception");
     93         } catch (Throwable t) {
     94             DxUtil.checkVerifyException(t);
     95         }
     96     }
     97 
     98     /**
     99      * @constraint 4.8.1.7
    100      * @title branch target shall not be "inside" wide
    101      * instruction
    102      */
    103     public void testVFE5() {
    104         try {
    105             Class.forName("dxc.junit.opcodes.ifnull.jm.T_ifnull_6");
    106             fail("expected a verification exception");
    107         } catch (Throwable t) {
    108             DxUtil.checkVerifyException(t);
    109         }
    110     }
    111 
    112 }
    113