Skip to content

Commit

Permalink
added array creation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauma109 committed Dec 14, 2022
1 parent 0fffa71 commit 5b75eb7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
21 changes: 21 additions & 0 deletions src/test/java/jd/core/test/ArrayCreation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package jd.core.test;
/*
* Test input built from Procyon's wiki page:
* https://github.com/mstrobel/procyon/wiki/Decompiler-Output-Comparison.
*/
public class ArrayCreation {
public int[] arrayCreation(final boolean initialize) {
if (initialize) {
return new int[] { 1, 2, 3 };
}
return new int[3];
}

public int[][] jaggedArrayInitialization() {
return new int[][] { { 1, 2, 3 }, { 4, 5, 6 } };
}

public int[][] multiDimensionalArrayCreation() {
return new int[3][2];
}
}
18 changes: 18 additions & 0 deletions src/test/java/jd/core/test/ArrayCreationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package jd.core.test;

import org.apache.commons.io.IOUtils;
import org.junit.Test;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import static org.junit.Assert.assertEquals;

public class ArrayCreationTest extends AbstractTestCase {

@Test
public void test() throws IOException {
String output = decompile("jd/core/test/ArrayCreation");
assertEquals(IOUtils.toString(getClass().getResource("ArrayCreation.txt"), StandardCharsets.UTF_8), output);
}
}
5 changes: 0 additions & 5 deletions src/test/java/jd/core/test/ToArrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,4 @@ public void test() throws IOException {
String output = decompile("jd/core/test/ToArray");
assertEquals(IOUtils.toString(getClass().getResource("ToArray.txt"), StandardCharsets.UTF_8), output);
}

@Override
protected boolean showDefaultConstructor() {
return false;
}
}
21 changes: 21 additions & 0 deletions src/test/resources/jd/core/test/ArrayCreation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* */ package jd.core.test;
/* */
/* */
/* */ public class ArrayCreation
/* */ {
/* */ public int[] arrayCreation(boolean initialize)
/* */ {
/* 8 */ if (initialize) {
/* 9 */ return new int[] { 1, 2, 3 };
/* */ }
/* 11 */ return new int[3];
/* */ }
/* */
/* */ public int[][] jaggedArrayInitialization() {
/* 15 */ return new int[][] { { 1, 2, 3 }, { 4, 5, 6 } };
/* */ }
/* */
/* */ public int[][] multiDimensionalArrayCreation() {
/* 19 */ return new int[3][2];
/* */ }
/* */ }

0 comments on commit 5b75eb7

Please sign in to comment.