From 024027db89ca833406147b79b7be74fc92906bbe Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 21 May 2014 19:58:48 +0100 Subject: Renamed cChunkBuffer to cChunkData --- tests/ChunkData/Coordinates.cpp | 143 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 tests/ChunkData/Coordinates.cpp (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp new file mode 100644 index 000000000..c0c46000e --- /dev/null +++ b/tests/ChunkData/Coordinates.cpp @@ -0,0 +1,143 @@ + +#include "TestGlobals.h" +#include "ChunkData.h" + + + +int main(int argc, char** argv) +{ + { + 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); + + // loaded but not written segments + 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); + + // Out of Range + CheckAsserts( + buffer.SetBlock(-1, 0, 0, 0); + ); + CheckAsserts( + buffer.SetBlock(0, -1, 0, 0); + ); + CheckAsserts( + buffer.SetBlock(0, 0, -1, 0); + ); + CheckAsserts( + buffer.SetBlock(256, 0, 0, 0); + ); + CheckAsserts( + buffer.SetBlock(0, 256, 0, 0); + ); + CheckAsserts( + buffer.SetBlock(0, 0, 256, 0); + ); + + // Out of Range + CheckAsserts( + buffer.GetBlock(-1, 0, 0); + ); + CheckAsserts( + buffer.GetBlock(0, -1, 0); + ); + CheckAsserts( + buffer.GetBlock(0, 0, -1); + ); + CheckAsserts( + buffer.GetBlock(256, 0, 0); + ); + CheckAsserts( + buffer.GetBlock(0, 256, 0); + ); + CheckAsserts( + buffer.GetBlock(0, 0, 256); + ); + + // Out of Range + CheckAsserts( + buffer.SetMeta(-1, 0, 0, 0); + ); + CheckAsserts( + buffer.SetMeta(0, -1, 0, 0); + ); + CheckAsserts( + buffer.SetMeta(0, 0, -1, 0); + ); + CheckAsserts( + buffer.SetMeta(256, 0, 0, 0); + ); + CheckAsserts( + buffer.SetMeta(0, 256, 0, 0); + ); + CheckAsserts( + buffer.SetMeta(0, 0, 256, 0); + ); + + // Out of Range + CheckAsserts( + buffer.GetMeta(-1, 0, 0); + ); + CheckAsserts( + buffer.GetMeta(0, -1, 0); + ); + CheckAsserts( + buffer.GetMeta(0, 0, -1); + ); + CheckAsserts( + buffer.GetMeta(256, 0, 0); + ); + CheckAsserts( + buffer.GetMeta(0, 256, 0); + ); + CheckAsserts( + buffer.GetMeta(0, 0, 256); + ); + } + + { + cChunkData buffer; + + // 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.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; + buffer.SetBlock(0,0,0,0x42); + cChunkData copy; + #if __cplusplus < 201103L + copy = buffer; + #else + copy = std::move(buffer); + #endif + testassert(copy.GetBlock(0,0,0) == 0x42); + #if __cplusplus < 201103L + copy = copy; + #else + copy = std::move(copy); + #endif + testassert(copy.GetBlock(0,0,0) == 0x42); + } + + return 0; +} -- cgit v1.2.3 From 8f964886e0ccbf51dac07227f0ac4c739b47d3a5 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 24 May 2014 13:33:40 +0100 Subject: Implemented style changes --- tests/ChunkData/Coordinates.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index c0c46000e..f02b68d40 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -10,18 +10,18 @@ int main(int argc, char** argv) 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( @@ -108,35 +108,35 @@ int main(int argc, char** argv) cChunkData buffer; // 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; - buffer.SetBlock(0,0,0,0x42); + buffer.SetBlock(0, 0, 0, 0x42); cChunkData copy; #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 copy = std::move(copy); #endif - testassert(copy.GetBlock(0,0,0) == 0x42); + testassert(copy.GetBlock(0, 0, 0) == 0x42); } return 0; -- cgit v1.2.3 From 19df18c46199f06f3bf2058cc0efee9126e7670a Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 27 May 2014 12:44:56 +0100 Subject: Fixed test globals to work with precompiled headers --- tests/ChunkData/Coordinates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index f02b68d40..938c66dcc 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -1,5 +1,5 @@ -#include "TestGlobals.h" +#include "Globals.h" #include "ChunkData.h" -- cgit v1.2.3 From e136f6e0f5b41ee7c9d784009ef40c9ac2e2e6fe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 11:35:29 +0200 Subject: Fixed cChunkData nibble copying. --- tests/ChunkData/Coordinates.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index 938c66dcc..48d731c7e 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -109,14 +109,14 @@ int main(int argc, char** argv) // Zero's buffer.SetBlock(0, 0, 0, 0x0); - buffer.SetBlock(0, 0, 1, 0xAB); + buffer.SetBlock(0, 0, 1, 0xab); testassert(buffer.GetBlock(0, 0, 0) == 0x0); - testassert(buffer.GetBlock(0, 0, 1) == 0xAB); + testassert(buffer.GetBlock(0, 0, 1) == 0xab); buffer.SetMeta(0, 16, 0, 0x0); - buffer.SetMeta(0, 16, 1, 0xC); + buffer.SetMeta(0, 16, 1, 0xc); testassert(buffer.GetMeta(0, 16, 0) == 0x0); - testassert(buffer.GetMeta(0, 16, 1) == 0xC); + testassert(buffer.GetMeta(0, 16, 1) == 0xc); } -- cgit v1.2.3 From ee50790398791c38e563eee04cf12780fab74baf Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 15:12:50 +0100 Subject: Merge branch 'master' of github.com:mc-server/MCServer --- tests/ChunkData/Coordinates.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'tests/ChunkData/Coordinates.cpp') diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp index 48d731c7e..b3c66dde5 100644 --- a/tests/ChunkData/Coordinates.cpp +++ b/tests/ChunkData/Coordinates.cpp @@ -6,8 +6,21 @@ int main(int argc, char** argv) { + class cMockAllocationPool + : public cAllocationPool + { + virtual cChunkData::sChunkSection * Allocate() + { + return new cChunkData::sChunkSection(); + } + + virtual void Free(cChunkData::sChunkSection * a_Ptr) + { + delete a_Ptr; + } + } Pool; { - cChunkData buffer; + cChunkData buffer(Pool); // Empty chunks buffer.SetBlock(0, 0, 0, 0xAB); @@ -105,7 +118,7 @@ int main(int argc, char** argv) } { - cChunkData buffer; + cChunkData buffer(Pool); // Zero's buffer.SetBlock(0, 0, 0, 0x0); @@ -122,9 +135,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 -- cgit v1.2.3