mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 11:03:43 +01:00 
			
		
		
		
	Let the Unit testing begin
Could use some more test cases on the make test, though
This commit is contained in:
		@@ -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]));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user