Package jadx.tests.integration.loops

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

package jadx.tests.integration.loops;

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

import java.util.Iterator;

import org.junit.Test;

import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.junit.Assert.assertThat;

public class TestLoopDetection4 extends IntegrationTest {

  public static class TestCls {
    private Iterator<String> iterator;
    private SomeCls filter;

    private String test() {
      while (iterator.hasNext()) {
        String next = iterator.next();
        String filtered = filter.filter(next);
        if (filtered != null) {
          return filtered;
        }
      }
      return null;
    }

    private class SomeCls {
      public String filter(String str) {
        return str;
      }
    }
  }

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

    assertThat(code, containsOne("while (this.iterator.hasNext()) {"));
    assertThat(code, containsOne("if (filtered != null) {"));
    assertThat(code, containsOne("return filtered;"));
    assertThat(code, containsOne("return null;"));
  }
}
TOP

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