forked from FabricMC/unpick
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
84 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies { | ||
testImplementation(libs.junit) | ||
} |
59 changes: 59 additions & 0 deletions
59
unpick-format-utils/src/test/java/daomephsta/unpick/tests/TestV2Reader.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,59 @@ | ||
package daomephsta.unpick.tests; | ||
|
||
import daomephsta.unpick.constantmappers.datadriven.parser.UnpickSyntaxException; | ||
import daomephsta.unpick.constantmappers.datadriven.parser.v2.UnpickV2Reader; | ||
import daomephsta.unpick.constantmappers.datadriven.parser.v2.UnpickV2Writer; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class TestV2Reader { | ||
private final Path missingHeader; | ||
private final Path validSyntax; | ||
private final Path invalidKeyword; | ||
|
||
public TestV2Reader() throws URISyntaxException { | ||
Path dir = getResource("/v2_test_files"); | ||
missingHeader = dir.resolve("missing_header.unpick"); | ||
validSyntax = dir.resolve("valid_syntax.unpick"); | ||
invalidKeyword = dir.resolve("invalid_keyword.unpick"); | ||
} | ||
|
||
private static Path getResource(String name) throws URISyntaxException { | ||
return Paths.get(TestV2Reader.class.getResource(name).toURI()); | ||
} | ||
|
||
@Test | ||
void testValidRead() throws IOException { | ||
File file = validSyntax.toFile(); | ||
|
||
try (UnpickV2Reader reader = new UnpickV2Reader(Files.newInputStream(file.toPath()))) { | ||
reader.accept(new UnpickV2Writer()); | ||
} | ||
} | ||
|
||
@Test | ||
void testMissingHeader() throws IOException { | ||
File file = missingHeader.toFile(); | ||
|
||
try (UnpickV2Reader reader = new UnpickV2Reader(Files.newInputStream(file.toPath()))) { | ||
assertThrows(UnpickSyntaxException.class, () -> reader.accept(new UnpickV2Writer())); | ||
} | ||
} | ||
|
||
@Test | ||
void testInvalidKeyword() throws IOException { | ||
File file = invalidKeyword.toFile(); | ||
|
||
try (UnpickV2Reader reader = new UnpickV2Reader(Files.newInputStream(file.toPath()))) { | ||
assertThrows(UnpickSyntaxException.class, () -> reader.accept(new UnpickV2Writer())); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
unpick-format-utils/src/test/resources/v2_test_files/invalid_keyword.unpick
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,7 @@ | ||
v2 | ||
|
||
gaming flag org/quiltmc/Gaming GAMING | ||
gaming flag org/quiltmc/Gaming NOT_GAMING | ||
|
||
target_method org/quiltmc/Gaming getFlag (I)Z | ||
param 0 flag |
5 changes: 5 additions & 0 deletions
5
unpick-format-utils/src/test/resources/v2_test_files/missing_header.unpick
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,5 @@ | ||
constant flag org/quiltmc/Gaming GAMING | ||
constant flag org/quiltmc/Gaming NOT_GAMING | ||
|
||
target_method org/quiltmc/Gaming getFlag (I)Z | ||
param 0 flag |
7 changes: 7 additions & 0 deletions
7
unpick-format-utils/src/test/resources/v2_test_files/valid_syntax.unpick
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,7 @@ | ||
v2 | ||
|
||
constant flag org/quiltmc/Gaming GAMING | ||
constant flag org/quiltmc/Gaming NOT_GAMING | ||
|
||
target_method org/quiltmc/Gaming getFlag (I)Z | ||
param 0 flag |