Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/interfaces
diff options
context:
space:
mode:
authorMartin Hořeňovský2026-02-09 19:05:39 +0100
committerMartin Hořeňovský2026-02-10 09:37:15 +0100
commitd079ee13ab137547ab26bd1ed5ca2858d7fbd847 (patch)
tree1e73da54d02eecbf095dd07bd4c0183d7a7f107b /src/catch2/interfaces
parent0056cd4efb01ab65f02af188e137fc65d79e18f8 (diff)
downloadcatch3-d079ee13ab137547ab26bd1ed5ca2858d7fbd847.tar.gz
Allow generators to declare themselves (infinite)
This will be useful later to implement warning on infinitely running `GENERATE` expressions.
Diffstat (limited to 'src/catch2/interfaces')
-rw-r--r--src/catch2/interfaces/catch_interfaces_generatortracker.cpp2
-rw-r--r--src/catch2/interfaces/catch_interfaces_generatortracker.hpp9
2 files changed, 11 insertions, 0 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_generatortracker.cpp b/src/catch2/interfaces/catch_interfaces_generatortracker.cpp
index 4ac23ddb..8442be4e 100644
--- a/src/catch2/interfaces/catch_interfaces_generatortracker.cpp
+++ b/src/catch2/interfaces/catch_interfaces_generatortracker.cpp
@@ -55,5 +55,7 @@ namespace Catch {
return m_stringReprCache;
}
+ bool GeneratorUntypedBase::isFinite() const { return true; }
+
} // namespace Generators
} // namespace Catch
diff --git a/src/catch2/interfaces/catch_interfaces_generatortracker.hpp b/src/catch2/interfaces/catch_interfaces_generatortracker.hpp
index eb3871bc..12cb9d79 100644
--- a/src/catch2/interfaces/catch_interfaces_generatortracker.hpp
+++ b/src/catch2/interfaces/catch_interfaces_generatortracker.hpp
@@ -88,6 +88,15 @@ namespace Catch {
* comes first.
*/
StringRef currentElementAsString() const;
+
+ /**
+ * Returns true if calls to `next` will eventually return false
+ *
+ * Note that for backwards compatibility this is currently defaulted
+ * to return `true`, but in the future all generators will have to
+ * provide their own implementation.
+ */
+ virtual bool isFinite() const;
};
using GeneratorBasePtr = Catch::Detail::unique_ptr<GeneratorUntypedBase>;