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 dot.junit.opcodes.or_int_lit8; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_1; 22 import dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_2; 23 import dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_3; 24 import dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_4; 25 import dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_5; 26 27 public class Test_or_int_lit8 extends DxTestCase { 28 29 /** 30 * @title Arguments = 15, 8 31 */ testN1()32 public void testN1() { 33 T_or_int_lit8_1 t = new T_or_int_lit8_1(); 34 assertEquals(15, t.run(15)); 35 } 36 37 /** 38 * @title Arguments = 0x5f, 0x7f 39 */ testN2()40 public void testN2() { 41 T_or_int_lit8_2 t = new T_or_int_lit8_2(); 42 assertEquals(0x7f, t.run(0x5f)); 43 } 44 45 /** 46 * @title Arguments = 0xcafe & -1 47 */ testN3()48 public void testN3() { 49 T_or_int_lit8_3 t = new T_or_int_lit8_3(); 50 assertEquals(-1, t.run(0xcaf)); 51 } 52 53 /** 54 * @title Types of arguments - float, int. Dalvik doens't distinguish 32-bits types internally, 55 * so this operation of float and int makes no sense but shall not crash the VM. 56 */ testN4()57 public void testN4() { 58 T_or_int_lit8_4 t = new T_or_int_lit8_4(); 59 try { 60 t.run(3.14f); 61 } catch (Throwable e) { 62 } 63 } 64 65 /** 66 * @title Arguments = 0 & -1 67 */ testB1()68 public void testB1() { 69 T_or_int_lit8_3 t = new T_or_int_lit8_3(); 70 assertEquals(-1, t.run(0)); 71 } 72 73 /** 74 * @title Arguments = Short.MAX_VALUE & Short.MIN_VALUE 75 */ testB2()76 public void testB2() { 77 T_or_int_lit8_5 t = new T_or_int_lit8_5(); 78 assertEquals(0xffffffff, t.run(Byte.MIN_VALUE)); 79 } 80 81 /** 82 * @constraint A23 83 * @title number of registers 84 */ testVFE1()85 public void testVFE1() { 86 try { 87 Class.forName("dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_6"); 88 fail("expected a verification exception"); 89 } catch (Throwable t) { 90 DxUtil.checkVerifyException(t); 91 } 92 } 93 94 95 96 /** 97 * @constraint B1 98 * @title types of arguments - double & int 99 */ testVFE2()100 public void testVFE2() { 101 try { 102 Class.forName("dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_7"); 103 fail("expected a verification exception"); 104 } catch (Throwable t) { 105 DxUtil.checkVerifyException(t); 106 } 107 } 108 109 /** 110 * @constraint B1 111 * @title types of arguments - long & int 112 */ testVFE3()113 public void testVFE3() { 114 try { 115 Class.forName("dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_8"); 116 fail("expected a verification exception"); 117 } catch (Throwable t) { 118 DxUtil.checkVerifyException(t); 119 } 120 } 121 122 /** 123 * @constraint B1 124 * @title types of arguments - reference & int 125 */ testVFE4()126 public void testVFE4() { 127 try { 128 Class.forName("dot.junit.opcodes.or_int_lit8.d.T_or_int_lit8_9"); 129 fail("expected a verification exception"); 130 } catch (Throwable t) { 131 DxUtil.checkVerifyException(t); 132 } 133 } 134 } 135