Merge pull request #235 from louisrubet/#225/remove_all_regex

Remove regex from test framework
This commit is contained in:
Louis Rubet 2022-02-24 12:12:34 +01:00 committed by GitHub
commit 59971292c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

@ -1 +1 @@
Subproject commit 3d3d594caf15b75517d9baea1f1860978cad771a Subproject commit 6a37ee0e9f117bb9950159545ecdbdbba41799bf

View file

@ -1,10 +1,21 @@
#include <regex>
using namespace std;
#include "escape.h" #include "escape.h"
#include "program.hpp" #include "program.hpp"
#include "version.h" #include "version.h"
static void _findAndReplaceAll(std::string & data, std::string toSearch, std::string replaceStr)
{
// Get the first occurrence
size_t pos = data.find(toSearch);
// Repeat till end is reached
while( pos != std::string::npos)
{
// Replace this occurrence of Sub String
data.replace(pos, toSearch.size(), replaceStr);
// Get the next occurrence from the current position
pos =data.find(toSearch, pos + replaceStr.size());
}
}
/// @brief write stack in a string, each entry separated between commas /// @brief write stack in a string, each entry separated between commas
/// ///
/// @param stack_is the output string /// @param stack_is the output string
@ -232,7 +243,7 @@ void program::test(string test_filename, int& total_tests, int& total_tests_fail
failed = true; failed = true;
} else { } else {
// parse entry and run line // parse entry and run line
entry = regex_replace(entry, regex("`"), ""); _findAndReplaceAll(entry, "`", "");
if (!entry.empty()) { if (!entry.empty()) {
program prog(stk, hp); program prog(stk, hp);
ret = prog.parse(entry); ret = prog.parse(entry);