Add jadx-gui, restructure src directory
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package jadx.tests;
|
||||
|
||||
import jadx.core.utils.StringUtils;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class StringUtilsTest extends TestCase {
|
||||
|
||||
public void testUnescape() {
|
||||
unescapeTest("\n", "\\n");
|
||||
unescapeTest("\t", "\\t");
|
||||
unescapeTest("\r", "\\r");
|
||||
unescapeTest("\b", "\\b");
|
||||
unescapeTest("\f", "\\f");
|
||||
unescapeTest("\\", "\\\\");
|
||||
unescapeTest("\"", "\\\"");
|
||||
unescapeTest("'", "'");
|
||||
|
||||
unescapeTest("\u1234", "\\u1234");
|
||||
|
||||
unescapeCharTest('\'', "'\\\''");
|
||||
}
|
||||
|
||||
private void unescapeTest(String input, String expected) {
|
||||
assertEquals("\"" + expected + "\"", StringUtils.unescapeString(input));
|
||||
}
|
||||
|
||||
private void unescapeCharTest(char input, String expected) {
|
||||
assertEquals(expected, StringUtils.unescapeChar(input));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package jadx.tests;
|
||||
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.core.dex.instructions.args.PrimitiveType;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import static jadx.core.dex.instructions.args.ArgType.BOOLEAN;
|
||||
import static jadx.core.dex.instructions.args.ArgType.CHAR;
|
||||
import static jadx.core.dex.instructions.args.ArgType.INT;
|
||||
import static jadx.core.dex.instructions.args.ArgType.LONG;
|
||||
import static jadx.core.dex.instructions.args.ArgType.NARROW;
|
||||
import static jadx.core.dex.instructions.args.ArgType.OBJECT;
|
||||
import static jadx.core.dex.instructions.args.ArgType.UNKNOWN;
|
||||
import static jadx.core.dex.instructions.args.ArgType.UNKNOWN_OBJECT;
|
||||
import static jadx.core.dex.instructions.args.ArgType.object;
|
||||
import static jadx.core.dex.instructions.args.ArgType.unknown;
|
||||
|
||||
public class TypeMergeTest extends TestCase {
|
||||
|
||||
public void testMerge() {
|
||||
first(INT, INT);
|
||||
first(BOOLEAN, INT);
|
||||
reject(INT, LONG);
|
||||
first(INT, UNKNOWN);
|
||||
reject(INT, UNKNOWN_OBJECT);
|
||||
|
||||
first(INT, NARROW);
|
||||
first(CHAR, INT);
|
||||
|
||||
merge(unknown(PrimitiveType.INT, PrimitiveType.BOOLEAN, PrimitiveType.FLOAT),
|
||||
unknown(PrimitiveType.INT, PrimitiveType.BOOLEAN),
|
||||
unknown(PrimitiveType.INT, PrimitiveType.BOOLEAN));
|
||||
|
||||
merge(unknown(PrimitiveType.INT, PrimitiveType.FLOAT),
|
||||
unknown(PrimitiveType.INT, PrimitiveType.BOOLEAN),
|
||||
INT);
|
||||
|
||||
merge(unknown(PrimitiveType.INT, PrimitiveType.OBJECT),
|
||||
unknown(PrimitiveType.OBJECT, PrimitiveType.ARRAY),
|
||||
unknown(PrimitiveType.OBJECT));
|
||||
|
||||
first(object("Lsomeobj;"), object("Lsomeobj;"));
|
||||
merge(object("Lsomeobj;"), object("Lotherobj;"), null);
|
||||
first(object("Lsomeobj;"), OBJECT);
|
||||
}
|
||||
|
||||
private void first(ArgType t1, ArgType t2) {
|
||||
check(t1, t2, t1);
|
||||
}
|
||||
|
||||
private void reject(ArgType t1, ArgType t2) {
|
||||
check(t1, t2, null);
|
||||
}
|
||||
|
||||
private void check(ArgType t1, ArgType t2, ArgType exp) {
|
||||
merge(t1, t2, exp);
|
||||
merge(t2, t1, exp);
|
||||
}
|
||||
|
||||
private void merge(ArgType t1, ArgType t2, ArgType exp) {
|
||||
ArgType res = ArgType.merge(t1, t2);
|
||||
String msg = format(t1, t2, exp, res);
|
||||
if (exp == null) {
|
||||
assertNull("Incorrect accept: " + msg, res);
|
||||
} else {
|
||||
assertNotNull("Incorrect reject: " + msg, res);
|
||||
assertTrue("Incorrect result: " + msg, exp.equals(res));
|
||||
}
|
||||
}
|
||||
|
||||
private String format(ArgType t1, ArgType t2, ArgType exp, ArgType res) {
|
||||
return t1 + " <+> " + t2 + " = '" + res + "', expected: " + exp;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user