Add unit test for BlockLocationHistory

Move ChunkStoreTest to correct package
This commit is contained in:
t00thpick1 2021-01-02 20:53:25 -05:00
parent 9e2d5aada8
commit a57e6d3bbe
2 changed files with 39 additions and 2 deletions

View File

@ -0,0 +1,37 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.Location;
import org.junit.Assert;
import org.junit.Test;
public class BlockLocationHistoryTest {
@Test
public void testRemovesOldestElement() {
BlockLocationHistory history = new BlockLocationHistory(2);
Location locationA = new Location(null, 0, 1, 2);
Location locationB = new Location(null, 1, 2, 3);
Location locationC = new Location(null, 2, 3, 4);
history.add(locationA);
history.add(locationB);
history.add(locationC);
Assert.assertFalse(history.contains(locationA));
Assert.assertTrue(history.contains(locationB));
Assert.assertTrue(history.contains(locationC));
}
@Test
public void testSupportsDuplicateElement() {
BlockLocationHistory history = new BlockLocationHistory(2);
Location locationA = new Location(null, 0, 1, 2);
Location locationB = new Location(null, 1, 2, 3);
history.add(locationA);
history.add(locationA);
history.add(locationB);
Assert.assertTrue(history.contains(locationA));
Assert.assertTrue(history.contains(locationB));
history.add(locationB);
Assert.assertFalse(history.contains(locationA));
}
}

View File

@ -1,10 +1,10 @@
import com.gmail.nossr50.util.blockmeta.*; package com.gmail.nossr50.util.blockmeta;
import com.google.common.io.Files; import com.google.common.io.Files;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.*; import org.junit.*;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mockito; import org.mockito.Mockito;