Home | History | Annotate | Download | only in if_gez
      1 package dot.junit.opcodes.if_gez;
      2 
      3 import dot.junit.DxTestCase;
      4 import dot.junit.DxUtil;
      5 import dot.junit.opcodes.if_gez.d.T_if_gez_1;
      6 import dot.junit.opcodes.if_gez.d.T_if_gez_2;
      7 
      8 public class Test_if_gez extends DxTestCase {
      9 
     10     /**
     11      * @title Argument = 5
     12      */
     13     public void testN1() {
     14         T_if_gez_1 t = new T_if_gez_1();
     15         assertEquals(1, t.run(5));
     16     }
     17 
     18     /**
     19      * @title Argument = -5
     20      */
     21     public void testN2() {
     22         T_if_gez_1 t = new T_if_gez_1();
     23         assertEquals(1234, t.run(-5));
     24     }
     25 
     26     /**
     27      * @title Types of arguments - float. Dalvik doens't distinguish 32-bits types internally,
     28      * so this operation of float makes no sense but shall not crash the VM.
     29      */
     30     public void testN3() {
     31         T_if_gez_2 t = new T_if_gez_2();
     32         assertEquals(1, t.run(1.123f));
     33     }
     34 
     35     /**
     36      * @title Arguments = Integer.MAX_VALUE
     37      */
     38     public void testB1() {
     39         T_if_gez_1 t = new T_if_gez_1();
     40         assertEquals(1, t.run(Integer.MAX_VALUE));
     41     }
     42 
     43     /**
     44      * @title Arguments = Integer.MIN_VALUE
     45      */
     46     public void testB2() {
     47         T_if_gez_1 t = new T_if_gez_1();
     48         assertEquals(1234, t.run(Integer.MIN_VALUE));
     49     }
     50 
     51     /**
     52      * @title Arguments = 0
     53      */
     54     public void testB3() {
     55         T_if_gez_1 t = new T_if_gez_1();
     56         assertEquals(1, t.run(0));
     57     }
     58 
     59     /**
     60      * @constraint A23
     61      * @title  number of registers
     62      */
     63     public void testVFE1() {
     64         try {
     65             Class.forName("dot.junit.opcodes.if_gez.d.T_if_gez_3");
     66             fail("expected a verification exception");
     67         } catch (Throwable t) {
     68             DxUtil.checkVerifyException(t);
     69         }
     70     }
     71 
     72 
     73 
     74     /**
     75      * @constraint B1
     76      * @title  types of arguments - double
     77      */
     78     public void testVFE2() {
     79         try {
     80             Class.forName("dot.junit.opcodes.if_gez.d.T_if_gez_4");
     81             fail("expected a verification exception");
     82         } catch (Throwable t) {
     83             DxUtil.checkVerifyException(t);
     84         }
     85     }
     86 
     87     /**
     88      * @constraint B1
     89      * @title  types of arguments - long
     90      */
     91     public void testVFE3() {
     92         try {
     93             Class.forName("dot.junit.opcodes.if_gez.d.T_if_gez_5");
     94             fail("expected a verification exception");
     95         } catch (Throwable t) {
     96             DxUtil.checkVerifyException(t);
     97         }
     98     }
     99 
    100     /**
    101      * @constraint B1
    102      * @title  types of arguments - reference
    103      */
    104     public void testVFE4() {
    105         try {
    106             Class.forName("dot.junit.opcodes.if_gez.d.T_if_gez_6");
    107             fail("expected a verification exception");
    108         } catch (Throwable t) {
    109             DxUtil.checkVerifyException(t);
    110         }
    111     }
    112 
    113     /**
    114      * @constraint A6
    115      * @title branch target shall be inside the method
    116      */
    117     public void testVFE5() {
    118         try {
    119             Class.forName("dot.junit.opcodes.if_gez.d.T_if_gez_8");
    120             fail("expected a verification exception");
    121         } catch (Throwable t) {
    122             DxUtil.checkVerifyException(t);
    123         }
    124     }
    125 
    126     /**
    127      * @constraint A6
    128      * @title  branch target shall not be "inside" instruction
    129      */
    130     public void testVFE6() {
    131         try {
    132             Class.forName("dot.junit.opcodes.if_gez.d.T_if_gez_9");
    133             fail("expected a verification exception");
    134         } catch (Throwable t) {
    135             DxUtil.checkVerifyException(t);
    136         }
    137     }
    138 
    139     /**
    140      * @constraint n/a
    141      * @title  branch must not be 0
    142      */
    143     public void testVFE7() {
    144         try {
    145             Class.forName("dot.junit.opcodes.if_gez.d.T_if_gez_10");
    146             fail("expected a verification exception");
    147         } catch (Throwable t) {
    148             DxUtil.checkVerifyException(t);
    149         }
    150     }
    151 }
    152