From caf7f8a4edd72e4334b2a39ab623a92fb6ded02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Thu, 11 Nov 2021 13:50:46 +0100 Subject: [PATCH] Added new test cases to 'test_tokenizer-t' for issue found and invalid comments --- test/tap/tests/test_tokenizer-t.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/tap/tests/test_tokenizer-t.cpp b/test/tap/tests/test_tokenizer-t.cpp index ab1621cf3..420947e47 100644 --- a/test/tap/tests/test_tokenizer-t.cpp +++ b/test/tap/tests/test_tokenizer-t.cpp @@ -26,6 +26,20 @@ using std::string; using std::tuple; const vector> query_digest_pairs { + // TODO: KnownIssue - 10 + // { + // "select /* COMMENT */ 1", + // "select ?" + // // Actual: "select ?# final_comment" + // }, + { + "select/* COMMENT */ 1", + "select ?" + }, + { + "select/* COMMENT */1", + "select ?" + }, // initial '#' comments { "# random_comment \n select 1.1", @@ -75,6 +89,11 @@ const vector> query_digest_pairs { "-- random_comment\n select 1.1-- final_comment \n", "select ?" }, + // NOTE: Comments with '--' should always be followed by an space. + // { + // "-- random_comment\n select 1.1--final_comment \n", + // "select ?" + // }, { "-- random_comment\n select 1.1 --final_comment \n ", "select ?" @@ -365,6 +384,7 @@ int main(int argc, char** argv) { for (size_t i = 0; i < query_digest_pairs.size(); i++) { const auto& query = query_digest_pairs[i].first; const auto& query_str_rep = replace_str(query_digest_pairs[i].first, "\n", "\\n"); + char* first_comment = NULL; std::string exp_res {}; if (replace_digits == false) { @@ -373,7 +393,7 @@ int main(int argc, char** argv) { exp_res = replace_numbers(query_digest_pairs[i].second, '?'); } - char* c_res = mysql_query_digest_and_first_comment(const_cast(query.c_str()), query.length(), NULL, buf); + char* c_res = mysql_query_digest_and_first_comment(const_cast(query.c_str()), query.length(), &first_comment, buf); const std::string result(c_res); std::string ok_msg {};