Package jadx.tests.integration.loops

Source Code of jadx.tests.integration.loops.TestLoopConditionInvoke$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.junit.Assert.assertThat;

public class TestLoopConditionInvoke extends IntegrationTest {

  public static class TestCls {
    private static final char STOP_CHAR = 0;
    private int pos;

    private boolean test(char lastChar) {
      int startPos = pos;
      char ch;
      while ((ch = next()) != STOP_CHAR) {
        if (ch == lastChar) {
          return true;
        }
      }
      pos = startPos;
      return false;
    }

    private char next() {
      return 0;
    }
  }

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

    assertThat(code, containsOne("do {"));
    assertThat(code, containsOne("if (ch == '\\u0000') {"));
    assertThat(code, containsOne("this.pos = startPos;"));
    assertThat(code, containsOne("return false;"));
    assertThat(code, containsOne("} while (ch != lastChar);"));
    assertThat(code, containsOne("return true;"));
  }
}
TOP

Related Classes of jadx.tests.integration.loops.TestLoopConditionInvoke$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.