Home | History | Annotate | Download | only in if_ltz
      1 package dot.junit.opcodes.if_ltz;
      2 
      3 import dot.junit.DxTestCase;
      4 import dot.junit.DxUtil;
      5 import dot.junit.opcodes.if_ltz.d.T_if_ltz_1;
      6 import dot.junit.opcodes.if_ltz.d.T_if_ltz_2;
      7 
      8 public class Test_if_ltz extends DxTestCase {
      9 
     10     /**
     11      * @title Argument = 5
     12      */
     13     public void testN1() {
     14         T_if_ltz_1 t = new T_if_ltz_1();
     15         assertEquals(1234, t.run(5));
     16     }
     17 
     18     /**
     19      * @title Argument = -5
     20      */
     21     public void testN2() {
     22         T_if_ltz_1 t = new T_if_ltz_1();
     23         assertEquals(1, 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_ltz_2 t = new T_if_ltz_2();
     32         assertEquals(1234, t.run(1.123f));
     33     }
     34 
     35     /**
     36      * @title Arguments = Integer.MAX_VALUE
     37      */
     38     public void testB1() {
     39         T_if_ltz_1 t = new T_if_ltz_1();
     40         assertEquals(1234, t.run(Integer.MAX_VALUE));
     41     }
     42 
     43     /**
     44      * @title Arguments = Integer.MIN_VALUE
     45      */
     46     public void testB2() {
     47         T_if_ltz_1 t = new T_if_ltz_1();
     48         assertEquals(1, t.run(Integer.MIN_VALUE));
     49     }
     50 
     51     /**
     52      * @title Arguments = 0
     53      */
     54     public void testB3() {
     55         T_if_ltz_1 t = new T_if_ltz_1();
     56         assertEquals(1234, 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_ltz.d.T_if_ltz_3");
     66             fail("expected a verification exception");
     67         } catch (Throwable t) {
     68             DxUtil.checkVerifyException(t);
     69         }
     70     }
     71 
     72 
     73     /**
     74      * @constraint B1
     75      * @title types of arguments - double
     76      */
     77     public void testVFE2() {
     78         try {
     79             Class.forName("dot.junit.opcodes.if_ltz.d.T_if_ltz_4");
     80             fail("expected a verification exception");
     81         } catch (Throwable t) {
     82             DxUtil.checkVerifyException(t);
     83         }
     84     }
     85 
     86     /**
     87      * @constraint B1
     88      * @title types of arguments - long
     89      */
     90     public void testVFE3() {
     91         try {
     92             Class.forName("dot.junit.opcodes.if_ltz.d.T_if_ltz_5");
     93             fail("expected a verification exception");
     94         } catch (Throwable t) {
     95             DxUtil.checkVerifyException(t);
     96         }
     97     }
     98 
     99     /**
    100      * @constraint B1
    101      * @title types of arguments - reference
    102      */
    103     public void testVFE4() {
    104         try {
    105             Class.forName("dot.junit.opcodes.if_ltz.d.T_if_ltz_6");
    106             fail("expected a verification exception");
    107         } catch (Throwable t) {
    108             DxUtil.checkVerifyException(t);
    109         }
    110     }
    111 
    112     /**
    113      * @constraint A6
    114      * @title  branch target shall be inside the method
    115      */
    116     public void testVFE5() {
    117         try {
    118             Class.forName("dot.junit.opcodes.if_ltz.d.T_if_ltz_8");
    119             fail("expected a verification exception");
    120         } catch (Throwable t) {
    121             DxUtil.checkVerifyException(t);
    122         }
    123     }
    124 
    125     /**
    126      * @constraint A6
    127      * @title branch target shall not be "inside" instruction
    128      */
    129     public void testVFE6() {
    130         try {
    131             Class.forName("dot.junit.opcodes.if_ltz.d.T_if_ltz_9");
    132             fail("expected a verification exception");
    133         } catch (Throwable t) {
    134             DxUtil.checkVerifyException(t);
    135         }
    136     }
    137 
    138     /**
    139      * @constraint n/a
    140      * @title branch must not be 0
    141      */
    142     public void testVFE7() {
    143         try {
    144             Class.forName("dot.junit.opcodes.if_ltz.d.T_if_ltz_7");
    145             fail("expected a verification exception");
    146         } catch (Throwable t) {
    147             DxUtil.checkVerifyException(t);
    148         }
    149     }
    150 }
    151