aboutsummaryrefslogtreecommitdiff
path: root/test/val/val_fixtures.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/val/val_fixtures.h')
-rw-r--r--test/val/val_fixtures.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/val/val_fixtures.h b/test/val/val_fixtures.h
index 5635c781..acbe0e57 100644
--- a/test/val/val_fixtures.h
+++ b/test/val/val_fixtures.h
@@ -183,4 +183,43 @@ spv_position_t ValidateBase<T>::getErrorPosition() {
} // namespace spvtest
+// For Vulkan testing.
+// Allows test parameter test to list all possible VUIDs with a delimiter that
+// is then split here to check if one VUID was in the error message
+MATCHER_P(AnyVUID, vuid_set, "VUID from the set is in error message") {
+ // use space as delimiter because clang-format will properly line break VUID
+ // strings which is important the entire VUID is in a single line for script
+ // to scan
+ std::string delimiter = " ";
+ std::string token;
+ std::string vuids = std::string(vuid_set);
+ size_t position;
+
+ // Catch case were someone accidentally left spaces by trimming string
+ // clang-format off
+ vuids.erase(std::find_if(vuids.rbegin(), vuids.rend(), [](unsigned char c) {
+ return (c != ' ');
+ }).base(), vuids.end());
+ vuids.erase(vuids.begin(), std::find_if(vuids.begin(), vuids.end(), [](unsigned char c) {
+ return (c != ' ');
+ }));
+ // clang-format on
+
+ do {
+ position = vuids.find(delimiter);
+ if (position != std::string::npos) {
+ token = vuids.substr(0, position);
+ vuids.erase(0, position + delimiter.length());
+ } else {
+ token = vuids.substr(0); // last item
+ }
+
+ // arg contains diagnostic message
+ if (arg.find(token) != std::string::npos) {
+ return true;
+ }
+ } while (position != std::string::npos);
+ return false;
+}
+
#endif // TEST_VAL_VAL_FIXTURES_H_