1
0
cuberite-2a/tests/ChunkData/ArraytoCoord.cpp

87 lines
2.6 KiB
C++
Raw Normal View History

2014-05-11 14:40:32 -04:00
#include "Globals.h"
2014-05-21 14:58:48 -04:00
#include "ChunkData.h"
2014-05-11 14:40:32 -04:00
int main(int argc, char** argv)
{
{
2014-05-17 09:07:49 -04:00
// Test first segment
2014-05-21 14:58:48 -04:00
cChunkData buffer;
2014-05-11 14:40:32 -04:00
2014-05-24 08:33:40 -04:00
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
2014-05-11 14:40:32 -04:00
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
2014-05-24 08:33:40 -04:00
SrcBlockBuffer[7 + (4 * 16) + (5 * 16 * 16)] = 0xCD;
2014-05-29 13:42:39 -04:00
buffer.SetBlockTypes(SrcBlockBuffer);
2014-05-11 14:40:32 -04:00
testassert(buffer.GetBlock(7,5,4) == 0xCD);
2014-05-24 08:33:40 -04:00
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xE;
2014-05-29 13:42:39 -04:00
buffer.SetMetas(SrcNibbleBuffer);
2014-05-24 08:33:40 -04:00
testassert(buffer.GetMeta(6, 2, 1) == 0xE);
2014-05-11 14:40:32 -04:00
2014-05-24 08:33:40 -04:00
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xE;
buffer.SetBlockLight(SrcNibbleBuffer);
testassert(buffer.GetBlockLight(6, 2, 1) == 0xE);
2014-05-11 14:40:32 -04:00
2014-05-24 08:33:40 -04:00
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xE;
2014-05-11 14:40:32 -04:00
buffer.SetSkyLight(SrcNibbleBuffer);
2014-05-24 08:33:40 -04:00
testassert(buffer.GetSkyLight(6, 2, 1) == 0xE);
2014-05-11 14:40:32 -04:00
}
{
2014-05-17 09:07:49 -04:00
// test following segment
2014-05-21 14:58:48 -04:00
cChunkData buffer;
2014-05-11 14:40:32 -04:00
2014-05-24 08:33:40 -04:00
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
2014-05-11 14:40:32 -04:00
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
2014-05-24 08:33:40 -04:00
SrcBlockBuffer[7 + (4 * 16) + (24 * 16 * 16)] = 0xCD;
2014-05-29 13:42:39 -04:00
buffer.SetBlockTypes(SrcBlockBuffer);
2014-05-24 08:33:40 -04:00
testassert(buffer.GetBlock(7, 24, 4) == 0xCD);
2014-05-11 14:40:32 -04:00
2014-05-24 08:33:40 -04:00
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16)) / 2] = 0xE;
2014-05-29 13:42:39 -04:00
buffer.SetMetas(SrcNibbleBuffer);
2014-05-24 08:33:40 -04:00
testassert(buffer.GetMeta(6, 24, 1) == 0xE);
2014-05-11 14:40:32 -04:00
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
SrcNibbleBuffer[(6+1*16+24*16*16)/2] = 0xE;
2014-05-24 08:33:40 -04:00
buffer.SetBlockLight(SrcNibbleBuffer);
2014-05-11 14:40:32 -04:00
testassert(buffer.GetBlockLight(6,24,1) == 0xE);
2014-05-24 08:33:40 -04:00
memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 / 2);
SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16))/2] = 0xE;
2014-05-11 14:40:32 -04:00
buffer.SetSkyLight(SrcNibbleBuffer);
2014-05-24 08:33:40 -04:00
testassert(buffer.GetSkyLight(6, 24, 1) == 0xE);
2014-05-11 14:40:32 -04:00
}
2014-05-17 09:07:49 -04:00
{
// test zeros
2014-05-21 14:58:48 -04:00
cChunkData buffer;
2014-05-17 09:07:49 -04:00
2014-05-24 08:33:40 -04:00
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
2014-05-17 09:07:49 -04:00
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
2014-05-29 13:42:39 -04:00
buffer.SetBlockTypes(SrcBlockBuffer);
2014-05-24 08:33:40 -04:00
testassert(buffer.GetBlock(7, 24, 4) == 0x00);
2014-05-17 09:07:49 -04:00
2014-05-24 08:33:40 -04:00
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256/2];
2014-05-17 09:07:49 -04:00
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
2014-05-29 13:42:39 -04:00
buffer.SetMetas(SrcNibbleBuffer);
2014-05-24 08:33:40 -04:00
testassert(buffer.GetMeta(6, 24, 1) == 0x0);
2014-05-17 09:07:49 -04:00
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
2014-05-24 08:33:40 -04:00
buffer.SetBlockLight(SrcNibbleBuffer);
2014-05-17 09:07:49 -04:00
testassert(buffer.GetBlockLight(6,24,1) == 0x0);
2014-05-17 10:11:58 -04:00
memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 /2);
2014-05-17 09:07:49 -04:00
buffer.SetSkyLight(SrcNibbleBuffer);
2014-05-24 08:33:40 -04:00
testassert(buffer.GetSkyLight(6, 24, 1) == 0xF);
2014-05-17 09:07:49 -04:00
}
2014-05-11 14:40:32 -04:00
}