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 dxc.junit.opcodes.dastore; 18 19 import dxc.junit.DxTestCase; 20 import dxc.junit.DxUtil; 21 import dxc.junit.opcodes.dastore.jm.T_dastore_1; 22 23 public class Test_dastore extends DxTestCase { 24 25 /** 26 * @title normal test. Trying different indexes 27 */ 28 public void testN1() { 29 T_dastore_1 t = new T_dastore_1(); 30 double[] arr = new double[2]; 31 t.run(arr, 1, 2.7d); 32 assertEquals(2.7d, arr[1]); 33 } 34 35 /** 36 * @title normal test. Trying different indexes 37 */ 38 public void testN2() { 39 T_dastore_1 t = new T_dastore_1(); 40 double[] arr = new double[2]; 41 t.run(arr, 0, 2.7d); 42 assertEquals(2.7d, arr[0]); 43 } 44 45 /** 46 * @title expected ArrayIndexOutOfBoundsException 47 */ 48 public void testE1() { 49 T_dastore_1 t = new T_dastore_1(); 50 double[] arr = new double[2]; 51 try { 52 t.run(arr, 2, 2.7d); 53 fail("expected ArrayIndexOutOfBoundsException"); 54 } catch (ArrayIndexOutOfBoundsException aie) { 55 // expected 56 } 57 } 58 59 /** 60 * @title expected NullPointerException 61 */ 62 public void testE2() { 63 T_dastore_1 t = new T_dastore_1(); 64 try { 65 t.run(null, 2, 2.7d); 66 fail("expected NullPointerException"); 67 } catch (NullPointerException aie) { 68 // expected 69 } 70 } 71 72 /** 73 * @title expected ArrayIndexOutOfBoundsException 74 */ 75 public void testE3() { 76 T_dastore_1 t = new T_dastore_1(); 77 double[] arr = new double[2]; 78 try { 79 t.run(arr, -1, 2.7d); 80 fail("expected ArrayIndexOutOfBoundsException"); 81 } catch (ArrayIndexOutOfBoundsException aie) { 82 // expected 83 } 84 } 85 86 /** 87 * @constraint 4.8.2.1 88 * @title number of arguments 89 */ 90 public void testVFE1() { 91 try { 92 Class.forName("dxc.junit.opcodes.dastore.jm.T_dastore_2"); 93 fail("expected a verification exception"); 94 } catch (Throwable t) { 95 DxUtil.checkVerifyException(t); 96 } 97 } 98 99 /** 100 * @constraint 4.8.2.1 101 * @title number of arguments 102 */ 103 public void testVFE2() { 104 try { 105 Class.forName("dxc.junit.opcodes.dastore.jm.T_dastore_3"); 106 fail("expected a verification exception"); 107 } catch (Throwable t) { 108 DxUtil.checkVerifyException(t); 109 } 110 } 111 112 /** 113 * @constraint 4.8.2.1 114 * @title types of arguments - array, double, 115 * double 116 */ 117 public void testVFE3() { 118 try { 119 Class.forName("dxc.junit.opcodes.dastore.jm.T_dastore_4"); 120 fail("expected a verification exception"); 121 } catch (Throwable t) { 122 DxUtil.checkVerifyException(t); 123 } 124 } 125 126 /** 127 * @constraint 4.8.2.1 128 * @title types of arguments - array, int, long 129 */ 130 public void testVFE4() { 131 try { 132 Class.forName("dxc.junit.opcodes.dastore.jm.T_dastore_5"); 133 fail("expected a verification exception"); 134 } catch (Throwable t) { 135 DxUtil.checkVerifyException(t); 136 } 137 } 138 139 /** 140 * @constraint 4.8.2.1 141 * @title types of arguments - object, int, 142 * double 143 */ 144 public void testVFE5() { 145 try { 146 Class.forName("dxc.junit.opcodes.dastore.jm.T_dastore_6"); 147 fail("expected a verification exception"); 148 } catch (Throwable t) { 149 DxUtil.checkVerifyException(t); 150 } 151 } 152 153 /** 154 * @constraint 4.8.2.1 155 * @title types of arguments - float[], int, 156 * double 157 */ 158 public void testVFE6() { 159 try { 160 Class.forName("dxc.junit.opcodes.dastore.jm.T_dastore_7"); 161 fail("expected a verification exception"); 162 } catch (Throwable t) { 163 DxUtil.checkVerifyException(t); 164 } 165 } 166 167 /** 168 * @constraint 4.8.2.1 169 * @title types of arguments - long[], int, 170 * double 171 */ 172 public void testVFE7() { 173 try { 174 Class.forName("dxc.junit.opcodes.dastore.jm.T_dastore_8"); 175 fail("expected a verification exception"); 176 } catch (Throwable t) { 177 DxUtil.checkVerifyException(t); 178 } 179 } 180 181 /** 182 * @constraint 4.8.2.1 183 * @title types of arguments - array, reference, 184 * double 185 */ 186 public void testVFE8() { 187 try { 188 Class.forName("dxc.junit.opcodes.dastore.jm.T_dastore_9"); 189 fail("expected a verification exception"); 190 } catch (Throwable t) { 191 DxUtil.checkVerifyException(t); 192 } 193 } 194 195 } 196