summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-05-25 19:02:33 +0200
committerTycho <work.tycho+git@gmail.com>2014-05-25 19:02:33 +0200
commit8133efd7f9def01b81ef2a52c05d8ec5b7f89632 (patch)
treea56f6889aea8de8759fab87abdee2eef778873ed /tests
parentFixed bug in freeing NULL pointers (diff)
parentinject TestGlobals.h correctly (diff)
downloadcuberite-8133efd7f9def01b81ef2a52c05d8ec5b7f89632.tar
cuberite-8133efd7f9def01b81ef2a52c05d8ec5b7f89632.tar.gz
cuberite-8133efd7f9def01b81ef2a52c05d8ec5b7f89632.tar.bz2
cuberite-8133efd7f9def01b81ef2a52c05d8ec5b7f89632.tar.lz
cuberite-8133efd7f9def01b81ef2a52c05d8ec5b7f89632.tar.xz
cuberite-8133efd7f9def01b81ef2a52c05d8ec5b7f89632.tar.zst
cuberite-8133efd7f9def01b81ef2a52c05d8ec5b7f89632.zip
Diffstat (limited to 'tests')
-rw-r--r--tests/ChunkData/ArraytoCoord.cpp90
-rw-r--r--tests/ChunkData/CMakeLists.txt1
-rw-r--r--tests/ChunkData/Coordinates.cpp44
-rw-r--r--tests/ChunkData/Copies.cpp135
-rw-r--r--tests/TestGlobals.h4
5 files changed, 90 insertions, 184 deletions
diff --git a/tests/ChunkData/ArraytoCoord.cpp b/tests/ChunkData/ArraytoCoord.cpp
index 04e6fbc5a..f800d8e05 100644
--- a/tests/ChunkData/ArraytoCoord.cpp
+++ b/tests/ChunkData/ArraytoCoord.cpp
@@ -19,107 +19,77 @@ int main(int argc, char** argv)
// Test first segment
cChunkData buffer(Pool);
- BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
- SrcBlockBuffer[7+4*16+5*16*16] = 0xCD;
+ SrcBlockBuffer[7 + (4 * 16) + (5 * 16 * 16)] = 0xCD;
buffer.SetBlocks(SrcBlockBuffer);
testassert(buffer.GetBlock(7,5,4) == 0xCD);
- delete SrcBlockBuffer;
- SrcBlockBuffer = NULL;
- NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- SrcNibbleBuffer[(6+1*16+2*16*16)/2] = 0xE;
+ NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
+ SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xE;
buffer.SetMeta(SrcNibbleBuffer);
- testassert(buffer.GetMeta(6,2,1) == 0xE);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
+ testassert(buffer.GetMeta(6, 2, 1) == 0xE);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- SrcNibbleBuffer[(6+1*16+2*16*16)/2] = 0xE;
- buffer.SetLight(SrcNibbleBuffer);
- testassert(buffer.GetBlockLight(6,2,1) == 0xE);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
+ 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);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- SrcNibbleBuffer[(6+1*16+2*16*16)/2] = 0xE;
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
+ SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xE;
buffer.SetSkyLight(SrcNibbleBuffer);
- testassert(buffer.GetSkyLight(6,2,1) == 0xE);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
+ testassert(buffer.GetSkyLight(6, 2, 1) == 0xE);
}
{
// test following segment
cChunkData buffer(Pool);
- BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
- SrcBlockBuffer[7+4*16+24*16*16] = 0xCD;
+ SrcBlockBuffer[7 + (4 * 16) + (24 * 16 * 16)] = 0xCD;
buffer.SetBlocks(SrcBlockBuffer);
- testassert(buffer.GetBlock(7,24,4) == 0xCD);
- delete SrcBlockBuffer;
- SrcBlockBuffer = NULL;
+ testassert(buffer.GetBlock(7, 24, 4) == 0xCD);
- NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- SrcNibbleBuffer[(6+1*16+24*16*16)/2] = 0xE;
+ NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
+ memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
+ SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16)) / 2] = 0xE;
buffer.SetMeta(SrcNibbleBuffer);
- testassert(buffer.GetMeta(6,24,1) == 0xE);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
+ testassert(buffer.GetMeta(6, 24, 1) == 0xE);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
SrcNibbleBuffer[(6+1*16+24*16*16)/2] = 0xE;
- buffer.SetLight(SrcNibbleBuffer);
+ buffer.SetBlockLight(SrcNibbleBuffer);
testassert(buffer.GetBlockLight(6,24,1) == 0xE);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- SrcNibbleBuffer[(6+1*16+24*16*16)/2] = 0xE;
+ memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 / 2);
+ SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16))/2] = 0xE;
buffer.SetSkyLight(SrcNibbleBuffer);
- testassert(buffer.GetSkyLight(6,24,1) == 0xE);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
+ testassert(buffer.GetSkyLight(6, 24, 1) == 0xE);
}
{
// test zeros
cChunkData buffer(Pool);
- BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
+ BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
buffer.SetBlocks(SrcBlockBuffer);
- testassert(buffer.GetBlock(7,24,4) == 0x00);
- delete SrcBlockBuffer;
- SrcBlockBuffer = NULL;
+ testassert(buffer.GetBlock(7, 24, 4) == 0x00);
- NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
+ NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256/2];
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
buffer.SetMeta(SrcNibbleBuffer);
- testassert(buffer.GetMeta(6,24,1) == 0x0);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
+ testassert(buffer.GetMeta(6, 24, 1) == 0x0);
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- buffer.SetLight(SrcNibbleBuffer);
+ buffer.SetBlockLight(SrcNibbleBuffer);
testassert(buffer.GetBlockLight(6,24,1) == 0x0);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
- SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 /2);
buffer.SetSkyLight(SrcNibbleBuffer);
- testassert(buffer.GetSkyLight(6,24,1) == 0xF);
- delete SrcNibbleBuffer;
- SrcNibbleBuffer = NULL;
+ testassert(buffer.GetSkyLight(6, 24, 1) == 0xF);
}
}
diff --git a/tests/ChunkData/CMakeLists.txt b/tests/ChunkData/CMakeLists.txt
index 3f6653bb5..a2bd9fd22 100644
--- a/tests/ChunkData/CMakeLists.txt
+++ b/tests/ChunkData/CMakeLists.txt
@@ -4,6 +4,7 @@ enable_testing()
include_directories(${CMAKE_SOURCE_DIR}/src/)
+add_definitions(-DTEST_GLOBALS=1)
add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp)
diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp
index 0a7d5e3f1..f94532183 100644
--- a/tests/ChunkData/Coordinates.cpp
+++ b/tests/ChunkData/Coordinates.cpp
@@ -9,27 +9,21 @@ int main(int argc, char** argv)
class cStarvationCallbacks
: public cAllocationPool<cChunkData::sChunkSection,1600>::cStarvationCallbacks
{
- virtual void OnStartingUsingBuffer() {}
- virtual void OnStopUsingBuffer() {}
- virtual void OnBufferEmpty() {}
- };
- cAllocationPool<cChunkData::sChunkSection,1600> Pool(std::auto_ptr<cAllocationPool<cChunkData::sChunkSection,1600>::cStarvationCallbacks>(new cStarvationCallbacks()));
- {
- cChunkData buffer(Pool);
+ cChunkData buffer;
// Empty chunks
- buffer.SetBlock(0,0,0, 0xAB);
- testassert(buffer.GetBlock(0,0,0) == 0xAB);
- buffer.SetMeta(0,16,0, 0xC);
- testassert(buffer.GetMeta(0,16,0) == 0xC);
+ buffer.SetBlock(0, 0, 0, 0xAB);
+ testassert(buffer.GetBlock(0, 0, 0) == 0xAB);
+ buffer.SetMeta(0, 16, 0, 0xC);
+ testassert(buffer.GetMeta(0, 16, 0) == 0xC);
// loaded but not written segments
- testassert(buffer.GetBlock(1,0,0) == 0x0);
- testassert(buffer.GetMeta(1,16,0) == 0x0);
+ testassert(buffer.GetBlock(1, 0, 0) == 0x0);
+ testassert(buffer.GetMeta(1, 16, 0) == 0x0);
// Notloaded segments
- testassert(buffer.GetBlock(0,32,0) == 0x0);
- testassert(buffer.GetMeta(0,48,0) == 0x0);
+ testassert(buffer.GetBlock(0, 32, 0) == 0x0);
+ testassert(buffer.GetMeta(0, 48, 0) == 0x0);
// Out of Range
CheckAsserts(
@@ -116,29 +110,29 @@ int main(int argc, char** argv)
cChunkData buffer(Pool);
// Zero's
- buffer.SetBlock(0,0,0, 0x0);
- buffer.SetBlock(0,0,1, 0xAB);
- testassert(buffer.GetBlock(0,0,0) == 0x0);
- testassert(buffer.GetBlock(0,0,1) == 0xAB);
+ buffer.SetBlock(0, 0, 0, 0x0);
+ buffer.SetBlock(0, 0, 1, 0xAB);
+ testassert(buffer.GetBlock(0, 0, 0) == 0x0);
+ testassert(buffer.GetBlock(0, 0, 1) == 0xAB);
- buffer.SetMeta(0,16,0, 0x0);
- buffer.SetMeta(0,16,1, 0xC);
- testassert(buffer.GetMeta(0,16,0) == 0x0);
- testassert(buffer.GetMeta(0,16,1) == 0xC);
+ buffer.SetMeta(0, 16, 0, 0x0);
+ buffer.SetMeta(0, 16, 1, 0xC);
+ testassert(buffer.GetMeta(0, 16, 0) == 0x0);
+ testassert(buffer.GetMeta(0, 16, 1) == 0xC);
}
{
// Operator =
cChunkData buffer(Pool);
- buffer.SetBlock(0,0,0,0x42);
+ buffer.SetBlock(0, 0, 0, 0x42);
cChunkData copy(Pool);
#if __cplusplus < 201103L
copy = buffer;
#else
copy = std::move(buffer);
#endif
- testassert(copy.GetBlock(0,0,0) == 0x42);
+ testassert(copy.GetBlock(0, 0, 0) == 0x42);
#if __cplusplus < 201103L
copy = copy;
#else
diff --git a/tests/ChunkData/Copies.cpp b/tests/ChunkData/Copies.cpp
index 1ccda9d9c..502a969e8 100644
--- a/tests/ChunkData/Copies.cpp
+++ b/tests/ChunkData/Copies.cpp
@@ -17,14 +17,14 @@ int main(int argc, char** argv)
{
cChunkData buffer(Pool);
- 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;
@@ -34,30 +34,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(Pool);
- 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;
@@ -67,30 +57,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(Pool);
- 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;
@@ -99,32 +80,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(Pool);
- 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;
@@ -134,68 +105,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(Pool);
- 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);
}
}
diff --git a/tests/TestGlobals.h b/tests/TestGlobals.h
index bb25bd20a..ea43de733 100644
--- a/tests/TestGlobals.h
+++ b/tests/TestGlobals.h
@@ -126,9 +126,9 @@ class cAssertFailure
#define UNUSED(X) (void)(X)
// Logging functions
-void LOGERROR(const char* a_Format, ...) FORMATSTRING(1,2);
+void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1,2);
-void LOGERROR(const char* a_Format, ...)
+void inline LOGERROR(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);