From 5a104986508969f4d09190b3071c95173c6df6fa Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 9 Sep 2014 15:50:27 +0100 Subject: Added a couple of basic tests --- tests/CMakeLists.txt | 1 + tests/Components/CMakeLists.txt | 13 +++++++++++++ tests/Components/Tick.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ tests/Components/creatable.cpp | 11 +++++++++++ 4 files changed, 66 insertions(+) create mode 100644 tests/Components/CMakeLists.txt create mode 100644 tests/Components/Tick.cpp create mode 100644 tests/Components/creatable.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1fbd88f04..07d6ab4ab 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(Components) diff --git a/tests/Components/CMakeLists.txt b/tests/Components/CMakeLists.txt new file mode 100644 index 000000000..ef46969ad --- /dev/null +++ b/tests/Components/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) + +enable_testing() + +include_directories(${CMAKE_SOURCE_DIR}/src/) + +add_definitions(-DTEST_GLOBALS=1) + +add_executable(BurningComponent-creatable-exe creatable.cpp) +add_test(NAME creatable-test COMMAND BurningComponent-creatable-exe) + +add_executable(BurningComponent-tick-exe Tick.cpp) +add_test(NAME tick-test COMMAND BurningComponent-tick-exe) diff --git a/tests/Components/Tick.cpp b/tests/Components/Tick.cpp new file mode 100644 index 000000000..fac47489b --- /dev/null +++ b/tests/Components/Tick.cpp @@ -0,0 +1,41 @@ + +#include "Globals.h" +#include "Mobs/Components/BurningComponent.h" + +int main(int argc, char** argv) +{ + class cMockEntity + { + public: + double GetPosX () { return 0;} + double GetPosY () { return 0;} + double GetPosZ () { return 0;} + + int GetChunkX () { return 0; } + int GetChunkZ () { return 0; } + + virtual bool IsOnFire () const { return false; } + void StartBurning(int a_TicksLeftBurning) {} + } Entity; + class cMockChunk + { + class cMockWorld + { + public: + void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = NULL) {} + virtual int GetTimeOfDay(void) const { return 0;} + virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) { return true; } + } mutable m_World; + public: + bool IsLightValid(void) { return true; } + inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const { return 0; } + cMockWorld * GetWorld(void) const { return &m_World; } + BLOCKTYPE GetBlock (int a_BlockX, int a_BlockY, int a_BlockZ) { return 0; } + } chunk; + cBurningComponent component(Entity); + + component.Tick(1.0f/20.0f, chunk); + + + return 0; +} diff --git a/tests/Components/creatable.cpp b/tests/Components/creatable.cpp new file mode 100644 index 000000000..bf96720c6 --- /dev/null +++ b/tests/Components/creatable.cpp @@ -0,0 +1,11 @@ + +#include "Globals.h" +#include "Mobs/Components/BurningComponent.h" + +int main(int argc, char** argv) +{ + class cMockEntity {} Entity; + class cMockChunk {}; + cBurningComponent component(Entity); + return 0; +} -- cgit v1.2.3