Home | History | Annotate | Download | only in swap
      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.swap;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.swap.jm.T_swap_1;
     22 import dxc.junit.opcodes.swap.jm.T_swap_6;
     23 import dxc.junit.opcodes.swap.jm.T_swap_7;
     24 import dxc.junit.opcodes.swap.jm.T_swap_8;
     25 
     26 public class Test_swap extends DxTestCase {
     27 
     28     /**
     29      * @title  Integers
     30      */
     31     public void testN1() {
     32         T_swap_1 t = new T_swap_1();
     33         assertEquals(8, t.run(15, 8));
     34     }
     35 
     36     /**
     37      * @title  Floats
     38      */
     39     public void testN2() {
     40         T_swap_6 t = new T_swap_6();
     41         assertEquals(8f, t.run(15f, 8f));
     42     }
     43 
     44     /**
     45      * @title  References
     46      */
     47     public void testN3() {
     48         T_swap_7 t = new T_swap_7();
     49         int tmp[] = new int[1];
     50         assertEquals(tmp, t.run(this, tmp));
     51     }
     52 
     53     /**
     54      * @title  Reference & int
     55      */
     56     public void testN4() {
     57         T_swap_8 t = new T_swap_8();
     58         assertEquals(this, t.run(0xff, this));
     59     }
     60 
     61     /**
     62      * @constraint 4.8.2.1
     63      * @title number of arguments
     64      */
     65     public void testVFE1() {
     66         try {
     67             Class.forName("dxc.junit.opcodes.swap.jm.T_swap_2");
     68             fail("expected a verification exception");
     69         } catch (Throwable t) {
     70             DxUtil.checkVerifyException(t);
     71         }
     72     }
     73 
     74 
     75     /**
     76      * @constraint 4.8.2.1
     77      * @title types of arguments - double & int
     78      */
     79     public void testVFE2() {
     80         try {
     81             Class.forName("dxc.junit.opcodes.swap.jm.T_swap_3");
     82             fail("expected a verification exception");
     83         } catch (Throwable t) {
     84             DxUtil.checkVerifyException(t);
     85         }
     86     }
     87 
     88     /**
     89      * @constraint 4.8.2.1
     90      * @title types of arguments - long & int
     91      */
     92     public void testVFE3() {
     93         try {
     94             Class.forName("dxc.junit.opcodes.swap.jm.T_swap_4");
     95             fail("expected a verification exception");
     96         } catch (Throwable t) {
     97             DxUtil.checkVerifyException(t);
     98         }
     99     }
    100 
    101     /**
    102      * @constraint 4.8.2.1
    103      * @title types of arguments - long & long
    104      */
    105     public void testVFE4() {
    106         try {
    107             Class.forName("dxc.junit.opcodes.swap.jm.T_swap_5");
    108             fail("expected a verification exception");
    109         } catch (Throwable t) {
    110             DxUtil.checkVerifyException(t);
    111         }
    112     }
    113 
    114 }
    115