mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Let the Unit testing begin
Could use some more test cases on the make test, though
This commit is contained in:
parent
dce7d8fdd3
commit
646bb32965
6
pom.xml
6
pom.xml
@ -128,6 +128,12 @@
|
|||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit-dep</artifactId>
|
||||||
|
<version>4.10</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -164,15 +164,15 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
|
|||||||
* - z = 1111 = 15
|
* - z = 1111 = 15
|
||||||
* => Chunklet coordinates (5, 15)
|
* => Chunklet coordinates (5, 15)
|
||||||
*/
|
*/
|
||||||
private static byte makeAddressByte(int x, int z) {
|
protected static byte makeAddressByte(int x, int z) {
|
||||||
return (byte) ((x << 4) + z);
|
return (byte) ((x << 4) + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int addressByteX(byte address) {
|
protected static int addressByteX(byte address) {
|
||||||
return (address & 0xF0) >>> 4;
|
return (address & 0xF0) >>> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int addressByteZ(byte address) {
|
protected static int addressByteZ(byte address) {
|
||||||
return address & 0x0F;
|
return address & 0x0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.gmail.nossr50.util.blockmeta;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class PrimitiveExChunkletStoreTest {
|
||||||
|
byte addresses[][] = new byte[16][16];
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void populateAddresses() {
|
||||||
|
for(int x = 0; x < 16; x++) {
|
||||||
|
for(int z = 0; z < 16; z++) {
|
||||||
|
addresses[x][z] = PrimitiveExChunkletStore.makeAddressByte(x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addressMakeTest() {
|
||||||
|
assertEquals(addresses[0][0], 0);
|
||||||
|
assertEquals(addresses[15][15], -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addressReverseTest() {
|
||||||
|
for(int x = 0; x < 16; x++) {
|
||||||
|
for(int z = 0; z < 16; z++) {
|
||||||
|
assertEquals(x, PrimitiveExChunkletStore.addressByteX(addresses[x][z]));
|
||||||
|
assertEquals(z, PrimitiveExChunkletStore.addressByteZ(addresses[x][z]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user