Search in sources :

Example 41 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestIfTryInCatch method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, countString(2, "try {"));
    assertThat(code, containsOne("if ("));
    assertThat(code, countString(2, "return f();"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) JadxMatchers.countString(jadx.tests.api.utils.JadxMatchers.countString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 42 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestSwitch2 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    //		assertThat(code, countString(4, "break;"));
    //		assertThat(code, countString(2, "return;"));
    // TODO: remove redundant break and returns
    assertThat(code, countString(5, "break;"));
    assertThat(code, countString(4, "return;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) JadxMatchers.countString(jadx.tests.api.utils.JadxMatchers.countString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 43 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestBreakInComplexIf method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsOne("if (tile == null || tile.y != 100) {"));
    assertThat(code, containsOne("break;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 44 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestBreakInComplexIf2 method testNoDebug.

@Test
public void testNoDebug() {
    noDebugInfo();
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, countString(2, "break;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) JadxMatchers.countString(jadx.tests.api.utils.JadxMatchers.countString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 45 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestBreakInLoop method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsOne("for (int i = 0; i < a.length; i++) {"));
    //		assertThat(code, containsOne("a[i]++;"));
    assertThat(code, containsOne("if (i < b) {"));
    assertThat(code, containsOne("break;"));
    assertThat(code, containsOne("this.f++;"));
    assertThat(code, countString(0, "else"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) JadxMatchers.countString(jadx.tests.api.utils.JadxMatchers.countString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Aggregations

ClassNode (jadx.core.dex.nodes.ClassNode)236 Test (org.junit.Test)201 IntegrationTest (jadx.tests.api.IntegrationTest)197 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)93 JadxMatchers.countString (jadx.tests.api.utils.JadxMatchers.countString)17 MethodNode (jadx.core.dex.nodes.MethodNode)12 FieldNode (jadx.core.dex.nodes.FieldNode)10 Matchers.containsString (org.hamcrest.Matchers.containsString)10 ConstClassNode (jadx.core.dex.instructions.ConstClassNode)7 InsnNode (jadx.core.dex.nodes.InsnNode)7 ClassInfo (jadx.core.dex.info.ClassInfo)6 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)6 DexNode (jadx.core.dex.nodes.DexNode)5 InsnArg (jadx.core.dex.instructions.args.InsnArg)4 ConstructorInsn (jadx.core.dex.instructions.mods.ConstructorInsn)4 SmaliTest (jadx.tests.api.SmaliTest)4 ArrayList (java.util.ArrayList)4 FieldReplaceAttr (jadx.core.dex.attributes.nodes.FieldReplaceAttr)3 FieldInfo (jadx.core.dex.info.FieldInfo)3 MethodInfo (jadx.core.dex.info.MethodInfo)3