()
| 219 | } |
| 220 | |
| 221 | public void testBoundsChecking() throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { |
| 222 | // Test the bounds checking of the Memory#read invocations |
| 223 | testBoundsCheckArray(byte.class, 1); |
| 224 | testBoundsCheckArray(char.class, Native.WCHAR_SIZE); |
| 225 | testBoundsCheckArray(short.class, 2); |
| 226 | testBoundsCheckArray(int.class, 4); |
| 227 | testBoundsCheckArray(long.class, 8); |
| 228 | testBoundsCheckArray(float.class, 4); |
| 229 | testBoundsCheckArray(double.class, 8); |
| 230 | testBoundsCheckArray(Pointer.class, Native.POINTER_SIZE); |
| 231 | // Test the bounds checking of the Memory#get* / Memory#set* methods |
| 232 | testBoundsCheckSingleValue(byte.class, "Byte", 1, (byte) 42); |
| 233 | testBoundsCheckSingleValue(char.class, "Char", Native.WCHAR_SIZE, 'x'); |
| 234 | testBoundsCheckSingleValue(short.class, "Short", 2, (short) 42); |
| 235 | testBoundsCheckSingleValue(int.class, "Int", 4, 42); |
| 236 | testBoundsCheckSingleValue(long.class, "Long", 8, 42L); |
| 237 | testBoundsCheckSingleValue(float.class, "Float", 4, 42f); |
| 238 | testBoundsCheckSingleValue(double.class, "Double", 8, 42d); |
| 239 | testBoundsCheckSingleValue(Pointer.class, "Pointer", Native.POINTER_SIZE, Pointer.createConstant(42L)); |
| 240 | } |
| 241 | |
| 242 | private void testBoundsCheckSingleValue(Class clazz, String name, int elementSize, Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { |
| 243 | Method readMethod = Memory.class.getMethod("get" + name, new Class[]{long.class}); |
nothing calls this directly
no test coverage detected