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