()
| 206 | } |
| 207 | |
| 208 | public void testOpaquePointer() throws Exception { |
| 209 | Pointer p = Pointer.createConstant(0); |
| 210 | Class<?> cls = p.getClass(); |
| 211 | Method[] methods = cls.getMethods(); |
| 212 | for (int i=0;i < methods.length;i++) { |
| 213 | Method m = methods[i]; |
| 214 | Class<?>[] argTypes = m.getParameterTypes(); |
| 215 | try { |
| 216 | Object[] args = new Object[argTypes.length]; |
| 217 | for (int arg=0;arg < args.length;arg++) { |
| 218 | args[arg] = defaultArg(argTypes[arg]); |
| 219 | } |
| 220 | if ("hashCode".equals(m.getName()) |
| 221 | || "equals".equals(m.getName()) |
| 222 | || m.getDeclaringClass() == Object.class |
| 223 | || (m.getModifiers() & Modifier.STATIC) != 0) { |
| 224 | continue; |
| 225 | } |
| 226 | Object result = m.invoke(p, args); |
| 227 | if ("toString".equals(m.getName())) { |
| 228 | assertTrue("toString() should indicate const-ness", ((String)result).indexOf("const") != -1); |
| 229 | continue; |
| 230 | } |
| 231 | fail("Method '" + m.getName() + "(" + Arrays.asList(argTypes) + ")' should throw UnsupportedOperationException"); |
| 232 | } |
| 233 | catch(InvocationTargetException e) { |
| 234 | assertEquals("Wrong exception type thrown by '" + m.getName() + "(" + Arrays.asList(argTypes) + ")", UnsupportedOperationException.class, e.getTargetException().getClass()); |
| 235 | } |
| 236 | catch(IllegalArgumentException e) { |
| 237 | fail("Need to fix test of method '" + m.getName() + "(" + Arrays.asList(argTypes) + ")'"); |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | public static void main(String[] args) { |
| 243 | junit.textui.TestRunner.run(PointerTest.class); |
nothing calls this directly
no test coverage detected