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.aget_byte; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.aget_byte.d.T_aget_byte_1; 22 import dot.junit.opcodes.aget_byte.d.T_aget_byte_8; 23 24 25 public class Test_aget_byte extends DxTestCase { 26 /** 27 * @title get byte from array 28 */ testN1()29 public void testN1() { 30 T_aget_byte_1 t = new T_aget_byte_1(); 31 byte[] arr = new byte[2]; 32 arr[1] = 100; 33 assertEquals(100, t.run(arr, 1)); 34 } 35 36 /** 37 * @title get byte from array 38 */ testN2()39 public void testN2() { 40 T_aget_byte_1 t = new T_aget_byte_1(); 41 byte[] arr = new byte[2]; 42 arr[0] = 100; 43 assertEquals(100, t.run(arr, 0)); 44 } 45 46 /** 47 * @title expected ArrayIndexOutOfBoundsException 48 */ testE1()49 public void testE1() { 50 loadAndRun("dot.junit.opcodes.aget_byte.d.T_aget_byte_1", 51 ArrayIndexOutOfBoundsException.class, new byte[2], 2); 52 } 53 54 /** 55 * @title expected NullPointerException 56 */ testE2()57 public void testE2() { 58 loadAndRun("dot.junit.opcodes.aget_byte.d.T_aget_byte_1", NullPointerException.class, null, 59 2); 60 } 61 62 /** 63 * @title expected ArrayIndexOutOfBoundsException (negative index) 64 */ testE3()65 public void testE3() { 66 loadAndRun("dot.junit.opcodes.aget_byte.d.T_aget_byte_1", 67 ArrayIndexOutOfBoundsException.class, new byte[2], -1); 68 } 69 70 /** 71 * @constraint B1 72 * @title types of arguments - array, double 73 */ testVFE1()74 public void testVFE1() { 75 load("dot.junit.opcodes.aget_byte.d.T_aget_byte_2", VerifyError.class); 76 } 77 78 /** 79 * @constraint B1 80 * @title types of arguments - array, long 81 */ testVFE2()82 public void testVFE2() { 83 load("dot.junit.opcodes.aget_byte.d.T_aget_byte_3", VerifyError.class); 84 } 85 86 /** 87 * @constraint B1 88 * @title types of arguments - Object, short 89 */ testVFE3()90 public void testVFE3() { 91 load("dot.junit.opcodes.aget_byte.d.T_aget_byte_4", VerifyError.class); 92 } 93 94 /** 95 * @constraint B1 96 * @title types of arguments - double[], int 97 */ testVFE4()98 public void testVFE4() { 99 load("dot.junit.opcodes.aget_byte.d.T_aget_byte_5", VerifyError.class); 100 } 101 102 /** 103 * @constraint B1 104 * @title types of arguments - int[], int 105 */ testVFE5()106 public void testVFE5() { 107 load("dot.junit.opcodes.aget_byte.d.T_aget_byte_6", VerifyError.class); 108 } 109 110 /** 111 * @constraint B1 112 * @title types of arguments - array, reference 113 */ testVFE6()114 public void testVFE6() { 115 load("dot.junit.opcodes.aget_byte.d.T_aget_byte_7", VerifyError.class); 116 } 117 118 /** 119 * @constraint A23 120 * @title number of registers 121 */ testVFE7()122 public void testVFE7() { 123 load("dot.junit.opcodes.aget_byte.d.T_aget_byte_9", VerifyError.class); 124 } 125 126 /** 127 * @constraint B1 128 * @title Type of index argument - float. The verifier checks that ints 129 * and floats are not used interchangeably. 130 */ testVFE8()131 public void testVFE8() { 132 load("dot.junit.opcodes.aget_byte.d.T_aget_byte_8", VerifyError.class); 133 } 134 135 } 136