Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: include/core/SkTypes.h

Issue 337243004: Add SkASSERTF. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkRefCnt.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTypes.h
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 15de8a4937b37cbd3456a91b52c013c47047068c..5ff57f807872e8bdd1624e9a3c526a994cf71bd5 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -115,6 +115,11 @@ inline void operator delete(void* p) {
#define SkFAIL(message) SK_ALWAYSBREAK(false && message)
+// We want to evaluate cond only once, and inside the SkASSERT somewhere so we see its string form.
+// So we use the comma operator to make an SkDebugf that always returns false: we'll evaluate cond,
+// and if it's true the assert passes; if it's false, we'll print the message and the assert fails.
+#define SkASSERTF(cond, fmt, ...) SkASSERT((cond) || (SkDebugf(fmt"\n", __VA_ARGS__), false))
+
#ifdef SK_DEVELOPER
#define SkDEVCODE(code) code
#else
« no previous file with comments | « include/core/SkRefCnt.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698