Add REPORTF test macro.
This macro replaces:
SkString str;
str.printf("Foo test Expected %d got %d", x, y);
reporter->reportFailed(str);
with the shorter code:
REPORTF(reporter, ("Foo test Expected %d got %d", x, y));
The new form also appends __FILE__:__LINE__ to the message before calling reportFailed().
BUG=
R=mtklein@google.com
Review URL: https://codereview.chromium.org/132843002
git-svn-id: http://skia.googlecode.com/svn/trunk@13016 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/Test.h b/tests/Test.h
index 1c89f98..ff6b4ac 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -89,23 +89,31 @@
typedef SkTRegistry<Test*(*)(void*)> TestRegistry;
}
-#define REPORTER_ASSERT(r, cond) \
- do { \
- if (!(cond)) { \
- SkString desc; \
- desc.printf("%s:%d: %s", __FILE__, __LINE__, #cond); \
- r->reportFailed(desc); \
- } \
+#define REPORTER_ASSERT(r, cond) \
+ do { \
+ if (!(cond)) { \
+ SkString desc; \
+ desc.printf("%s:%d\t%s", __FILE__, __LINE__, #cond); \
+ r->reportFailed(desc); \
+ } \
} while(0)
-#define REPORTER_ASSERT_MESSAGE(r, cond, message) \
- do { \
- if (!(cond)) { \
- SkString desc; \
- desc.printf("%s %s:%d: %s", message, __FILE__, __LINE__, #cond); \
- r->reportFailed(desc); \
- } \
+#define REPORTER_ASSERT_MESSAGE(r, cond, message) \
+ do { \
+ if (!(cond)) { \
+ SkString desc; \
+ desc.printf("%s:%d\t%s: %s", __FILE__, __LINE__, \
+ message, #cond); \
+ r->reportFailed(desc); \
+ } \
} while(0)
+#define ERRORF(reporter, ...) \
+ do { \
+ SkString desc; \
+ desc.printf("%s:%d\t", __FILE__, __LINE__); \
+ desc.appendf(__VA_ARGS__) ; \
+ (reporter)->reportFailed(desc); \
+ } while(0)
#endif