about summary refs log tree commit diff
path: root/src/debug.h
diff options
context:
space:
mode:
authorPjotr Prins2017-11-09 11:43:53 +0000
committerPjotr Prins2017-11-09 11:43:53 +0000
commitdbce439e7196ab6882634b270f2675b3ebcb33cd (patch)
tree4c593fa5594d1482ccbb57bf4d799e9d0529aebe /src/debug.h
parent4c158a9bb45e0dec14436a8a19707f485015bf2e (diff)
downloadpangemma-dbce439e7196ab6882634b270f2675b3ebcb33cd.tar.gz
Adding tests for bslmm
Diffstat (limited to 'src/debug.h')
-rw-r--r--src/debug.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/debug.h b/src/debug.h
index 29f6c69..6b82b3b 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -70,18 +70,18 @@ inline void fail_msg(std::string msg) {
 
 #if defined NDEBUG
 
-#define warning_msg(msg) cerr << "**** WARNING: " << msg << endl;
-#define debug_msg(msg)
-#define assert_issue(is_issue, expr)
+  #define warning_msg(msg) cerr << "**** WARNING: " << msg << endl;
+  #define debug_msg(msg)
+  #define assert_issue(is_issue, expr)
 
 #else // DEBUG
 
-#define warning_msg(msg) cerr << "**** WARNING: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __FUNCTION__ << endl;
-#define debug_msg(msg) (is_debug_mode() && cerr << "**** DEBUG: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __FUNCTION__ << endl);
-#define assert_issue(is_issue, expr) \
-  ((is_issue) ? enforce_msg(expr,"FAIL: ISSUE assert") : __ASSERT_VOID_CAST(0))
+  #define warning_msg(msg) cerr << "**** WARNING: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __FUNCTION__ << endl;
+  #define debug_msg(msg) (is_debug_mode() && cerr << "**** DEBUG: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __FUNCTION__ << endl);
+  #define assert_issue(is_issue, expr) \
+    ((is_issue) ? enforce_msg(expr,"FAIL: ISSUE assert") : __ASSERT_VOID_CAST(0))
 
-#endif
+#endif // NDEBUG
 
 // enforce works like assert but also when NDEBUG is set (i.e., it
 // always works). enforce_msg prints message instead of expr
@@ -122,4 +122,10 @@ inline void __enforce_fail(const char *__assertion, const char *__file,
        : __enforce_fail(gsl_strerror(COMBINE(res, __LINE__)), __FILE__,         \
                         __LINE__, __ASSERT_FUNCTION))
 
+#define enforce_fexists(fn, msg)                                               \
+  if (!fn.empty())                                                             \
+    enforce_msg(stat(fn.c_str(), &fileInfo) == 0,                              \
+                ((std::string(__STRING(fn)) + " " + fn + ": " + msg).c_str()));
+
+
 #endif