mirror of https://github.com/Minestom/Minestom.git
Test tag defaults
This commit is contained in:
parent
90a217eb9b
commit
3c7291298f
|
@ -7,7 +7,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
|||
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TagTest {
|
||||
|
||||
|
@ -34,4 +34,19 @@ public class TagTest {
|
|||
final String snbt = reader.getTag(Tag.SNBT);
|
||||
assertEquals(snbt, mutable.toCompound().toSNBT(), "SNBT is not the same");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
var nullable = Tag.String("key");
|
||||
var notNull = nullable.defaultValue("Hey");
|
||||
assertNotSame(nullable, notNull);
|
||||
|
||||
var handler = TagHandler.fromCompound(new MutableNBTCompound());
|
||||
assertFalse(handler.hasTag(nullable));
|
||||
assertTrue(handler.hasTag(notNull)); // default value is set
|
||||
assertFalse(handler.hasTag(nullable));
|
||||
|
||||
assertNull(handler.getTag(nullable));
|
||||
assertEquals("Hey", handler.getTag(notNull));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue