-
Notifications
You must be signed in to change notification settings - Fork 25
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
1 parent
948b752
commit ce7ed95
Showing
13 changed files
with
561 additions
and
6 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
68 changes: 68 additions & 0 deletions
68
common/src/test/java/io/github/amerebagatelle/mods/nuit/skybox/AnimatableTextureTest.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,68 @@ | ||
package io.github.amerebagatelle.mods.nuit.skybox; | ||
|
||
import com.mojang.serialization.JsonOps; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class AnimatableTextureTest { | ||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
""" | ||
{ | ||
"texture": "test:resourcelocation" | ||
} | ||
""", | ||
""" | ||
{ | ||
"texture": "test:resourcelocation", | ||
"gridColumns": 1 | ||
} | ||
""", | ||
""" | ||
{ | ||
"texture": "test:resourcelocation", | ||
"gridRows": 1 | ||
} | ||
""", | ||
""" | ||
{ | ||
"texture": "test:resourcelocation", | ||
"duration": 1 | ||
} | ||
""", | ||
""" | ||
{ | ||
"texture": "test:resourcelocation", | ||
"interpolate": true | ||
} | ||
""", | ||
""" | ||
{ | ||
"texture": "test:resourcelocation", | ||
"frameDuration": { | ||
"1": 10, | ||
"2": 20 | ||
} | ||
} | ||
""" | ||
}) | ||
public void testCorrectParse(String json) { | ||
var jsonOb = JsonTestHelper.readJson(json); | ||
assertDoesNotThrow(() -> AnimatableTexture.CODEC.decode(JsonOps.INSTANCE, jsonOb).getOrThrow().getFirst()); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
""" | ||
{ | ||
} | ||
""", | ||
}) | ||
public void testIncorrectParse(String json) { | ||
var jsonOb = JsonTestHelper.readJson(json); | ||
assertThrows(IllegalStateException.class, () -> AnimatableTexture.CODEC.decode(JsonOps.INSTANCE, jsonOb).getOrThrow().getFirst()); | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
common/src/test/java/io/github/amerebagatelle/mods/nuit/skybox/BlendTest.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,110 @@ | ||
package io.github.amerebagatelle.mods.nuit.skybox; | ||
|
||
import com.mojang.serialization.JsonOps; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
public class BlendTest { | ||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
""" | ||
{ | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "add" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "subtract" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "multiply" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "screen" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "replace" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "normal" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "burn" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "dodge" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "disable" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "decorations" | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "custom", | ||
"blender": { | ||
} | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "custom", | ||
"blender": { | ||
"separateFunction": true | ||
} | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "custom", | ||
"blender": { | ||
"sourceFactor": 1 | ||
} | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "custom", | ||
"blender": { | ||
"equation": 32775 | ||
} | ||
} | ||
""", | ||
""" | ||
{ | ||
"blend": "custom", | ||
"blender": { | ||
"alphaEnabled": false | ||
} | ||
} | ||
""" | ||
}) | ||
public void testCorrectParse(String json) { | ||
var jsonOb = JsonTestHelper.readJson(json); | ||
assertDoesNotThrow(() -> Blend.CODEC.decode(JsonOps.INSTANCE, jsonOb).getOrThrow().getFirst()); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
common/src/test/java/io/github/amerebagatelle/mods/nuit/skybox/BlenderTest.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,41 @@ | ||
package io.github.amerebagatelle.mods.nuit.skybox; | ||
|
||
import com.mojang.serialization.JsonOps; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
public class BlenderTest { | ||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
""" | ||
{ | ||
} | ||
""", | ||
""" | ||
{ | ||
"separateFunction": true | ||
} | ||
""", | ||
""" | ||
{ | ||
"sourceFactor": 1 | ||
} | ||
""", | ||
""" | ||
{ | ||
"equation": 32775 | ||
} | ||
""", | ||
""" | ||
{ | ||
"alphaEnabled": false | ||
} | ||
""" | ||
}) | ||
public void testCorrectParse(String json) { | ||
var jsonOb = JsonTestHelper.readJson(json); | ||
assertDoesNotThrow(() -> Blender.CODEC.decode(JsonOps.INSTANCE, jsonOb).getOrThrow().getFirst()); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
common/src/test/java/io/github/amerebagatelle/mods/nuit/skybox/FadeTest.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,38 @@ | ||
package io.github.amerebagatelle.mods.nuit.skybox; | ||
|
||
import com.mojang.serialization.JsonOps; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
public class FadeTest { | ||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
""" | ||
{ | ||
} | ||
""", | ||
""" | ||
{ | ||
"alwaysOn": false | ||
} | ||
""", | ||
""" | ||
{ | ||
"duration": 24000 | ||
} | ||
""", | ||
""" | ||
{ | ||
"keyFrames": { | ||
"1000": 10, | ||
"3000": 20 | ||
} | ||
}""" | ||
}) | ||
public void testCorrectParse(String json) { | ||
var jsonOb = JsonTestHelper.readJson(json); | ||
assertDoesNotThrow(() -> Fade.CODEC.decode(JsonOps.INSTANCE, jsonOb).getOrThrow().getFirst()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/test/java/io/github/amerebagatelle/mods/nuit/skybox/JsonTestHelper.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,15 @@ | ||
package io.github.amerebagatelle.mods.nuit.skybox; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.google.gson.JsonObject; | ||
|
||
public class JsonTestHelper { | ||
public static final Gson GSON = new GsonBuilder() | ||
.setLenient() | ||
.create(); | ||
|
||
public static JsonObject readJson(String json) { | ||
return GSON.fromJson(json, JsonObject.class); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
common/src/test/java/io/github/amerebagatelle/mods/nuit/skybox/MetadataTest.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,70 @@ | ||
package io.github.amerebagatelle.mods.nuit.skybox; | ||
|
||
import com.mojang.serialization.JsonOps; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class MetadataTest { | ||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
""" | ||
{ | ||
"schemaVersion": 1, | ||
"type": "monocolor" | ||
} | ||
""", | ||
""" | ||
{ | ||
"schemaVersion": 1, | ||
"type": "square-textured" | ||
} | ||
""", | ||
""" | ||
{ | ||
"schemaVersion": 1, | ||
"type": "multi-textured" | ||
} | ||
""", | ||
""" | ||
{ | ||
"schemaVersion": 1, | ||
"type": "overworld" | ||
} | ||
""", | ||
""" | ||
{ | ||
"schemaVersion": 1, | ||
"type": "end" | ||
} | ||
""" | ||
}) | ||
public void testCorrectParse(String json) { | ||
var jsonOb = JsonTestHelper.readJson(json); | ||
assertDoesNotThrow(() -> Metadata.CODEC.decode(JsonOps.INSTANCE, jsonOb).getOrThrow().getFirst()); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
""" | ||
{ | ||
} | ||
""", | ||
""" | ||
{ | ||
"schemaVersion": 1 | ||
} | ||
""", | ||
""" | ||
{ | ||
"type": "overworld" | ||
} | ||
""" | ||
}) | ||
public void testIncorrectParse(String json) { | ||
var jsonOb = JsonTestHelper.readJson(json); | ||
assertThrows(IllegalStateException.class, () -> Metadata.CODEC.decode(JsonOps.INSTANCE, jsonOb).getOrThrow().getFirst()); | ||
} | ||
} |
Oops, something went wrong.