-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: convert inner enums and fix inner classes reference (#719)
- Loading branch information
Showing
3 changed files
with
107 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
jadx-core/src/test/java/jadx/tests/integration/enums/TestInnerEnums.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package jadx.tests.integration.enums; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.JadxMatchers.containsOne; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TestInnerEnums extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
|
||
public enum Numbers { | ||
ONE(1, NumString.ONE), TWO(2, NumString.TWO); | ||
|
||
private final int num; | ||
private final NumString str; | ||
|
||
public enum NumString { | ||
ONE("one"), TWO("two"); | ||
|
||
private final String name; | ||
|
||
NumString(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} | ||
|
||
Numbers(int n, NumString str) { | ||
this.num = n; | ||
this.str = str; | ||
} | ||
|
||
public int getNum() { | ||
return num; | ||
} | ||
|
||
public NumString getNumStr() { | ||
return str; | ||
} | ||
|
||
public String getName() { | ||
return str.getName(); | ||
} | ||
} | ||
|
||
public void check() { | ||
assertEquals(1, Numbers.ONE.getNum()); | ||
assertEquals(Numbers.NumString.ONE, Numbers.ONE.getNumStr()); | ||
assertEquals("one", Numbers.ONE.getName()); | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("ONE(1, NumString.ONE)")); | ||
assertThat(code, containsOne("ONE(\"one\")")); | ||
} | ||
} |