From 8bc3e68bd198d130689b1e32c5f738daae7dcb0c Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Fri, 21 May 2021 17:30:58 +0000 Subject: [PATCH] ParamGenerator: Return the end iterator if any param is empty Not doing so produces an infinite loop when iterating from begin to end. Bug: none Change-Id: I323587a19ba1618d7e9a326de2ee398ae5e0bb7b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/51762 Auto-Submit: Austin Eng Reviewed-by: Brandon Jones Reviewed-by: Kai Ninomiya Commit-Queue: Brandon Jones --- src/tests/ParamGenerator.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tests/ParamGenerator.h b/src/tests/ParamGenerator.h index 213756a025..8f8dc08665 100644 --- a/src/tests/ParamGenerator.h +++ b/src/tests/ParamGenerator.h @@ -46,7 +46,10 @@ class ParamGenerator { public: using value_type = ParamStruct; - ParamGenerator(std::vector... params) : mParams(params...) { + ParamGenerator(std::vector... params) : mParams(params...), mIsEmpty(false) { + for (bool isEmpty : {params.empty()...}) { + mIsEmpty |= isEmpty; + } } class Iterator : public std::iterator { @@ -94,6 +97,9 @@ class ParamGenerator { }; Iterator begin() const { + if (mIsEmpty) { + return end(); + } return Iterator(mParams, {}); } @@ -105,6 +111,7 @@ class ParamGenerator { private: ParamTuple mParams; + bool mIsEmpty; }; struct BackendTestConfig;