mirror of
https://github.com/louisrubet/rpn
synced 2025-02-07 08:45:48 +01:00
Merge pull request #235 from louisrubet/#225/remove_all_regex
Remove regex from test framework
This commit is contained in:
commit
59971292c8
2 changed files with 16 additions and 5 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 3d3d594caf15b75517d9baea1f1860978cad771a
|
||||
Subproject commit 6a37ee0e9f117bb9950159545ecdbdbba41799bf
|
|
@ -1,10 +1,21 @@
|
|||
#include <regex>
|
||||
using namespace std;
|
||||
|
||||
#include "escape.h"
|
||||
#include "program.hpp"
|
||||
#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
|
||||
///
|
||||
/// @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;
|
||||
} else {
|
||||
// parse entry and run line
|
||||
entry = regex_replace(entry, regex("`"), "");
|
||||
_findAndReplaceAll(entry, "`", "");
|
||||
if (!entry.empty()) {
|
||||
program prog(stk, hp);
|
||||
ret = prog.parse(entry);
|
||||
|
|
Loading…
Add table
Reference in a new issue