TypeEncoder { public String encode(SootMethod method, boolean is64bit) { StringBuilder sb = new StringBuilder(); sb.append(encodeOne(method, method.getReturnType(), -1, is64bit)); for (int i = 0; i < method.getParameterCount(); i++) { sb.append(encodeOne(method, method.getParameterType(i), i, is64bit)); } return sb.toString(); }  String encode(SootMethod method, boolean is64bit); static final String SELECTOR; static final String OBJC_CLASS; static final String OBJC_BLOCK; }
@Test public void testVoidReturnTypeNoParameters() { assertEquals("v", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m1"), false)); }
@Test public void testSimplePrimitiveTypes() { assertEquals("ccsSiqfd", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m2"), false)); assertEquals("ccsSiqfd", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m2"), true)); }
@Test public void testArchDependentPrimitiveTypes() { assertEquals("^v^viIff", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m3"), false)); assertEquals("^v^vqQdd", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m3"), true)); }
@Test public void testSimpleStructTypes() { assertEquals("^v{?=ii}{?=ff}", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m4"), false)); assertEquals("^v{?=ii}{?=dd}", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m4"), true)); }
@Test public void testNestedStructTypes() { assertEquals("v{?={?=ff}{?=ff}}", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m5"), false)); assertEquals("v{?={?=dd}{?=dd}}", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m5"), true)); }
@Test public void testUnionTypes() { assertEquals("v(?=i{?=ff})", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m6"), false)); assertEquals("v(?=i{?=dd})", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m6"), true)); }
@Test public void testObjectType() { assertEquals("@@", new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m7"), false)); }
@Test public void testArrayInStructTypeFails1() { try { new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m8"), false); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } }
@Test public void testArrayInStructTypeFails2() { try { new TypeEncoder().encode(toSootClass(Methods.class).getMethodByName("m9"), false); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } }