summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-05-27 13:44:56 +0200
committerTycho <work.tycho+git@gmail.com>2014-05-27 13:46:22 +0200
commit19df18c46199f06f3bf2058cc0efee9126e7670a (patch)
tree786ebe6c351eee68dc02f685b1e4c2c982178288 /src
parentinject TestGlobals.h correctly (diff)
downloadcuberite-19df18c46199f06f3bf2058cc0efee9126e7670a.tar
cuberite-19df18c46199f06f3bf2058cc0efee9126e7670a.tar.gz
cuberite-19df18c46199f06f3bf2058cc0efee9126e7670a.tar.bz2
cuberite-19df18c46199f06f3bf2058cc0efee9126e7670a.tar.lz
cuberite-19df18c46199f06f3bf2058cc0efee9126e7670a.tar.xz
cuberite-19df18c46199f06f3bf2058cc0efee9126e7670a.tar.zst
cuberite-19df18c46199f06f3bf2058cc0efee9126e7670a.zip
Diffstat (limited to 'src')
-rw-r--r--src/ChunkData.cpp4
-rw-r--r--src/Globals.h48
2 files changed, 36 insertions, 16 deletions
diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp
index 79029f0cf..c41dcb265 100644
--- a/src/ChunkData.cpp
+++ b/src/ChunkData.cpp
@@ -1,9 +1,5 @@
-#ifdef TEST_GLOBALS
-#include "TestGlobals.h"
-#else
#include "Globals.h"
-#endif
#include "ChunkData.h"
cChunkData::cChunkData()
diff --git a/src/Globals.h b/src/Globals.h
index 71e9191e4..85cfd2f18 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -225,16 +225,28 @@ template class SizeChecker<UInt16, 2>;
+#ifndef TEST_GLOBALS
+ // Common headers (part 1, without macros):
+ #include "StringUtils.h"
+ #include "OSSupport/Sleep.h"
+ #include "OSSupport/CriticalSection.h"
+ #include "OSSupport/Semaphore.h"
+ #include "OSSupport/Event.h"
+ #include "OSSupport/Thread.h"
+ #include "OSSupport/File.h"
+ #include "MCLogger.h"
+#else
+ // Logging functions
+void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1,2);
-// Common headers (part 1, without macros):
-#include "StringUtils.h"
-#include "OSSupport/Sleep.h"
-#include "OSSupport/CriticalSection.h"
-#include "OSSupport/Semaphore.h"
-#include "OSSupport/Event.h"
-#include "OSSupport/Thread.h"
-#include "OSSupport/File.h"
-#include "MCLogger.h"
+void inline LOGERROR(const char* a_Format, ...)
+{
+ va_list argList;
+ va_start(argList, a_Format);
+ vprintf(a_Format, argList);
+ va_end(argList);
+}
+#endif
@@ -253,10 +265,22 @@ template class SizeChecker<UInt16, 2>;
#define FAST_FLOOR_DIV( x, div ) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div))
// Own version of assert() that writes failed assertions to the log for review
-#ifdef _DEBUG
- #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) )
+#ifdef TEST_GLOBALS
+
+ class cAssertFailure
+ {
+ };
+
+ #define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0)
+ #define testassert(x) do { if(!(x)) { exit(1); } } while (0)
+ #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } exit(1); } while (0)
+
#else
- #define ASSERT(x) ((void)(x))
+ #ifdef _DEBUG
+ #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) )
+ #else
+ #define ASSERT(x) ((void)(x))
+ #endif
#endif
// Pretty much the same as ASSERT() but stays in Release builds