2014-05-10 11:15:45 -04:00
|
|
|
|
2014-05-27 07:44:56 -04:00
|
|
|
#include "Globals.h"
|
2014-05-21 14:58:48 -04:00
|
|
|
#include "ChunkData.h"
|
2014-05-10 11:15:45 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2016-06-16 11:34:17 -04:00
|
|
|
LOGD("Test started");
|
|
|
|
|
2014-06-16 10:12:50 -04:00
|
|
|
class cMockAllocationPool
|
|
|
|
: public cAllocationPool<cChunkData::sChunkSection>
|
|
|
|
{
|
|
|
|
virtual cChunkData::sChunkSection * Allocate()
|
|
|
|
{
|
|
|
|
return new cChunkData::sChunkSection();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Free(cChunkData::sChunkSection * a_Ptr)
|
|
|
|
{
|
|
|
|
delete a_Ptr;
|
|
|
|
}
|
|
|
|
} Pool;
|
2014-05-11 14:40:32 -04:00
|
|
|
{
|
2014-06-16 10:12:50 -04:00
|
|
|
cChunkData buffer(Pool);
|
2014-05-10 11:15:45 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
buffer.SetBlock(3, 1, 4, 0xDE);
|
|
|
|
buffer.SetMeta(3, 1, 4, 0xA);
|
2014-05-10 11:15:45 -04:00
|
|
|
|
2017-08-21 12:56:53 -04:00
|
|
|
cChunkData copy(Pool);
|
|
|
|
copy.Assign(buffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(copy.GetBlock(3, 1, 4) == 0xDE);
|
|
|
|
testassert(copy.GetMeta(3, 1, 4) == 0xA);
|
2014-05-10 11:15:45 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
|
2014-05-11 14:40:32 -04:00
|
|
|
for (int i = 0; i < 16 * 16 * 256; i += 4)
|
|
|
|
{
|
2014-05-29 14:18:37 -04:00
|
|
|
SrcBlockBuffer[i + 0] = 0xde;
|
|
|
|
SrcBlockBuffer[i + 1] = 0xad;
|
|
|
|
SrcBlockBuffer[i + 2] = 0xbe;
|
|
|
|
SrcBlockBuffer[i + 3] = 0xef;
|
2014-05-11 14:40:32 -04:00
|
|
|
}
|
2014-05-10 11:15:45 -04:00
|
|
|
|
2014-05-29 13:42:39 -04:00
|
|
|
buffer.SetBlockTypes(SrcBlockBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
BLOCKTYPE DstBlockBuffer[16 * 16 * 256];
|
2014-05-29 13:42:39 -04:00
|
|
|
buffer.CopyBlockTypes(DstBlockBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
|
2014-05-17 08:39:28 -04:00
|
|
|
|
|
|
|
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
|
2014-05-29 13:42:39 -04:00
|
|
|
buffer.SetBlockTypes(SrcBlockBuffer);
|
|
|
|
buffer.CopyBlockTypes(DstBlockBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
|
2014-05-17 08:39:28 -04:00
|
|
|
}
|
2014-05-30 03:17:50 -04:00
|
|
|
|
2014-05-17 08:39:28 -04:00
|
|
|
{
|
2014-06-16 10:12:50 -04:00
|
|
|
cChunkData buffer(Pool);
|
2014-05-10 11:15:45 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
2014-05-11 14:40:32 -04:00
|
|
|
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
|
|
|
|
{
|
2014-05-29 14:18:37 -04:00
|
|
|
SrcNibbleBuffer[i + 0] = 0xde;
|
|
|
|
SrcNibbleBuffer[i + 1] = 0xad;
|
|
|
|
SrcNibbleBuffer[i + 2] = 0xbe;
|
|
|
|
SrcNibbleBuffer[i + 3] = 0xef;
|
2014-05-11 14:40:32 -04:00
|
|
|
}
|
2014-05-11 10:57:56 -04:00
|
|
|
|
2014-05-29 13:42:39 -04:00
|
|
|
buffer.SetMetas(SrcNibbleBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
NIBBLETYPE DstNibbleBuffer[16 * 16 * 256/ 2];
|
2014-05-29 13:42:39 -04:00
|
|
|
buffer.CopyMetas(DstNibbleBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
|
2014-05-17 08:39:28 -04:00
|
|
|
|
|
|
|
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
|
2014-05-29 13:42:39 -04:00
|
|
|
buffer.SetMetas(SrcNibbleBuffer);
|
|
|
|
buffer.CopyMetas(DstNibbleBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
|
2014-05-17 08:39:28 -04:00
|
|
|
}
|
2014-05-30 03:17:50 -04:00
|
|
|
|
2014-05-17 08:39:28 -04:00
|
|
|
{
|
2014-06-16 10:12:50 -04:00
|
|
|
cChunkData buffer(Pool);
|
2014-05-17 08:39:28 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
2014-05-11 14:40:32 -04:00
|
|
|
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
|
|
|
|
{
|
2014-05-29 14:18:37 -04:00
|
|
|
SrcNibbleBuffer[i + 0] = 0xde;
|
|
|
|
SrcNibbleBuffer[i + 1] = 0xad;
|
|
|
|
SrcNibbleBuffer[i + 2] = 0xbe;
|
|
|
|
SrcNibbleBuffer[i + 3] = 0xef;
|
2014-05-11 14:40:32 -04:00
|
|
|
}
|
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
buffer.SetBlockLight(SrcNibbleBuffer);
|
|
|
|
NIBBLETYPE DstNibbleBuffer[16 * 16 * 256 / 2];
|
|
|
|
buffer.CopyBlockLight(DstNibbleBuffer);
|
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) - 1) == 0);
|
2014-05-17 08:39:28 -04:00
|
|
|
|
|
|
|
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
|
2014-05-24 08:33:40 -04:00
|
|
|
buffer.SetBlockLight(SrcNibbleBuffer);
|
|
|
|
buffer.CopyBlockLight(DstNibbleBuffer);
|
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) - 1) == 0);
|
2014-05-17 08:39:28 -04:00
|
|
|
}
|
2014-05-30 03:17:50 -04:00
|
|
|
|
2014-05-17 08:39:28 -04:00
|
|
|
{
|
2014-06-16 10:12:50 -04:00
|
|
|
cChunkData buffer(Pool);
|
2014-05-17 08:39:28 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
2014-05-11 14:40:32 -04:00
|
|
|
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
|
|
|
|
{
|
2014-05-29 14:18:37 -04:00
|
|
|
SrcNibbleBuffer[i + 0] = 0xde;
|
|
|
|
SrcNibbleBuffer[i + 1] = 0xad;
|
|
|
|
SrcNibbleBuffer[i + 2] = 0xbe;
|
|
|
|
SrcNibbleBuffer[i + 3] = 0xef;
|
2014-05-11 14:40:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
buffer.SetSkyLight(SrcNibbleBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
NIBBLETYPE DstNibbleBuffer[16 * 16 * 256/ 2];
|
2014-05-11 14:40:32 -04:00
|
|
|
buffer.CopySkyLight(DstNibbleBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
|
2014-05-11 14:40:32 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 / 2);
|
2014-05-11 14:40:32 -04:00
|
|
|
buffer.SetSkyLight(SrcNibbleBuffer);
|
|
|
|
buffer.CopySkyLight(DstNibbleBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
|
2014-05-11 10:57:56 -04:00
|
|
|
}
|
2014-05-30 03:17:50 -04:00
|
|
|
|
2014-05-11 14:40:32 -04:00
|
|
|
{
|
2014-06-16 10:12:50 -04:00
|
|
|
cChunkData buffer(Pool);
|
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
|
|
|
BLOCKTYPE DstBlockBuffer[16 * 16 * 256];
|
2014-05-29 13:42:39 -04:00
|
|
|
buffer.CopyBlockTypes(DstBlockBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
|
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);
|
|
|
|
NIBBLETYPE DstNibbleBuffer[16 * 16 * 256 / 2];
|
2014-05-29 13:42:39 -04:00
|
|
|
buffer.CopyMetas(DstNibbleBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
|
2014-05-11 10:57:56 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
|
|
|
|
buffer.CopyBlockLight(DstNibbleBuffer);
|
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
|
2014-05-11 14:40:32 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 / 2);
|
2014-05-11 14:40:32 -04:00
|
|
|
buffer.CopySkyLight(DstNibbleBuffer);
|
2014-05-24 08:33:40 -04:00
|
|
|
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
|
2014-05-11 14:40:32 -04:00
|
|
|
}
|
2014-05-30 03:17:50 -04:00
|
|
|
|
|
|
|
// All tests successful:
|
|
|
|
return 0;
|
2014-05-10 11:15:45 -04:00
|
|
|
}
|