Package jadx.tests.integration.switches

Source Code of jadx.tests.integration.switches.TestSwitchLabels$TestCls$Inner

package jadx.tests.integration.switches;

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

import org.junit.Test;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;

public class TestSwitchLabels extends IntegrationTest {
  public static class TestCls {
    public static final int CONST_ABC = 0xABC;
    public static final int CONST_CDE = 0xCDE;

    public static class Inner {
      private static final int CONST_CDE_PRIVATE = 0xCDE;

      public int f1(int arg0) {
        switch (arg0) {
          case CONST_CDE_PRIVATE:
            return CONST_ABC;
        }
        return 0;
      }
    }

    public static int f1(int arg0) {
      switch (arg0) {
        case CONST_ABC:
          return CONST_CDE;
      }
      return 0;
    }
  }

  @Test
  public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsString("case CONST_ABC:"));
    assertThat(code, containsString("return CONST_CDE;"));

    cls.addInnerClass(getClassNode(TestCls.Inner.class));
    assertThat(code, containsString("case CONST_CDE_PRIVATE:"));
    assertThat(code, containsString(".CONST_ABC;"));
  }
}
TOP

Related Classes of jadx.tests.integration.switches.TestSwitchLabels$TestCls$Inner

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.