-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathTestRegex.cpp
More file actions
81 lines (68 loc) · 2.14 KB
/
TestRegex.cpp
File metadata and controls
81 lines (68 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "TestRegex.h"
#include "../Data.h"
#include <QtTest/QTest>
QTEST_APPLESS_MAIN(TestRegex)
void TestRegex::sqlQueryComments_data()
{
QTest::addColumn<QString>("dirtyQuery");
QTest::addColumn<QString>("clearQuery");
QTest::newRow("test1")
<< // dirtyQuery
"SELECT * -- asd ffdsf\n"
"-- saf ewf sf\n"
"-- dsaf fd\n"
"FROM \t-- sfsdf\n"
"qwfwqf -- asdasd"
<< // clearQuery
"SELECT *\nFROM\nqwfwqf";
QTest::newRow("test2")
<< // dirtyQuery
"SELECT *-- comment\n"
"FROM\n\n"
"-- something\n"
"qwfqwf"
<< // cleanQuery
"SELECT *\nFROM\nqwfqwf";
QTest::newRow("test3")
<< // dirtyQuery
"-- Comment before the query\n"
"SELECT * FROM test"
<< // cleanQuery
"SELECT * FROM test";
QTest::newRow("test4")
<< // dirtyQuery
"SELECT * FROM test\n"
"-- Comment after the query"
<< // cleanQuery
"SELECT * FROM test";
QTest::newRow("test5")
<< // dirtyQuery
"SELECT 40+2 -- get the answer\n"
"AS answer"
<< // cleanQuery
"SELECT 40+2\n"
"AS answer";
QTest::newRow("test6")
<< // dirtyQuery
"SELECT '-- comment inside quotes'"
<< // cleanQuery
"SELECT '-- comment inside quotes'";
QTest::newRow("single_quote_comment")
<< // dirtyQuery
"SELECT 'something--something' -- comment"
<< // cleanQuery
"SELECT 'something--something'";
/* This still needs to be fixed in our code before activating the test
QTest::newRow("double_quote_comment")
<< // dirtyQuery
"SELECT \"something--something\" -- comment"
<< // cleanQuery
"SELECT \"something--something\"";*/
}
void TestRegex::sqlQueryComments()
{
QFETCH(QString, dirtyQuery);
QFETCH(QString, clearQuery);
removeCommentsFromQuery(dirtyQuery);
QCOMPARE(dirtyQuery, clearQuery);
}