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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/interfaces/catch_interfaces_generatortracker.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-05-16 16:34:06 +0200
committerMartin Hořeňovský2022-05-16 16:34:06 +0200
commit48f322697434292206db570e8fbe1e3ac8728d0b (patch)
treeb19176f822bad7fb0eb3fd4b1ee50b762c654db5 /src/catch2/interfaces/catch_interfaces_generatortracker.cpp
parentaf8b54ecd59f8174aaaa97682e3544f2820a0900 (diff)
downloadcatch3-48f322697434292206db570e8fbe1e3ac8728d0b.tar.gz
Add support for retrieving generator's element as string
Diffstat (limited to 'src/catch2/interfaces/catch_interfaces_generatortracker.cpp')
-rw-r--r--src/catch2/interfaces/catch_interfaces_generatortracker.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_generatortracker.cpp b/src/catch2/interfaces/catch_interfaces_generatortracker.cpp
new file mode 100644
index 00000000..e8c67b54
--- /dev/null
+++ b/src/catch2/interfaces/catch_interfaces_generatortracker.cpp
@@ -0,0 +1,32 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+
+#include <catch2/interfaces/catch_interfaces_generatortracker.hpp>
+#include <string>
+
+namespace Catch {
+ namespace Generators {
+
+ bool GeneratorUntypedBase::countedNext() {
+ auto ret = next();
+ if ( ret ) {
+ m_stringReprCache.clear();
+ ++m_currentElementIndex;
+ }
+ return ret;
+ }
+
+ StringRef GeneratorUntypedBase::currentElementAsString() const {
+ if ( m_stringReprCache.empty() ) {
+ m_stringReprCache = stringifyImpl();
+ }
+ return m_stringReprCache;
+ }
+
+ } // namespace Generators
+} // namespace Catch