diff --git a/jadx-core/src/test/java/jadx/tests/StringUtilsTest.java b/jadx-core/src/test/java/jadx/tests/StringUtilsTest.java index 05f2676adbeaf679fabdfb6fb1116be9b1b3fcb8..1bd53fcb80f24957610ff716ee9513b1047c1606 100644 --- a/jadx-core/src/test/java/jadx/tests/StringUtilsTest.java +++ b/jadx-core/src/test/java/jadx/tests/StringUtilsTest.java @@ -1,10 +1,14 @@ package jadx.tests; import jadx.core.utils.StringUtils; -import junit.framework.TestCase; -public class StringUtilsTest extends TestCase { +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +public class StringUtilsTest { + + @Test public void testUnescape() { unescapeTest("\n", "\\n"); unescapeTest("\t", "\\t"); diff --git a/jadx-core/src/test/java/jadx/tests/TypeMergeTest.java b/jadx-core/src/test/java/jadx/tests/TypeMergeTest.java index 7554e231db4b67502eed229d71c1584cc7b5ed36..d90f02fa66e4269163e1e74009bfa4584e755ddd 100644 --- a/jadx-core/src/test/java/jadx/tests/TypeMergeTest.java +++ b/jadx-core/src/test/java/jadx/tests/TypeMergeTest.java @@ -4,10 +4,12 @@ import jadx.core.clsp.ClspGraph; import jadx.core.dex.instructions.args.ArgType; import jadx.core.dex.instructions.args.PrimitiveType; import jadx.core.utils.exceptions.DecodeException; -import junit.framework.TestCase; import java.io.IOException; +import org.junit.Before; +import org.junit.Test; + 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; @@ -19,18 +21,21 @@ import static jadx.core.dex.instructions.args.ArgType.UNKNOWN_OBJECT; import static jadx.core.dex.instructions.args.ArgType.genericType; import static jadx.core.dex.instructions.args.ArgType.object; import static jadx.core.dex.instructions.args.ArgType.unknown; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; -public class TypeMergeTest extends TestCase { +public class TypeMergeTest { - private void initClsp() throws IOException, DecodeException { + @Before + public void initClsp() throws IOException, DecodeException { ClspGraph clsp = new ClspGraph(); clsp.load(); ArgType.setClsp(clsp); } + @Test public void testMerge() throws IOException, DecodeException { - initClsp(); - first(INT, INT); first(BOOLEAN, INT); reject(INT, LONG); diff --git a/jadx-samples/src/main/java/jadx/samples/TestEnum.java b/jadx-samples/src/main/java/jadx/samples/TestEnum.java index de811f4b6c033982acf613592ff68f0fef08aa87..b469e58c1a32019546f64b5b2cc06321d915e028 100644 --- a/jadx-samples/src/main/java/jadx/samples/TestEnum.java +++ b/jadx-samples/src/main/java/jadx/samples/TestEnum.java @@ -9,7 +9,7 @@ public class TestEnum extends AbstractTest { public enum Direction { NORTH, SOUTH, EAST, WEST - }; + } private static int three = 3; @@ -25,7 +25,7 @@ public class TestEnum extends AbstractTest { public int getNum() { return num; } - }; + } public enum Operation { PLUS { @@ -101,11 +101,28 @@ public class TestEnum extends AbstractTest { public enum Singleton { INSTANCE; + public String test(String arg) { return arg.concat("test"); } } + public String testEnumSwitch(final Direction color) { + String d; + switch (color) { + case NORTH: + d = "N"; + break; + case SOUTH: + d = "S"; + break; + default: + d = "<>"; + break; + } + return d; + } + @Override public boolean testRun() throws Exception { Direction d = Direction.EAST; diff --git a/jadx-samples/src/main/java/jadx/samples/TestInvoke.java b/jadx-samples/src/main/java/jadx/samples/TestInvoke.java index 32ca1d88f2b08d328982732843b44690cb00f3c5..f6abf674b7c3e62bac101b033689b59c64fd6a92 100644 --- a/jadx-samples/src/main/java/jadx/samples/TestInvoke.java +++ b/jadx-samples/src/main/java/jadx/samples/TestInvoke.java @@ -37,15 +37,6 @@ public class TestInvoke extends AbstractTest { return s; } - /* TODO - public TestInvoke testConstructor(int flag) { - if (getF() == flag) - return new TestInvoke(flag); - else - return this; - } - */ - @Override public boolean testRun() throws Exception { TestInvoke inv = new TestInvoke(); @@ -58,7 +49,6 @@ public class TestInvoke extends AbstractTest { assertTrue(inv.testVarArgs("a", "2", "III")); assertTrue(inv.testVarArgs2("a".toCharArray(), new char[] { '1', '2' }).equals("a12")); - // assertTrue(testConstructor(f) != this); return true; }