diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ChunkData/ArraytoCoord.cpp | 15 | ||||
-rw-r--r-- | tests/ChunkData/Coordinates.cpp | 18 | ||||
-rw-r--r-- | tests/ChunkData/Copies.cpp | 18 | ||||
-rw-r--r-- | tests/ChunkData/creatable.cpp | 10 |
4 files changed, 47 insertions, 14 deletions
diff --git a/tests/ChunkData/ArraytoCoord.cpp b/tests/ChunkData/ArraytoCoord.cpp index 0daf38f7b..80bcc5283 100644 --- a/tests/ChunkData/ArraytoCoord.cpp +++ b/tests/ChunkData/ArraytoCoord.cpp @@ -6,9 +6,18 @@ 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())); + { + // Test first segment - cChunkData buffer; + cChunkData buffer(Pool); BLOCKTYPE SrcBlockBuffer[16 * 16 * 256]; memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer)); @@ -35,7 +44,7 @@ int main(int argc, char** argv) { // test following segment - cChunkData buffer; + cChunkData buffer(Pool); BLOCKTYPE SrcBlockBuffer[16 * 16 * 256]; memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer)); @@ -62,7 +71,7 @@ int main(int argc, char** argv) { // test zeros - cChunkData buffer; + cChunkData buffer(Pool); BLOCKTYPE SrcBlockBuffer[16 * 16 * 256]; memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer)); diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index 48d731c7e..d5abbb143 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -6,8 +6,16 @@ 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; + cChunkData buffer(Pool); // Empty chunks buffer.SetBlock(0, 0, 0, 0xAB); @@ -105,7 +113,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); // Zero's buffer.SetBlock(0, 0, 0, 0x0); @@ -122,9 +130,9 @@ int main(int argc, char** argv) { // Operator = - cChunkData buffer; + cChunkData buffer(Pool); buffer.SetBlock(0, 0, 0, 0x42); - cChunkData copy; + cChunkData copy(Pool); #if __cplusplus < 201103L copy = buffer; #else @@ -136,7 +144,7 @@ int main(int argc, char** argv) #else copy = std::move(copy); #endif - testassert(copy.GetBlock(0, 0, 0) == 0x42); + testassert(copy.GetBlock(0,0,0) == 0x42); } return 0; diff --git a/tests/ChunkData/Copies.cpp b/tests/ChunkData/Copies.cpp index 312441eee..6f5d40792 100644 --- a/tests/ChunkData/Copies.cpp +++ b/tests/ChunkData/Copies.cpp @@ -6,8 +6,16 @@ int main(int argc, char** argv) { + class cStarvationCallbacks + : public cAllocationPool<cChunkData::sChunkSection,1600>::cStarvationCallbacks { - cChunkData buffer; + 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); buffer.SetBlock(3, 1, 4, 0xDE); buffer.SetMeta(3, 1, 4, 0xA); @@ -37,7 +45,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2]; for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) @@ -60,7 +68,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2]; for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) @@ -83,7 +91,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2]; for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) @@ -106,7 +114,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); BLOCKTYPE SrcBlockBuffer[16 * 16 * 256]; memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); diff --git a/tests/ChunkData/creatable.cpp b/tests/ChunkData/creatable.cpp index 1321bf49b..0dde8cf3b 100644 --- a/tests/ChunkData/creatable.cpp +++ b/tests/ChunkData/creatable.cpp @@ -4,6 +4,14 @@ int main(int argc, char** argv) { - cChunkData buffer; + 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); return 0; } |