From d9f6c691cc7ecf005618611fa0f32d854f8f87ff Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 1 Sep 2014 21:31:27 +0200 Subject: CopyBlocks test: decreased the test size. It just needlessly ate up test time; there's no need for such rigorous testing once the test started succeeding. --- tests/ChunkData/CopyBlocks.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/ChunkData/CopyBlocks.cpp b/tests/ChunkData/CopyBlocks.cpp index ec9451099..99f416e94 100644 --- a/tests/ChunkData/CopyBlocks.cpp +++ b/tests/ChunkData/CopyBlocks.cpp @@ -45,7 +45,7 @@ int main(int argc, char ** argv) BLOCKTYPE * WritePosition = &TestBuffer[WritePosIdx]; memset(TestBuffer, 0x03, sizeof(TestBuffer)); size_t LastReportedStep = 1; - for (size_t idx = 0; idx < 5000; idx += 7) + for (size_t idx = 0; idx < 5000; idx += 73) { if (idx / 500 != LastReportedStep) { @@ -53,7 +53,7 @@ int main(int argc, char ** argv) LastReportedStep = idx / 500; } - for (size_t len = 3; len < 1000; len += 13) + for (size_t len = 3; len < 700; len += 13) { Data.CopyBlockTypes(WritePosition, idx, len); -- cgit v1.2.3 From 6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 17 Sep 2014 18:40:10 +0100 Subject: Added first test to show the object can be created --- tests/CMakeLists.txt | 1 + tests/Redstone/CMakeLists.txt | 10 +++ tests/Redstone/creatable.cpp | 162 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 tests/Redstone/CMakeLists.txt create mode 100644 tests/Redstone/creatable.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1fbd88f04..7e21ff94f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,3 +5,4 @@ enable_testing() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(ChunkData) +add_subdirectory(Redstone) diff --git a/tests/Redstone/CMakeLists.txt b/tests/Redstone/CMakeLists.txt new file mode 100644 index 000000000..ee4a7a64f --- /dev/null +++ b/tests/Redstone/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required (VERSION 2.6) + +enable_testing() + +include_directories(${CMAKE_SOURCE_DIR}/src/) + +add_definitions(-DTEST_GLOBALS=1) + +add_executable(Redstone-creatable-exe creatable.cpp ../../src/BoundingBox.cpp) +add_test(NAME creatable-test COMMAND Redstone-creatable-exe) diff --git a/tests/Redstone/creatable.cpp b/tests/Redstone/creatable.cpp new file mode 100644 index 000000000..07b800f9b --- /dev/null +++ b/tests/Redstone/creatable.cpp @@ -0,0 +1,162 @@ + +#include "Globals.h" + +class MockChest; +typedef cItemCallback cChestCallback; + +AString ItemToFullString(const cItem & a_Item) +{ +return ""; +} + +class cEntity +{ +public: + const Vector3d & GetPosition (void) const { return m_pos;} + double GetWidth (void) const { return 0; } + double GetHeight (void) const { return 0; } + static const Vector3d m_pos; +}; + +const Vector3d cEntity::m_pos = Vector3d(0,0,0); + +class cItem +{ +public: + cItem(BLOCKTYPE val) {} +}; + +void cBlockInfo::Initialize(cBlockInfoArray & a_Info) {} +cBlockInfo::~cBlockInfo () {} + +#include "Blocks/ChunkInterface.h" + +bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) +{ + return false; +} + +bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) +{ + return false; +} + +#include "Simulator/Simulator.inc" + +#include "Simulator/IncrementalRedstoneSimulator.inc" + +class MockWorld; + + +class MockHandler +{ +public: + static eBlockFace MetadataToDirection(NIBBLETYPE a_MetaData) { return BLOCK_FACE_NONE; } + static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) { return BLOCK_FACE_NONE; } + static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_MetaData) { return BLOCK_FACE_NONE; } + static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { return 0; } + static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, MockWorld * a_World) {} + static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, MockWorld * a_World) {} + static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) {} + +}; + +template +class MockHandlerFetcher +{ +public: + typedef MockHandler type; +}; + +class MockWorld +{ +public: + bool IsChunkLighted(int a_ChunkX, int a_ChunkZ) { return false; } + bool ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback & a_Callback) { return false; } + + void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = NULL) {} + + + NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ) { return 0; } + + cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true) { return NULL; } + + + void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) {} + + void SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1) {} + + + bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) {return false; } + + + cChunkMap * GetChunkMap (void) { return NULL; } + +}; + + +class MockChunk +{ +public: + cRedstoneSimulatorChunkData * GetRedstoneSimulatorData() { return NULL; } + bool IsRedstoneDirty() { return true; } + void SetIsRedstoneDirty(bool a_Param) {} + + void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) {} + + void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true) {} + void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) {} + + int GetPosX(void) const { return 0; } + int GetPosZ(void) const { return 0; } + + MockChunk * GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ) const { return NULL; } + + + BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const { return 0; } + BLOCKTYPE GetBlock(const Vector3i & a_RelCoords) const { return 0; } + + NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const { return 0; } + void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) {} + + + bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const { return false; } + + bool UnboundedRelGetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType) const { return false; } + + MockChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ) { return NULL; } + + MockChunk * GetRelNeighborChunk(int a_RelX, int a_RelZ) { return NULL; } + + bool IsValid(void) const { return false; } + + NIBBLETYPE GetTimeAlteredLight(NIBBLETYPE a_Skylight) const { return 0; } + + void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL) {} + void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) {} + + bool DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cRedstonePoweredCallback & a_Callback) { return false; } + + template + bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, T & a_Callback) + { + return false; + } + +}; + +int main(int argc, char** argv) +{ + + class MockChest + { + public: + BLOCKTYPE GetBlockType(void) const { return 0; } + int GetNumberOfPlayers(void) const { return 0; } + }; + + MockWorld World; + + cIncrementalRedstoneSimulator Simulator(World); + return 0; +} -- cgit v1.2.3 From 73dfe1fe81a4b60dc8b67a0caaba16d83c56e136 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 17 Sep 2014 18:59:45 +0100 Subject: Fix accedental c++11 --- tests/Redstone/creatable.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/Redstone/creatable.cpp b/tests/Redstone/creatable.cpp index 07b800f9b..f26ebe85c 100644 --- a/tests/Redstone/creatable.cpp +++ b/tests/Redstone/creatable.cpp @@ -144,16 +144,17 @@ public: } }; +class MockChest +{ +public: + BLOCKTYPE GetBlockType(void) const { return 0; } + int GetNumberOfPlayers(void) const { return 0; } +}; int main(int argc, char** argv) { - class MockChest - { - public: - BLOCKTYPE GetBlockType(void) const { return 0; } - int GetNumberOfPlayers(void) const { return 0; } - }; + MockWorld World; -- cgit v1.2.3 From c40f65ad83d3e873e4831fc3a39b2c86a96ebd05 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sat, 27 Sep 2014 15:29:11 +0100 Subject: Update creatable.cpp --- tests/Redstone/creatable.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/Redstone/creatable.cpp b/tests/Redstone/creatable.cpp index f26ebe85c..02c622788 100644 --- a/tests/Redstone/creatable.cpp +++ b/tests/Redstone/creatable.cpp @@ -99,6 +99,7 @@ class MockChunk { public: cRedstoneSimulatorChunkData * GetRedstoneSimulatorData() { return NULL; } + void SetRedstoneSimulatorData(cRedstoneSimulatorChunkData * a_Data) {} bool IsRedstoneDirty() { return true; } void SetIsRedstoneDirty(bool a_Param) {} -- cgit v1.2.3