Home | History | Annotate | Download | only in iflt
      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.iflt;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.iflt.jm.T_iflt_1;
     22 
     23 public class Test_iflt extends DxTestCase {
     24 
     25     /**
     26      * @title  Argument = 5
     27      */
     28     public void testN1() {
     29         T_iflt_1 t = new T_iflt_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(5));
     35     }
     36 
     37     /**
     38      * @title  Argument = 0
     39      */
     40     public void testN2() {
     41         T_iflt_1 t = new T_iflt_1();
     42         assertEquals(1234, t.run(0));
     43     }
     44 
     45     /**
     46      * @title  Arguments = -5
     47      */
     48     public void testN3() {
     49         T_iflt_1 t = new T_iflt_1();
     50         assertEquals(1, t.run(-5));
     51     }
     52 
     53     /**
     54      * @title  Arguments = Integer.MAX_VALUE
     55      */
     56     public void testB1() {
     57         T_iflt_1 t = new T_iflt_1();
     58         assertEquals(1234, t.run(Integer.MAX_VALUE));
     59     }
     60 
     61     /**
     62      * @title  Arguments = Integer.MIN_VALUE
     63      */
     64     public void testB2() {
     65         T_iflt_1 t = new T_iflt_1();
     66         assertEquals(1, t.run(Integer.MIN_VALUE));
     67     }
     68 
     69     /**
     70      * @constraint 4.8.2.1
     71      * @title number of arguments
     72      */
     73     public void testVFE1() {
     74         try {
     75             Class.forName("dxc.junit.opcodes.iflt.jm.T_iflt_2");
     76             fail("expected a verification exception");
     77         } catch (Throwable t) {
     78             DxUtil.checkVerifyException(t);
     79         }
     80     }
     81 
     82     /**
     83      * @constraint 4.8.2.1
     84      * @title types of arguments - double
     85      */
     86     public void testVFE2() {
     87         try {
     88             Class.forName("dxc.junit.opcodes.iflt.jm.T_iflt_3");
     89             fail("expected a verification exception");
     90         } catch (Throwable t) {
     91             DxUtil.checkVerifyException(t);
     92         }
     93     }
     94 
     95     /**
     96      * @constraint 4.8.2.1
     97      * @title types of arguments - long
     98      */
     99     public void testVFE3() {
    100         try {
    101             Class.forName("dxc.junit.opcodes.iflt.jm.T_iflt_4");
    102             fail("expected a verification exception");
    103         } catch (Throwable t) {
    104             DxUtil.checkVerifyException(t);
    105         }
    106     }
    107 
    108     /**
    109      * @constraint 4.8.1.7
    110      * @title branch target shall be inside the
    111      * method
    112      */
    113     public void testVFE4() {
    114         try {
    115             Class.forName("dxc.junit.opcodes.iflt.jm.T_iflt_5");
    116             fail("expected a verification exception");
    117         } catch (Throwable t) {
    118             DxUtil.checkVerifyException(t);
    119         }
    120     }
    121 
    122     /**
    123      * @constraint 4.8.1.7
    124      * @title branch target shall not be "inside" wide
    125      * instruction
    126      */
    127     public void testVFE5() {
    128         try {
    129             Class.forName("dxc.junit.opcodes.iflt.jm.T_iflt_6");
    130             fail("expected a verification exception");
    131         } catch (Throwable t) {
    132             DxUtil.checkVerifyException(t);
    133         }
    134     }
    135 
    136     /**
    137      * @constraint 4.8.2.1
    138      * @title types of arguments - reference
    139      */
    140     public void testVFE6() {
    141         try {
    142             Class.forName("dxc.junit.opcodes.iflt.jm.T_iflt_7");
    143             fail("expected a verification exception");
    144         } catch (Throwable t) {
    145             DxUtil.checkVerifyException(t);
    146         }
    147     }
    148 
    149 }
    150