-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
6d45f89
commit 8d19578
Showing
1 changed file
with
21 additions
and
29 deletions.
There are no files selected for viewing
50 changes: 21 additions & 29 deletions
50
src/test/java/com/sweetrpg/crafttracker/test/crafttracker/common/util/UtilTest.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 |
---|---|---|
@@ -1,39 +1,31 @@ | ||
package com.sweetrpg.crafttracker.test.crafttracker.common.util; | ||
|
||
import static com.sweetrpg.crafttracker.common.util.Util.getRegistryId; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraftforge.registries.RegistryObject; | ||
import net.minecraftforge.registries.IForgeRegistryEntry; | ||
import net.minecraftforge.registries.IRegistryDelegate; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class UtilTest { | ||
|
||
@Test | ||
public void testGetRegistryId() { | ||
ResourceLocation dirtRL = new ResourceLocation("minecraft:dirt"); | ||
assertEquals(dirtRL, getRegistryId("minecraft:dirt")); | ||
assertEquals(dirtRL, getRegistryId(dirtRL)); | ||
assertEquals(dirtRL, getRegistryId(RegistryObject.of(dirtRL, Block.class, "dummy_mod"))); | ||
|
||
assertEquals(dirtRL, getRegistryId(new IRegistryDelegate<Block>() { | ||
@Override public ResourceLocation name() { return dirtRL; } | ||
// Methods should never be called | ||
@Override public Class type() { return Block.class; } | ||
@Override public Block get() { return null; } | ||
})); | ||
|
||
assertEquals(dirtRL, getRegistryId(new IForgeRegistryEntry<Block>() { | ||
@Override public ResourceLocation getRegistryName() { return dirtRL; } | ||
// Methods should never be called | ||
@Override public Class<Block> getRegistryType() { return Block.class; } | ||
@Override public Block setRegistryName(ResourceLocation name) { return null; } | ||
})); | ||
|
||
assertNull(getRegistryId("name:space:invalid")); // invalid rl's should return null | ||
assertNull(getRegistryId(Integer.valueOf(0))); // other object types too | ||
// ResourceLocation dirtRL = new ResourceLocation("minecraft:dirt"); | ||
// assertEquals(dirtRL, getRegistryId("minecraft:dirt")); | ||
// assertEquals(dirtRL, getRegistryId(dirtRL)); | ||
// assertEquals(dirtRL, getRegistryId(RegistryObject.of(dirtRL, Block.class, "dummy_mod"))); | ||
// | ||
// assertEquals(dirtRL, getRegistryId(new IRegistryDelegate<Block>() { | ||
// @Override public ResourceLocation name() { return dirtRL; } | ||
// // Methods should never be called | ||
// @Override public Class type() { return Block.class; } | ||
// @Override public Block get() { return null; } | ||
// })); | ||
// | ||
// assertEquals(dirtRL, getRegistryId(new IForgeRegistryEntry<Block>() { | ||
// @Override public ResourceLocation getRegistryName() { return dirtRL; } | ||
// // Methods should never be called | ||
// @Override public Class<Block> getRegistryType() { return Block.class; } | ||
// @Override public Block setRegistryName(ResourceLocation name) { return null; } | ||
// })); | ||
// | ||
// assertNull(getRegistryId("name:space:invalid")); // invalid rl's should return null | ||
// assertNull(getRegistryId(Integer.valueOf(0))); // other object types too | ||
} | ||
} |