Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Measure the table strings with std::string and regenerate the amalgamation

The self tests are also built as C++14 (Meson with Clang-CL), where
std::string_view does not exist. The amalgamated source carries the
change to Process.cpp.

Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
Commit
0cc73f2c53f40a172dd5bbfee0c96d25599d9dba
Author
Leitwolf11 ·
Parents
a6c83f1bfaf4

Files · Download .tar.gz

Changes

 extras/catch_amalgamated.cpp                   | 7 ++++++-
 tests/SelfTest/UsageTests/Generators.tests.cpp | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp
index a5dc580c..475c5ea8 100644
--- a/extras/catch_amalgamated.cpp
+++ b/extras/catch_amalgamated.cpp
@@ -16957,7 +16957,12 @@ namespace Progmasoft::Catch3::Runner
         std::string buffer(size, '\0');
         if (_NSGetExecutablePath(buffer.data(), &size) == 0)
         {
-            buffer.resize(std::strlen(buffer.c_str()));
+            // The path ends at its first NUL, never past the buffer.
+            const auto end = buffer.find('\0');
+            if (end != std::string::npos)
+            {
+                buffer.resize(end);
+            }
             auto canonical = std::filesystem::weakly_canonical(buffer, error);
             return error ? std::filesystem::path{ buffer } : canonical;
         }
diff --git a/tests/SelfTest/UsageTests/Generators.tests.cpp b/tests/SelfTest/UsageTests/Generators.tests.cpp
index 77ffde8d..41138b5a 100644
--- a/tests/SelfTest/UsageTests/Generators.tests.cpp
+++ b/tests/SelfTest/UsageTests/Generators.tests.cpp
@@ -12,7 +12,7 @@
 #include <Progmasoft/Catch3/Generators/Random.hpp>
 #include <Progmasoft/Catch3/Generators/Range.hpp>
 
-#include <string_view>
+#include <string>
 
 
 // Generators and sections can be nested freely
@@ -62,7 +62,7 @@ TEST_CASE("tables", "[generators]") {
         tuple_type{"etc...", 6}
     }));
 
-    REQUIRE(std::string_view(std::get<0>(data)).size() == static_cast<size_t>(std::get<1>(data)));
+    REQUIRE(std::string(std::get<0>(data)).size() == static_cast<size_t>(std::get<1>(data)));
 }