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

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPetr Ledvina2019-05-01 19:12:44 +0200
committerMartin Hořeňovský2019-05-01 19:12:44 +0200
commit9c741fe96073ed620ffc032afbed1f3c789d2b68 (patch)
tree3c11b9f54f95a71b0d2874e343afebeaae203d2b /include
parent979bbf03bb00bc55ca09783791b5091a2247df68 (diff)
downloadcatch3-9c741fe96073ed620ffc032afbed1f3c789d2b68.tar.gz
Allow quotes in CAPTURE arguments (#1608)
* Allow quotes in CAPTURE arguments Fix CAPTURE to handle string and character literals properly
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_message.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/internal/catch_message.cpp b/include/internal/catch_message.cpp
index fa7e8746..69e48211 100644
--- a/include/internal/catch_message.cpp
+++ b/include/internal/catch_message.cpp
@@ -9,6 +9,7 @@
#include "catch_message.h"
#include "catch_interfaces_capture.h"
#include "catch_uncaught_exceptions.h"
+#include "catch_enforce.h"
#include <cassert>
#include <stack>
@@ -76,6 +77,15 @@ namespace Catch {
}
return names.substr(start, end - start + 1);
};
+ auto skipq = [&] (size_t start, char quote) {
+ for (auto i = start + 1; i < names.size() ; ++i) {
+ if (names[i] == quote)
+ return i;
+ if (names[i] == '\\')
+ ++i;
+ }
+ CATCH_INTERNAL_ERROR("CAPTURE parsing encountered unmatched parentheses");
+ };
size_t start = 0;
std::stack<char> openings;
@@ -96,6 +106,10 @@ namespace Catch {
// case '>':
openings.pop();
break;
+ case '"':
+ case '\'':
+ pos = skipq(pos, c);
+ break;
case ',':
if (start != pos && openings.size() == 0) {
m_messages.emplace_back(macroName, lineInfo, resultType);