Package jadx.tests.integration.loops

Source Code of jadx.tests.integration.loops.TestIterableForEach

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.containsLines;
import static org.junit.Assert.assertThat;

public class TestIterableForEach extends IntegrationTest {

  public static class TestCls {
    private String test(Iterable<String> a) {
      StringBuilder sb = new StringBuilder();
      for (String s : a) {
        sb.append(s);
      }
      return sb.toString();
    }
  }

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

    assertThat(code, containsLines(2,
        "StringBuilder sb = new StringBuilder();",
        "for (String s : a) {",
        indent(1) + "sb.append(s);",
        "}",
        "return sb.toString();"
    ));
  }
}
TOP

Related Classes of jadx.tests.integration.loops.TestIterableForEach

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.