From 039b055260f8b43c9c7e17de7d34e8e55fab49ea Mon Sep 17 00:00:00 2001 From: Daniil Date: Fri, 10 Aug 2018 16:17:32 +0700 Subject: [PATCH] EntityLocation.clone() unit test --- .../src/main/java/mc/core/EntityLocation.java | 2 +- .../test/java/mc/core/EntityLocationTest.java | 100 ++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 core/src/test/java/mc/core/EntityLocationTest.java diff --git a/core/src/main/java/mc/core/EntityLocation.java b/core/src/main/java/mc/core/EntityLocation.java index edb92a3..0eec9d2 100644 --- a/core/src/main/java/mc/core/EntityLocation.java +++ b/core/src/main/java/mc/core/EntityLocation.java @@ -29,6 +29,6 @@ public class EntityLocation extends Location implements Cloneable { @Override public EntityLocation clone() { - return (EntityLocation) super.clone(); //TODO need test + return (EntityLocation) super.clone(); } } diff --git a/core/src/test/java/mc/core/EntityLocationTest.java b/core/src/test/java/mc/core/EntityLocationTest.java new file mode 100644 index 0000000..7e77fdc --- /dev/null +++ b/core/src/test/java/mc/core/EntityLocationTest.java @@ -0,0 +1,100 @@ +package mc.core; + +import com.flowpowered.nbt.Tag; +import mc.core.world.ChunkSection; +import mc.core.world.IWorldType; +import mc.core.world.Region; +import mc.core.world.World; +import org.junit.Assert; +import org.junit.Test; + +import java.util.UUID; +import java.util.stream.Stream; + +public class EntityLocationTest { + @Test + public void cloneTest() { + World dummyWorld = new World() { + @Override + public UUID getWorldId() { + return null; + } + + @Override + public IWorldType getWorldType() { + return null; + } + + @Override + public EntityLocation getSpawn() { + return null; + } + + @Override + public void setSpawn(EntityLocation location) { + + } + + @Override + public ChunkSection getChunk(int x, int y, int z) { + return null; + } + + @Override + public void setChunk(int x, int y, int z, ChunkSection chunkSection) { + + } + + @Override + public Region getRegion(int x, int z) { + return null; + } + + @Override + public void setRegion(int x, int z, Region region) { + + } + + @Override + public int getSeed() { + return 0; + } + + @Override + public String getName() { + return null; + } + + @Override + public void setName(String name) { + + } + + @Override + public Tag getTag(String name) { + return null; + } + + @Override + public void setTag(Tag tag) { + + } + + @Override + public Stream> tagStream() { + return null; + } + }; + + EntityLocation firstLocation = new EntityLocation(10, 20, 30, 40, 50, dummyWorld); + EntityLocation locationClone = firstLocation.clone(); + + Assert.assertEquals("X mismatch", firstLocation.getX(), locationClone.getX(), 0); + Assert.assertEquals("Y mismatch", firstLocation.getY(), locationClone.getY(), 0); + Assert.assertEquals("Z mismatch", firstLocation.getZ(), locationClone.getZ(), 0); + Assert.assertEquals("Pitch mismatch", firstLocation.getPitch(), locationClone.getPitch(), 0); + Assert.assertEquals("Yaw mismatch", firstLocation.getYaw(), locationClone.getYaw(), 0); + Assert.assertEquals("World mismatch", firstLocation.getWorld(), locationClone.getWorld()); + + } +}