@@ -109,6 +109,18 @@ create_result: (resultExpr: std::string, r) -> std::string = {
109
109
return result;
110
110
}
111
111
112
+ sanitize: (copy str: std::string) -> std::string =
113
+ {
114
+ str = cpp2::string_util::replace_all(str, "\a", "\\a");
115
+ str = cpp2::string_util::replace_all(str, "\f", "\\f");
116
+ str = cpp2::string_util::replace_all(str, "\x1b", "\\e");
117
+ str = cpp2::string_util::replace_all(str, "\n", "\\n");
118
+ str = cpp2::string_util::replace_all(str, "\r", "\\r");
119
+ str = cpp2::string_util::replace_all(str, "\t", "\\t");
120
+
121
+ return str;
122
+ }
123
+
112
124
test: <M> (regex: M, id: std::string, regex_str: std::string, str: std::string, kind: std::string, resultExpr: std::string,
113
125
resultExpected: std::string) = {
114
126
@@ -131,7 +143,7 @@ test: <M> (regex: M, id: std::string, regex_str: std::string, str: std::string,
131
143
result := create_result(resultExpr, r);
132
144
133
145
if result != resultExpected {
134
- status = "Failure: Result is wrong. (is: (result)$)";
146
+ status = "Failure: Result is wrong. (is: (sanitize( result) )$)";
135
147
}
136
148
}
137
149
}
@@ -146,7 +158,7 @@ test: <M> (regex: M, id: std::string, regex_str: std::string, str: std::string,
146
158
if !warning.empty() {
147
159
warning += " ";
148
160
}
149
- std::cout << "(id)$_(kind)$: (status)$ (warning)$regex: (regex_str)$ parsed_regex: (regex.to_string())$ str: (str)$ result_expr: (resultExpr)$ expected_results (resultExpected)$" << std::endl;
161
+ std::cout << "(id)$_(kind)$: (status)$ (warning)$regex: (regex_str)$ parsed_regex: (regex.to_string())$ str: (sanitize( str)) $ result_expr: (resultExpr)$ expected_results (sanitize( resultExpected) )$" << std::endl;
150
162
}
151
163
152
164
0 commit comments