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/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index 455fc69..d831e5e 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -21,11 +21,9 @@
static void report_opaqueness(skiatest::Reporter* reporter, const SkBitmap& src,
const SkBitmap& dst) {
- SkString str;
- str.printf("src %s opaque:%d, dst %s opaque:%d",
- gConfigName[src.config()], src.isOpaque(),
- gConfigName[dst.config()], dst.isOpaque());
- reporter->reportFailed(str);
+ ERRORF(reporter, "src %s opaque:%d, dst %s opaque:%d",
+ gConfigName[src.config()], src.isOpaque(),
+ gConfigName[dst.config()], dst.isOpaque());
}
static bool canHaveAlpha(SkBitmap::Config config) {
@@ -192,10 +190,7 @@
}
if (!success) {
- SkString str;
- str.printf("%s [config = %s]",
- msg, getSkConfigName(bm1));
- reporter->reportFailed(str);
+ ERRORF(reporter, "%s [config = %s]", msg, getSkConfigName(bm1));
}
}
@@ -247,20 +242,16 @@
bool success = srcPremul.copyTo(&dst, gPairs[j].fConfig);
bool expected = gPairs[i].fValid[j] != '0';
if (success != expected) {
- SkString str;
- str.printf("SkBitmap::copyTo from %s to %s. expected %s returned %s",
- gConfigName[i], gConfigName[j], boolStr(expected),
- boolStr(success));
- reporter->reportFailed(str);
+ ERRORF(reporter, "SkBitmap::copyTo from %s to %s. expected %s "
+ "returned %s", gConfigName[i], gConfigName[j],
+ boolStr(expected), boolStr(success));
}
bool canSucceed = srcPremul.canCopyTo(gPairs[j].fConfig);
if (success != canSucceed) {
- SkString str;
- str.printf("SkBitmap::copyTo from %s to %s. returned %s canCopyTo %s",
- gConfigName[i], gConfigName[j], boolStr(success),
- boolStr(canSucceed));
- reporter->reportFailed(str);
+ ERRORF(reporter, "SkBitmap::copyTo from %s to %s. returned %s "
+ "canCopyTo %s", gConfigName[i], gConfigName[j],
+ boolStr(success), boolStr(canSucceed));
}
if (success) {
@@ -345,10 +336,8 @@
100000000U);
int64_t safeSize = tstSafeSize.computeSafeSize64();
if (safeSize < 0) {
- SkString str;
- str.printf("getSafeSize64() negative: %s",
- getSkConfigName(tstSafeSize));
- reporter->reportFailed(str);
+ ERRORF(reporter, "getSafeSize64() negative: %s",
+ getSkConfigName(tstSafeSize));
}
bool sizeFail = false;
// Compare against hand-computed values.
@@ -380,10 +369,8 @@
break;
}
if (sizeFail) {
- SkString str;
- str.printf("computeSafeSize64() wrong size: %s",
- getSkConfigName(tstSafeSize));
- reporter->reportFailed(str);
+ ERRORF(reporter, "computeSafeSize64() wrong size: %s",
+ getSkConfigName(tstSafeSize));
}
int subW = 2;