Refactor ConvertLangToSqlString and fix couple of bugs. Verify with unit tests.
This commit is contained in:
parent
5821c23439
commit
9ff0bada4e
3 changed files with 254 additions and 218 deletions
|
|
@ -61,6 +61,96 @@ TEST(ConvertLangToSqlString, testSemiColon)
|
|||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testWideLiteralL)
|
||||
{
|
||||
QString in(R"__( L"SELECT" )__");
|
||||
QString expected(R"__(SELECT)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testWideLiteralU)
|
||||
{
|
||||
QString in(R"__( U"SELECT" )__");
|
||||
QString expected(R"__(SELECT)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testUtf16Literal)
|
||||
{
|
||||
QString in(R"__( u"SELECT" )__");
|
||||
QString expected(R"__(SELECT)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testUtf8Literal)
|
||||
{
|
||||
QString in(R"__( u8"SELECT" )__");
|
||||
QString expected(R"__(SELECT)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testPrefixedLiteralConcat)
|
||||
{
|
||||
QString in(R"__( L"A" + "B" )__");
|
||||
QString expected(R"__(AB)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testUnicodeEscapeBmp)
|
||||
{
|
||||
QString in(R"__( "\U00000041" )__");
|
||||
QString expected(R"__(A)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testUnicodeEscapeSurrogatePair)
|
||||
{
|
||||
QString in(R"__( "\U0001F600" )__");
|
||||
QString expected = QString::fromUcs4(U"\U0001F600");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testUnicodeEscapeOutOfRange)
|
||||
{
|
||||
QString in(R"__( "AB\U00110000CD" )__");
|
||||
QString expected(R"__(AB)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testUnicodeEscapeSurrogateCodePoint)
|
||||
{
|
||||
QString in(R"__( "AB\U0000D800CD" )__");
|
||||
QString expected(R"__(AB)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
TEST(ConvertLangToSqlString, testHexEscapeInvalidDigit)
|
||||
{
|
||||
QString in(R"__( "AB\x4GCD" )__");
|
||||
QString expected(R"__(AB)__");
|
||||
|
||||
auto output = ConvertLangToSqlString(in);
|
||||
ASSERT_EQ(output, expected);
|
||||
}
|
||||
|
||||
//TEST(ConvertLangToSqlString, testComment)
|
||||
//{
|
||||
// QString in(R"__( "SELECT * " // comment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue