mirror of
https://github.com/pocoproject/poco.git
synced 2025-12-11 20:37:30 +01:00
* chore(CppParser): 0, NULL --> nullptr * chore(Crypto): 0, NULL --> nullptr * chore(DNSSD): 0, NULL --> nullptr * chore(Encodings): 0, NULL --> nullptr * chore(CppUnit): Correct indentation. * chore(Foundation): 0, NULL --> nullptr * chore(CMake): Always warn about wrong nullptr usage when compiling with GCC or CLang * chore(Net): 0, NULL --> nullptr * chore(Foundation): 0, NULL --> nullptr * chore(Data): 0, NULL --> nullptr * chore(macOS): 0, NULL --> nullptr * chore(XML): 0, NULL --> nullptr * chore(Zip): 0, NULL --> nullptr * chore(Util): 0, NULL --> nullptr * chore(Net/NetSSL): 0, NULL --> nullptr * chore(Bonjour): 0, NULL --> nullptr * chore(MongoDB, Redis): 0, NULL --> nullptr * chore(Poco): 0, NULL --> nullptr * chore(Win32): 0, NULL --> nullptr * chore(CMake): Only warn about nullptr when verbose warnings are enabled. * Potential fix for code scanning alert no. 1634: Guarded Free Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * chore(Net): Fix warning reported by gitlab. * chore(gitlab CI): attempt to clean to gain disk space on the runner. * chore(gitlab CI): Run build with --parallel 4, correct docker cleanup. --------- Co-authored-by: Aleksandar Fabijanic <aleks-f@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#include "thirdparty/microtest/microtest.h"
|
|
|
|
#include <iostream>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
#include "SQLParser.h"
|
|
#include "parser/bison_parser.h"
|
|
#include "sql_asserts.h"
|
|
|
|
using namespace hsql;
|
|
|
|
void test_tokens(const std::string& query, const std::vector<int16_t>& expected_tokens) {
|
|
std::vector<int16_t> tokens;
|
|
ASSERT(SQLParser::tokenize(query, &tokens));
|
|
|
|
ASSERT_EQ(expected_tokens.size(), tokens.size());
|
|
|
|
for (unsigned i = 0; i < expected_tokens.size(); ++i) {
|
|
ASSERT_EQ(expected_tokens[i], tokens[i]);
|
|
}
|
|
}
|
|
|
|
TEST(SQLParserTokenizeTest) {
|
|
test_tokens("SELECT * FROM test;", {SQL_SELECT, '*', SQL_FROM, SQL_IDENTIFIER, ';'});
|
|
test_tokens("SELECT a, 'b' FROM test WITH HINT;",
|
|
{SQL_SELECT, SQL_IDENTIFIER, ',', SQL_STRING, SQL_FROM, SQL_IDENTIFIER, SQL_WITH, SQL_HINT, ';'});
|
|
}
|
|
|
|
TEST(SQLParserTokenizeStringifyTest) {
|
|
const std::string query = "SELECT * FROM test;";
|
|
std::vector<int16_t> tokens;
|
|
ASSERT(SQLParser::tokenize(query, &tokens));
|
|
|
|
// Make u16string.
|
|
std::u16string token_string(tokens.cbegin(), tokens.cend());
|
|
|
|
// Check if u16 string is cacheable.
|
|
std::map<std::u16string, std::string> cache;
|
|
cache[token_string] = query;
|
|
|
|
ASSERT(query == cache[token_string]);
|
|
ASSERT(&query != &cache[token_string]);
|
|
}
|