Package jadx.tests.integration.loops

Source Code of jadx.tests.integration.loops.TestLoopDetection2$TestCls

package jadx.tests.integration.loops;

import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;

import org.junit.Test;

import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;

public class TestLoopDetection2 extends IntegrationTest {

  public static class TestCls {

    public int test(int a, int b) {
      int c = a + b;
      for (int i = a; i < b; i++) {
        if (i == 7) {
          c += 2;
        } else {
          c *= 2;
        }
      }
      c--;
      return c;
    }
  }

  @Test
  public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();

    assertThat(code, containsOne("int c = a + b;"));
    assertThat(code, containsOne("for (int i = a; i < b; i++) {"));
    assertThat(code, not(containsString("c_2")));
  }
}
TOP

Related Classes of jadx.tests.integration.loops.TestLoopDetection2$TestCls

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.