Skip to content

Commit

Permalink
squash w/ [3902] Replace GenQuery1 ad-hoc parsing code with flex/biso…
Browse files Browse the repository at this point in the history
…n parser.
  • Loading branch information
korydraughn committed Dec 12, 2024
1 parent e3c2413 commit 366d704
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions unit_tests/src/test_genquery1_flex_bison_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <catch2/catch.hpp>

//#include "boost/algorithm/string/replace.hpp"
#include "irods/irods_at_scope_exit.hpp"
#include "irods/irods_default_paths.hpp"
#include "irods/rcMisc.h"
Expand All @@ -15,7 +14,7 @@
#include <vector>

// NOLINTNEXTLINE(readability-function-cognitive-complexity)
TEST_CASE("genquery1 flex bison parser maintains backward compatibility")
TEST_CASE("GenQuery1 flex bison parser maintains backward compatibility with original GenQuery1 parser")
{
// IMPORTANT: This test assumes all queries CAN be parsed into a valid GenQuery1
// input struct.
Expand All @@ -27,31 +26,18 @@ TEST_CASE("genquery1 flex bison parser maintains backward compatibility")
REQUIRE(in);

std::size_t iteration = 0;
std::size_t skipped = 0;
std::string query;
genQueryInp_t input1{};
genQueryInp_t input2{};

while (std::getline(in, query)) {
INFO(fmt::format("Query {} = [{}]", iteration++, query))

if (query.find("\\x27") != std::string::npos) {
++skipped;
continue;
}

irods::at_scope_exit_unsafe clear_input_structs{[&input1, &input2] {
clearGenQueryInp(&input1);
clearGenQueryInp(&input2);
}};

// The query may contain escaped single quotes. This has to do with how the queries
// were captured. The original GenQuery1 parser does not understand hex-encoded bytes
// so the test must unescape them. The new parser will convert the hex-encoded bytes
// to their unescaped form automatically. Without this, the string-based comparisons
// involving embedded single quotes would always fail.
//auto unescaped_query = boost::replace_all_copy(query, "\\x27", "'");

// Parse the query string into a genQueryInp_t struct.
const auto ec1 = fillGenQueryInpFromStrCond(query.data(), &input1);
const auto ec2 = parse_genquery1_string(query.c_str(), &input2);
Expand Down Expand Up @@ -95,6 +81,4 @@ TEST_CASE("genquery1 flex bison parser maintains backward compatibility")
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
}
}

SUCCEED("Queries: total=[" << iteration << "], skipped=[" << skipped << ']');
}

0 comments on commit 366d704

Please sign in to comment.