Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
Fix some bugs with potted plants, add tests for Identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed Apr 21, 2019
1 parent b8081c7 commit 32885e0
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import io.github.cottonmc.jsonfactory.output.loot.Pool
import io.github.cottonmc.jsonfactory.output.prefixed

object PottedPlantLootTable : ContentGenerator(
"Potted Plant Model", "loot_tables/blocks", GeneratorInfo.POTTED_PLANTS,
"Potted Plant Loot Table", "loot_tables/blocks", GeneratorInfo.POTTED_PLANTS,
resourceRoot = ResourceRoot.Data
) {
override fun generate(id: Identifier) = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object PottedPlantModel : ContentGenerator("Potted Plant Model", "models/block",
Model(
parent = Identifier.mc("block/flower_pot_cross"),
textures = mapOf(
"plant" to id
"plant" to id.prefixPath("block/")
)
).prefixed("potted")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ internal object TrapdoorBlockModel : ContentGenerator("Trapdoor Block Model", "m
Model(
parent = Identifier.mc("block/template_orientable_trapdoor_bottom"),
textures = mapOf(
"texture" to id.prefixPath("block/").suffixPath("_trapdoor")
"texture" to id.wrapPath("block/", "_trapdoor")
)
).suffixed("trapdoor_bottom"),
Model(
parent = Identifier.mc("block/template_orientable_trapdoor_top"),
textures = mapOf(
"texture" to id.prefixPath("block/").suffixPath("_trapdoor")
"texture" to id.wrapPath("block/", "_trapdoor")
)
).suffixed("trapdoor_top"),
Model(
parent = Identifier.mc("block/template_orientable_trapdoor_open"),
textures = mapOf(
"texture" to id.prefixPath("block/").suffixPath("_trapdoor")
"texture" to id.wrapPath("block/", "_trapdoor")
)
).suffixed("trapdoor_open")
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.github.cottonmc.jsonfactory.tests

import io.github.cottonmc.jsonfactory.data.Identifier
import org.junit.jupiter.api.Test
import strikt.api.expectThat
import strikt.assertions.isEqualTo
import strikt.assertions.isNull

class IdentifierTests {
private val base = Identifier("json_factory", "test")

@Test
fun prefixPath() {
expectThat(base.prefixPath("my_prefix/"))
.isEqualTo(Identifier("json_factory", "my_prefix/test"))
}

@Test
fun suffixPath() {
expectThat(base.suffixPath("/my_suffix"))
.isEqualTo(Identifier("json_factory", "test/my_suffix"))
}

@Test
fun wrapPath() {
expectThat(base.wrapPath("my_prefix/", "/my_suffix"))
.isEqualTo(Identifier("json_factory", "my_prefix/test/my_suffix"))
}

@Test
fun `wrapPath equals prefixPath + suffixPath`() {
expectThat(base.wrapPath("my_prefix/", "/my_suffix"))
.isEqualTo(base.prefixPath("my_prefix/").suffixPath("/my_suffix"))
}

@Test
fun minecraft() {
expectThat(Identifier.mc("example"))
.isEqualTo(Identifier("minecraft", "example"))
}

@Test
fun `Identifier from combined parts`() {
expectThat(Identifier("json_factory:test"))
.isEqualTo(base)
}

@Test
fun `invalid Identifier from combined parts`() {
expectThat(Identifier.orNull("invalid identifier =D"))
.isNull()
}
}

0 comments on commit 32885e0

Please sign in to comment.