GM: allow caller to specify which result types trigger an error
Review URL: https://codereview.chromium.org/14187007
git-svn-id: http://skia.googlecode.com/svn/trunk@8652 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gm_error.h b/gm/gm_error.h
index 1691743..e442f5d 100644
--- a/gm/gm_error.h
+++ b/gm/gm_error.h
@@ -58,6 +58,22 @@
}
/**
+ * Fills in "type" with the ErrorType associated with name "name".
+ * Returns true if we found one, false if it is an unknown type name.
+ */
+ static bool getErrorTypeByName(const char name[], ErrorType *type) {
+ for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
+ ErrorType thisType = static_cast<ErrorType>(typeInt);
+ const char *thisTypeName = getErrorTypeName(thisType);
+ if (0 == strcmp(thisTypeName, name)) {
+ *type = thisType;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* A combination of 0 or more ErrorTypes.
*/
class ErrorCombination {
@@ -94,6 +110,26 @@
}
/**
+ * Returns a string representation of all ErrorTypes in this
+ * ErrorCombination.
+ *
+ * @param separator text with which to separate ErrorType names
+ */
+ SkString asString(const char separator[]) const {
+ SkString s;
+ for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
+ ErrorType type = static_cast<ErrorType>(typeInt);
+ if (this->includes(type)) {
+ if (!s.isEmpty()) {
+ s.append(separator);
+ }
+ s.append(getErrorTypeName(type));
+ }
+ }
+ return s;
+ }
+
+ /**
* Returns a new ErrorCombination, which includes the union of all
* ErrorTypes in two ErrorCombination objects (this and other).
*/