Package jadx.tests.integration

Source Code of jadx.tests.integration.TestWrongCode$TestCls

package jadx.tests.integration;

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 TestWrongCode extends IntegrationTest {

  public static class TestCls {
    private int test() {
      int[] a = null;
      return a.length;
    }

    @SuppressWarnings("empty")
    private int test2(int a) {
      if (a == 0) {
        ;
      }
      return a;
    }
  }

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

    assertThat(code, not(containsString("return false.length;")));
    assertThat(code, containsOne("int[] a = null;"));
    assertThat(code, containsOne("return a.length;"));

    assertThat(code, containsString("return a == 0 ? a : a;"));
  }

  @Test
  public void testNoDebug() {
    noDebugInfo();
    getClassNode(TestCls.class);
  }
}
TOP

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