summaryrefslogtreecommitdiffstats
path: root/tests/ChunkData/Copies.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-05-24 14:33:40 +0200
committerTycho <work.tycho+git@gmail.com>2014-05-24 14:33:40 +0200
commit8f964886e0ccbf51dac07227f0ac4c739b47d3a5 (patch)
tree534fec1ed8061513b67d8504a95f2bd926416d53 /tests/ChunkData/Copies.cpp
parentMerge branch 'master' into chunksparsing/structs (diff)
downloadcuberite-8f964886e0ccbf51dac07227f0ac4c739b47d3a5.tar
cuberite-8f964886e0ccbf51dac07227f0ac4c739b47d3a5.tar.gz
cuberite-8f964886e0ccbf51dac07227f0ac4c739b47d3a5.tar.bz2
cuberite-8f964886e0ccbf51dac07227f0ac4c739b47d3a5.tar.lz
cuberite-8f964886e0ccbf51dac07227f0ac4c739b47d3a5.tar.xz
cuberite-8f964886e0ccbf51dac07227f0ac4c739b47d3a5.tar.zst
cuberite-8f964886e0ccbf51dac07227f0ac4c739b47d3a5.zip
Diffstat (limited to 'tests/ChunkData/Copies.cpp')
-rw-r--r--tests/ChunkData/Copies.cpp135
1 files changed, 38 insertions, 97 deletions
diff --git a/tests/ChunkData/Copies.cpp b/tests/ChunkData/Copies.cpp
index 145ffd8e0..b10ddb759 100644
--- a/tests/ChunkData/Copies.cpp
+++ b/tests/ChunkData/Copies.cpp
@@ -9,14 +9,14 @@ int main(int argc, char** argv)
{
cChunkData buffer;
- buffer.SetBlock(3,1,4,0xDE);
- buffer.SetMeta(3,1,4,0xA);
+ buffer.SetBlock(3, 1, 4, 0xDE);
+ buffer.SetMeta(3, 1, 4, 0xA);
cChunkData copy = buffer.Copy();
- testassert(copy.GetBlock(3,1,4) == 0xDE);
- testassert(copy.GetMeta(3,1,4) == 0xA);
+ testassert(copy.GetBlock(3, 1, 4) == 0xDE);
+ testassert(copy.GetMeta(3, 1, 4) == 0xA);
- BLOCKTYPE * SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
for (int i = 0; i < 16 * 16 * 256; i += 4)
{
SrcBlockBuffer[i+0] = 0xDE;
@@ -26,30 +26,20 @@ int main(int argc, char** argv)
}
buffer.SetBlocks(SrcBlockBuffer);
- BLOCKTYPE * DstBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ BLOCKTYPE DstBlockBuffer[16 * 16 * 256];
buffer.CopyBlocks(DstBlockBuffer);
- testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) -1) == 0);
- delete SrcBlockBuffer;
- delete DstBlockBuffer;
- SrcBlockBuffer = NULL;
- DstBlockBuffer = NULL;
+ testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
- SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
buffer.SetBlocks(SrcBlockBuffer);
- DstBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
buffer.CopyBlocks(DstBlockBuffer);
- testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) -1) == 0);
- delete SrcBlockBuffer;
- delete DstBlockBuffer;
- SrcBlockBuffer = NULL;
- DstBlockBuffer = NULL;
+ testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
}
{
cChunkData buffer;
- NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
{
SrcNibbleBuffer[i+0] = 0xEF;
@@ -59,30 +49,21 @@ int main(int argc, char** argv)
}
buffer.SetMeta(SrcNibbleBuffer);
- NIBBLETYPE * DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ NIBBLETYPE DstNibbleBuffer[16 * 16 * 256/ 2];
buffer.CopyMeta(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
buffer.SetMeta(SrcNibbleBuffer);
- DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
buffer.CopyMeta(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
+
}
{
cChunkData buffer;
- NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
{
SrcNibbleBuffer[i+0] = 0xDE;
@@ -91,32 +72,22 @@ int main(int argc, char** argv)
SrcNibbleBuffer[i+3] = 0xEF;
}
- buffer.SetLight(SrcNibbleBuffer);
- NIBBLETYPE * DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
- buffer.CopyLight(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ buffer.SetBlockLight(SrcNibbleBuffer);
+ NIBBLETYPE DstNibbleBuffer[16 * 16 * 256 / 2];
+ buffer.CopyBlockLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) - 1) == 0);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- buffer.SetLight(SrcNibbleBuffer);
- DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
- buffer.CopyLight(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ buffer.SetBlockLight(SrcNibbleBuffer);
+ buffer.CopyBlockLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) - 1) == 0);
}
{
cChunkData buffer;
- NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
{
SrcNibbleBuffer[i+0] = 0xAD;
@@ -126,68 +97,38 @@ int main(int argc, char** argv)
}
buffer.SetSkyLight(SrcNibbleBuffer);
- NIBBLETYPE * DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ NIBBLETYPE DstNibbleBuffer[16 * 16 * 256/ 2];
buffer.CopySkyLight(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 /2);
+ memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 / 2);
buffer.SetSkyLight(SrcNibbleBuffer);
- DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
buffer.CopySkyLight(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
}
{
cChunkData buffer;
- BLOCKTYPE * SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
- BLOCKTYPE * DstBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ BLOCKTYPE DstBlockBuffer[16 * 16 * 256];
buffer.CopyBlocks(DstBlockBuffer);
- testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) -1) == 0);
- delete SrcBlockBuffer;
- delete DstBlockBuffer;
- SrcBlockBuffer = NULL;
- DstBlockBuffer = NULL;
+ testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
- NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- NIBBLETYPE * DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
+ NIBBLETYPE DstNibbleBuffer[16 * 16 * 256 / 2];
buffer.CopyMeta(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
- buffer.CopyLight(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
+ buffer.CopyBlockLight(DstNibbleBuffer);
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 /2);
- DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];
+ memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 / 2);
buffer.CopySkyLight(DstNibbleBuffer);
- testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) -1) == 0);
- delete SrcNibbleBuffer;
- delete DstNibbleBuffer;
- SrcNibbleBuffer = NULL;
- DstNibbleBuffer = NULL;
+ testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
}
}