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