|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtTest/QtTest> |
|
19 #include <QStringList> |
|
20 #include <QLocale> |
|
21 |
|
22 #include "ut_cntsqlsearch.h" |
|
23 #include "cntsqlsearch.h" |
|
24 |
|
25 #define WRITE_LOGS |
|
26 #define SQL_QT_TEST |
|
27 |
|
28 #if defined(WRITE_LOGS) |
|
29 #include <e32debug.h> // RDebug |
|
30 |
|
31 #define LOG(a) WriteLog(a, "") |
|
32 #define LOG2(a, b) WriteLog(a, b) |
|
33 #define TEST_BEGIN_LOG(a) LOG(a##" begins") |
|
34 #define TEST_PASSED_LOG(a) LOG(a##" passed") |
|
35 |
|
36 void WriteLog(const QString a, const QString b); |
|
37 void WritePart(const TDesC& s); |
|
38 #else |
|
39 #define LOG(a) |
|
40 #define LOG2(a, b) |
|
41 #define TEST_BEGIN_LOG(a) |
|
42 #define TEST_PASSED_LOG(a) |
|
43 #endif |
|
44 |
|
45 |
|
46 void UT_CntSqlSearch::initTestCase() |
|
47 { |
|
48 } |
|
49 |
|
50 void UT_CntSqlSearch::cleanupTestCase() |
|
51 { |
|
52 } |
|
53 |
|
54 |
|
55 void UT_CntSqlSearch::init() |
|
56 { |
|
57 mCntSqlSearch = new CntSqlSearch(); |
|
58 } |
|
59 |
|
60 void UT_CntSqlSearch::cleanup() |
|
61 { |
|
62 delete mCntSqlSearch; |
|
63 mCntSqlSearch = 0; |
|
64 |
|
65 } |
|
66 void UT_CntSqlSearch::testPredictiveSearch() |
|
67 { |
|
68 TEST_BEGIN_LOG("testPredictiveSearch"); |
|
69 |
|
70 QString pattern = QString("205"); |
|
71 #if defined(SEARCH_FROM_ONE_TABLE) |
|
72 #if defined(USE_DEMORGAN) |
|
73 QString reference("SELECT contact_id FROM predictivesearch2 WHERE NOT(NOT(NOT(NOT(nbr>145522562959409151 AND nbr<145804037936119808) AND NOT(nbr2>145522562959409151 AND nbr2<145804037936119808) AND NOT(nbr3>145522562959409151 AND nbr3<145804037936119808) AND NOT(nbr4>145522562959409151 AND nbr4<145804037936119808))) AND NOT(NOT(NOT(nbr2>360287970189639679 AND nbr2<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr3>144115188075855871 AND nbr3<216172782113783808))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>360287970189639679 AND nbr3<432345564227567616)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
74 #else // #if defined(USE_DEMORGAN) |
|
75 QString reference("SELECT contact_id FROM predictivesearch2 WHERE \ |
|
76 ((nbr>145522562959409151 AND nbr<145804037936119808) OR (nbr2>145522562959409151 AND nbr2<145804037936119808) \ |
|
77 OR (nbr3>145522562959409151 AND nbr3<145804037936119808) OR (nbr4>145522562959409151 AND nbr4<145804037936119808)) OR \ |
|
78 (nbr2>360287970189639679 AND nbr2<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
79 (nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
80 (nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
81 (nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
82 (nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
83 (nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr3>144115188075855871 AND nbr3<216172782113783808) OR \ |
|
84 (nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) OR \ |
|
85 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) OR \ |
|
86 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) OR \ |
|
87 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) OR \ |
|
88 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) OR \ |
|
89 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>360287970189639679 AND nbr3<432345564227567616) \ |
|
90 ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
91 #endif // #if defined(USE_DEMORGAN) |
|
92 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
93 QString reference("SELECT predictivesearch2.contact_id FROM predictivesearch2 WHERE EXISTS (SELECT contact_id FROM predictivesearch5 WHERE predictivesearch2.contact_id = predictivesearch5.contact_id) OR (SELECT contact_id FROM predictivesearch2 WHERE (NOT(NOT(predictivesearch2.nbr>145522562959409151 AND predictivesearch2.nbr<145804037936119808) AND NOT(predictivesearch2.nbr2>145522562959409151 AND predictivesearch2.nbr2<145804037936119808) AND NOT(predictivesearch2.nbr3>145522562959409151 AND predictivesearch2.nbr3<145804037936119808) AND NOT(predictivesearch2.nbr4>145522562959409151 AND predictivesearch2.nbr4<145804037936119808)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
94 #endif // #if defined(SEARCH_FROM_ONE_TABLE) |
|
95 QString result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
96 //qDebug() << pattern << "-> result" << result; |
|
97 LOG2(pattern, result); |
|
98 LOG2(QString("Reference"), reference); |
|
99 QVERIFY(!result.compare(reference)); |
|
100 |
|
101 pattern = QString("101"); |
|
102 #if defined(USE_DEMORGAN) |
|
103 reference = QString("SELECT contact_id FROM predictivesearch1 WHERE NOT(NOT(NOT(NOT(nbr>72339069014638591 AND nbr<72620543991349248) AND NOT(nbr2>72339069014638591 AND nbr2<72620543991349248) AND NOT(nbr3>72339069014638591 AND nbr3<72620543991349248) AND NOT(nbr4>72339069014638591 AND nbr4<72620543991349248))) AND NOT(NOT(NOT(nbr2>72057594037927935 AND nbr2<144115188075855872 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr2>72057594037927935 AND nbr2<144115188075855872) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr2>72057594037927935 AND nbr2<144115188075855872) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr3>72057594037927935 AND nbr3<144115188075855872)))) ORDER BY predictivesearch1.first_name, predictivesearch1.last_name ASC;"); |
|
104 #else |
|
105 reference = QString("SELECT contact_id FROM predictivesearch1 WHERE ((nbr>72339069014638591 AND nbr<72620543991349248) OR (nbr2>72339069014638591 AND nbr2<72620543991349248) OR (nbr3>72339069014638591 AND nbr3<72620543991349248) OR (nbr4>72339069014638591 AND nbr4<72620543991349248)) OR (nbr2>72057594037927935 AND nbr2<144115188075855872 AND nbr>72057594037927935 AND nbr<144115188075855872) OR (nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr>72057594037927935 AND nbr<144115188075855872) OR (nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr2>72057594037927935 AND nbr2<144115188075855872) OR (nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr>72057594037927935 AND nbr<144115188075855872) OR (nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr2>72057594037927935 AND nbr2<144115188075855872) OR (nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr3>72057594037927935 AND nbr3<144115188075855872) ORDER BY predictivesearch1.first_name, predictivesearch1.last_name ASC;"); |
|
106 #endif |
|
107 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
108 qDebug() << pattern << " -> result" << result; |
|
109 LOG2(pattern, result); |
|
110 QVERIFY(!result.compare(reference)); |
|
111 |
|
112 pattern = QString("202"); |
|
113 #if defined(USE_DEMORGAN) |
|
114 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE NOT(NOT(NOT(NOT(nbr>144678138029277183 AND nbr<144959613005987840) AND NOT(nbr2>144678138029277183 AND nbr2<144959613005987840) AND NOT(nbr3>144678138029277183 AND nbr3<144959613005987840) AND NOT(nbr4>144678138029277183 AND nbr4<144959613005987840))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>144115188075855871 AND nbr3<216172782113783808)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
115 #else |
|
116 reference = QString("TODO"); |
|
117 #endif |
|
118 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
119 //qDebug() << pattern << " -> result" << result; |
|
120 LOG2(pattern, result); |
|
121 //QVERIFY(!result.compare(reference)); |
|
122 |
|
123 pattern = QString("25"); |
|
124 #if defined(USE_DEMORGAN) |
|
125 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE (NOT(NOT(nbr>166633186212708351 AND nbr<171136785840078848) AND NOT(nbr2>166633186212708351 AND nbr2<171136785840078848) AND NOT(nbr3>166633186212708351 AND nbr3<171136785840078848) AND NOT(nbr4>166633186212708351 AND nbr4<171136785840078848))) ORDER BY first_name, last_name ASC;"); |
|
126 #else |
|
127 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE (NOT(NOT(nbr>166633186212708351 AND nbr<171136785840078848) AND NOT(nbr2>166633186212708351 AND nbr2<171136785840078848) AND NOT(nbr3>166633186212708351 AND nbr3<171136785840078848) AND NOT(nbr4>166633186212708351 AND nbr4<171136785840078848))) ORDER BY first_name, last_name ASC;"); |
|
128 #endif |
|
129 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
130 //qDebug() << pattern << " -> result" << result; |
|
131 LOG2(pattern, result); |
|
132 QVERIFY(!result.compare( reference)); |
|
133 |
|
134 |
|
135 pattern = QString("56606"); |
|
136 #if defined(SEARCH_FROM_ONE_TABLE) |
|
137 #if defined(USE_DEMORGAN) |
|
138 reference = QString("SELECT contact_id FROM predictivesearch5 WHERE NOT(NOT(NOT(NOT(nbr>389005014883893247 AND nbr<389006114395521024) AND NOT(nbr2>389005014883893247 AND nbr2<389006114395521024) AND NOT(nbr3>389005014883893247 AND nbr3<389006114395521024) AND NOT(nbr4>389005014883893247 AND nbr4<389006114395521024))) AND NOT(NOT(NOT(nbr2>432345564227567615 AND nbr2<504403158265495552 AND nbr>388998417814126591 AND nbr<389279892790837248) AND NOT(nbr3>432345564227567615 AND nbr3<504403158265495552 AND nbr>388998417814126591 AND nbr<389279892790837248) AND NOT(nbr3>432345564227567615 AND nbr3<504403158265495552 AND nbr2>388998417814126591 AND nbr2<389279892790837248) AND NOT(nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr>388998417814126591 AND nbr<389279892790837248) AND NOT(nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr2>388998417814126591 AND nbr2<389279892790837248) AND NOT(nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr3>388998417814126591 AND nbr3<389279892790837248))) AND NOT(NOT(NOT(nbr2>388998417814126591 AND nbr2<389279892790837248 AND nbr>432345564227567615 AND nbr<504403158265495552) AND NOT(nbr3>388998417814126591 AND nbr3<389279892790837248 AND nbr>432345564227567615 AND nbr<504403158265495552) AND NOT(nbr3>388998417814126591 AND nbr3<389279892790837248 AND nbr2>432345564227567615 AND nbr2<504403158265495552) AND NOT(nbr4>388998417814126591 AND nbr4<389279892790837248 AND nbr>432345564227567615 AND nbr<504403158265495552) AND NOT(nbr4>388998417814126591 AND nbr4<389279892790837248 AND nbr2>432345564227567615 AND nbr2<504403158265495552) AND NOT(nbr4>388998417814126591 AND nbr4<389279892790837248 AND nbr3>432345564227567615 AND nbr3<504403158265495552)))) ORDER BY predictivesearch5.first_name, predictivesearch5.last_name ASC;"); |
|
139 #else // #if defined(USE_DEMORGAN) |
|
140 reference = QString("SELECT contact_id FROM predictivesearch5 WHERE \ |
|
141 ((nbr>389005014883893247 AND nbr<389006114395521024) OR (nbr2>389005014883893247 AND nbr2<389006114395521024) OR \ |
|
142 (nbr3>389005014883893247 AND nbr3<389006114395521024) OR (nbr4>389005014883893247 AND nbr4<389006114395521024)) OR \ |
|
143 (nbr2>432345564227567615 AND nbr2<504403158265495552 AND nbr>388998417814126591 AND nbr<389279892790837248) OR \ |
|
144 (nbr3>432345564227567615 AND nbr3<504403158265495552 AND nbr>388998417814126591 AND nbr<389279892790837248) OR \ |
|
145 (nbr3>432345564227567615 AND nbr3<504403158265495552 AND nbr2>388998417814126591 AND nbr2<389279892790837248) OR \ |
|
146 (nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr>388998417814126591 AND nbr<389279892790837248) OR \ |
|
147 (nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr2>388998417814126591 AND nbr2<389279892790837248) OR \ |
|
148 (nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr3>388998417814126591 AND nbr3<389279892790837248) OR \ |
|
149 (nbr2>388998417814126591 AND nbr2<389279892790837248 AND nbr>432345564227567615 AND nbr<504403158265495552) OR \ |
|
150 (nbr3>388998417814126591 AND nbr3<389279892790837248 AND nbr>432345564227567615 AND nbr<504403158265495552) OR \ |
|
151 (nbr3>388998417814126591 AND nbr3<389279892790837248 AND nbr2>432345564227567615 AND nbr2<504403158265495552) OR \ |
|
152 (nbr4>388998417814126591 AND nbr4<389279892790837248 AND nbr>432345564227567615 AND nbr<504403158265495552) OR \ |
|
153 (nbr4>388998417814126591 AND nbr4<389279892790837248 AND nbr2>432345564227567615 AND nbr2<504403158265495552) OR \ |
|
154 (nbr4>388998417814126591 AND nbr4<389279892790837248 AND nbr3>432345564227567615 AND nbr3<504403158265495552) \ |
|
155 ORDER BY predictivesearch5.first_name, predictivesearch5.last_name ASC;"); |
|
156 #endif //#if defined(USE_DEMORGAN) |
|
157 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
158 reference = QString("SELECT contact_id FROM (SELECT predictivesearch5.contact_id, predictivesearch5.first_name, predictivesearch5.last_name FROM predictivesearch5 WHERE (NOT(NOT(predictivesearch5.nbr>389005014883893247 AND predictivesearch5.nbr<389006114395521024) AND NOT(predictivesearch5.nbr2>389005014883893247 AND predictivesearch5.nbr2<389006114395521024) AND NOT(predictivesearch5.nbr3>389005014883893247 AND predictivesearch5.nbr3<389006114395521024) AND NOT(predictivesearch5.nbr4>389005014883893247 AND predictivesearch5.nbr4<389006114395521024))) UNION SELECT predictivesearch5.contact_id, predictivesearch5.first_name, predictivesearch5.last_name FROM predictivesearch5 JOIN predictivesearch6 ON predictivesearch5.contact_id = predictivesearch6.contact_id WHERE(NOT(NOT(predictivesearch5.nbr>388998417814126591 AND predictivesearch5.nbr<389279892790837248) AND NOT(predictivesearch5.nbr2>388998417814126591 AND predictivesearch5.nbr2<389279892790837248) AND NOT(predictivesearch5.nbr3>388998417814126591 AND predictivesearch5.nbr3<389279892790837248) AND NOT(predictivesearch5.nbr4>388998417814126591 AND predictivesearch5.nbr4<389279892790837248)))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
159 #endif // #if defined(SEARCH_FROM_ONE_TABLE) |
|
160 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
161 //qDebug() << pattern << " -> result" << result; |
|
162 LOG2(pattern, result); |
|
163 QVERIFY( !result.compare( reference) ); |
|
164 |
|
165 pattern = QString("3"); |
|
166 reference = QString ("SELECT contact_id FROM predictivesearch3 ORDER BY first_name, last_name ASC;"); |
|
167 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
168 //qDebug() << pattern << " -> result" << result; |
|
169 LOG2(pattern, result); |
|
170 QVERIFY( !result.compare( reference) ); |
|
171 |
|
172 pattern = QString("0"); |
|
173 reference = QString ("SELECT contact_id FROM predictivesearch0 ORDER BY first_name, last_name ASC;"); |
|
174 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
175 //qDebug() << pattern << " -> result" << result; |
|
176 LOG2(pattern, result); |
|
177 QVERIFY(!result.compare( reference)); |
|
178 |
|
179 // TODO: Test this case on HW and verify leading zeros. |
|
180 pattern.clear(); |
|
181 pattern = "0705"; |
|
182 #if defined(SEARCH_FROM_ONE_TABLE) |
|
183 #if defined(USE_DEMORGAN) |
|
184 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE NOT(NOT(NOT(NOT(nbr>31613158321815551 AND nbr<31630750507859968) AND NOT(nbr2>31613158321815551 AND nbr2<31630750507859968) AND NOT(nbr3>31613158321815551 AND nbr3<31630750507859968) AND NOT(nbr4>31613158321815551 AND nbr4<31630750507859968))) AND NOT(NOT(NOT(nbr2>360287970189639679 AND nbr2<432345564227567616 AND nbr>31525197391593471 AND nbr<36028797018963968) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr>31525197391593471 AND nbr<36028797018963968) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr2>31525197391593471 AND nbr2<36028797018963968) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr>31525197391593471 AND nbr<36028797018963968) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr2>31525197391593471 AND nbr2<36028797018963968) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr3>31525197391593471 AND nbr3<36028797018963968))) AND NOT(NOT(NOT(nbr2>31525197391593471 AND nbr2<36028797018963968 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr3>31525197391593471 AND nbr3<36028797018963968 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr3>31525197391593471 AND nbr3<36028797018963968 AND nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr4>31525197391593471 AND nbr4<36028797018963968 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr4>31525197391593471 AND nbr4<36028797018963968 AND nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr4>31525197391593471 AND nbr4<36028797018963968 AND nbr3>360287970189639679 AND nbr3<432345564227567616)))) ORDER BY predictivesearch0.first_name, predictivesearch0.last_name ASC;"); |
|
185 #else // #if defined(USE_DEMORGAN) |
|
186 |
|
187 #endif //#if defined(USE_DEMORGAN) |
|
188 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
189 reference = QString("SELECT contact_id FROM (SELECT predictivesearch0.contact_id, predictivesearch0.first_name, predictivesearch0.last_name FROM predictivesearch0 WHERE (NOT(NOT(predictivesearch0.nbr>31613158321815551 AND predictivesearch0.nbr<31630750507859968) AND NOT(predictivesearch0.nbr2>31613158321815551 AND predictivesearch0.nbr2<31630750507859968) AND NOT(predictivesearch0.nbr3>31613158321815551 AND predictivesearch0.nbr3<31630750507859968) AND NOT(predictivesearch0.nbr4>31613158321815551 AND predictivesearch0.nbr4<31630750507859968))) UNION SELECT predictivesearch0.contact_id, predictivesearch0.first_name, predictivesearch0.last_name FROM predictivesearch0 JOIN predictivesearch5 ON predictivesearch0.contact_id = predictivesearch5.contact_id WHERE(NOT(NOT(predictivesearch0.nbr>31525197391593471 AND predictivesearch0.nbr<36028797018963968) AND NOT(predictivesearch0.nbr2>31525197391593471 AND predictivesearch0.nbr2<36028797018963968) AND NOT(predictivesearch0.nbr3>31525197391593471 AND predictivesearch0.nbr3<36028797018963968) AND NOT(predictivesearch0.nbr4>31525197391593471 AND predictivesearch0.nbr4<36028797018963968)))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
190 #endif // #if defined(SEARCH_FROM_ONE_TABLE) |
|
191 |
|
192 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
193 //qDebug() << pattern << result; |
|
194 LOG2(pattern, result); |
|
195 QVERIFY(!result.compare(reference)); |
|
196 |
|
197 pattern.clear(); |
|
198 pattern = "4301"; |
|
199 #if defined(SEARCH_FROM_ONE_TABLE) |
|
200 #if defined(USE_DEMORGAN) |
|
201 reference = QString("SELECT contact_id FROM predictivesearch4 WHERE NOT(NOT(NOT(NOT(nbr>301758767219867647 AND nbr<301776359405912064) AND NOT(nbr2>301758767219867647 AND nbr2<301776359405912064) AND NOT(nbr3>301758767219867647 AND nbr3<301776359405912064) AND NOT(nbr4>301758767219867647 AND nbr4<301776359405912064))) AND NOT(NOT(NOT(nbr2>72057594037927935 AND nbr2<144115188075855872 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr2>301741175033823231 AND nbr2<306244774661193728) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr2>301741175033823231 AND nbr2<306244774661193728) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr3>301741175033823231 AND nbr3<306244774661193728))) AND NOT(NOT(NOT(nbr2>301741175033823231 AND nbr2<306244774661193728 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr3>301741175033823231 AND nbr3<306244774661193728 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr3>301741175033823231 AND nbr3<306244774661193728 AND nbr2>72057594037927935 AND nbr2<144115188075855872) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr2>72057594037927935 AND nbr2<144115188075855872) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr3>72057594037927935 AND nbr3<144115188075855872)))) ORDER BY predictivesearch4.first_name, predictivesearch4.last_name ASC;"); |
|
202 #else // #if defined(USE_DEMORGAN) |
|
203 |
|
204 #endif //#if defined(USE_DEMORGAN) |
|
205 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
206 reference = QString("SELECT contact_id FROM (SELECT predictivesearch4.contact_id, predictivesearch4.first_name, predictivesearch4.last_name FROM predictivesearch4 WHERE (NOT(NOT(predictivesearch4.nbr>301758767219867647 AND predictivesearch4.nbr<301776359405912064) AND NOT(predictivesearch4.nbr2>301758767219867647 AND predictivesearch4.nbr2<301776359405912064) AND NOT(predictivesearch4.nbr3>301758767219867647 AND predictivesearch4.nbr3<301776359405912064) AND NOT(predictivesearch4.nbr4>301758767219867647 AND predictivesearch4.nbr4<301776359405912064))) UNION SELECT predictivesearch4.contact_id, predictivesearch4.first_name, predictivesearch4.last_name FROM predictivesearch4 JOIN predictivesearch1 ON predictivesearch4.contact_id = predictivesearch1.contact_id WHERE(NOT(NOT(predictivesearch4.nbr>301741175033823231 AND predictivesearch4.nbr<306244774661193728) AND NOT(predictivesearch4.nbr2>301741175033823231 AND predictivesearch4.nbr2<306244774661193728) AND NOT(predictivesearch4.nbr3>301741175033823231 AND predictivesearch4.nbr3<306244774661193728) AND NOT(predictivesearch4.nbr4>301741175033823231 AND predictivesearch4.nbr4<306244774661193728)))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
207 #endif // #if defined(SEARCH_FROM_ONE_TABLE) |
|
208 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
209 //qDebug() << pattern << result; |
|
210 LOG2(pattern, result); |
|
211 QVERIFY(!result.compare(reference)); |
|
212 |
|
213 pattern.clear(); |
|
214 pattern = "4304"; |
|
215 #if defined(USE_DEMORGAN) |
|
216 reference = QString("SELECT contact_id FROM predictivesearch4 WHERE NOT(NOT(NOT(NOT(nbr>301811543778000895 AND nbr<301829135964045312) AND NOT(nbr2>301811543778000895 AND nbr2<301829135964045312) AND NOT(nbr3>301811543778000895 AND nbr3<301829135964045312) AND NOT(nbr4>301811543778000895 AND nbr4<301829135964045312))) AND NOT(NOT(NOT(nbr2>288230376151711743 AND nbr2<360287970189639680 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr3>288230376151711743 AND nbr3<360287970189639680 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr3>288230376151711743 AND nbr3<360287970189639680 AND nbr2>301741175033823231 AND nbr2<306244774661193728) AND NOT(nbr4>288230376151711743 AND nbr4<360287970189639680 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr4>288230376151711743 AND nbr4<360287970189639680 AND nbr2>301741175033823231 AND nbr2<306244774661193728) AND NOT(nbr4>288230376151711743 AND nbr4<360287970189639680 AND nbr3>301741175033823231 AND nbr3<306244774661193728))) AND NOT(NOT(NOT(nbr2>301741175033823231 AND nbr2<306244774661193728 AND nbr>288230376151711743 AND nbr<360287970189639680) AND NOT(nbr3>301741175033823231 AND nbr3<306244774661193728 AND nbr>288230376151711743 AND nbr<360287970189639680) AND NOT(nbr3>301741175033823231 AND nbr3<306244774661193728 AND nbr2>288230376151711743 AND nbr2<360287970189639680) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr>288230376151711743 AND nbr<360287970189639680) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr2>288230376151711743 AND nbr2<360287970189639680) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr3>288230376151711743 AND nbr3<360287970189639680)))) ORDER BY predictivesearch4.first_name, predictivesearch4.last_name ASC;"); |
|
217 #else |
|
218 //TODO: |
|
219 #endif |
|
220 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
221 //qDebug() << pattern << result; |
|
222 LOG2(pattern, result); |
|
223 QVERIFY(!result.compare(reference)); |
|
224 |
|
225 pattern.clear(); |
|
226 pattern = "4043"; |
|
227 #if defined(USE_DEMORGAN) |
|
228 reference = QString("SELECT contact_id FROM predictivesearch4 WHERE NOT(NOT(NOT(NOT(nbr>289409052616687615 AND nbr<289426644802732032) AND NOT(nbr2>289409052616687615 AND nbr2<289426644802732032) AND NOT(nbr3>289409052616687615 AND nbr3<289426644802732032) AND NOT(nbr4>289409052616687615 AND nbr4<289426644802732032))) AND NOT(NOT(NOT(nbr2>301741175033823231 AND nbr2<306244774661193728 AND nbr>288230376151711743 AND nbr<360287970189639680) AND NOT(nbr3>301741175033823231 AND nbr3<306244774661193728 AND nbr>288230376151711743 AND nbr<360287970189639680) AND NOT(nbr3>301741175033823231 AND nbr3<306244774661193728 AND nbr2>288230376151711743 AND nbr2<360287970189639680) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr>288230376151711743 AND nbr<360287970189639680) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr2>288230376151711743 AND nbr2<360287970189639680) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr3>288230376151711743 AND nbr3<360287970189639680))) AND NOT(NOT(NOT(nbr2>288230376151711743 AND nbr2<360287970189639680 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr3>288230376151711743 AND nbr3<360287970189639680 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr3>288230376151711743 AND nbr3<360287970189639680 AND nbr2>301741175033823231 AND nbr2<306244774661193728) AND NOT(nbr4>288230376151711743 AND nbr4<360287970189639680 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr4>288230376151711743 AND nbr4<360287970189639680 AND nbr2>301741175033823231 AND nbr2<306244774661193728) AND NOT(nbr4>288230376151711743 AND nbr4<360287970189639680 AND nbr3>301741175033823231 AND nbr3<306244774661193728)))) ORDER BY predictivesearch4.first_name, predictivesearch4.last_name ASC;"); |
|
229 #else |
|
230 //TODO: |
|
231 #endif |
|
232 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
233 //qDebug() << pattern << result; |
|
234 LOG2(pattern, result); |
|
235 QVERIFY(!result.compare(reference)); |
|
236 |
|
237 pattern = QString("03"); |
|
238 #if defined(USE_DEMORGAN) |
|
239 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE (NOT(NOT(nbr>13510798882111487 AND nbr<18014398509481984) AND NOT(nbr2>13510798882111487 AND nbr2<18014398509481984) AND NOT(nbr3>13510798882111487 AND nbr3<18014398509481984) AND NOT(nbr4>13510798882111487 AND nbr4<18014398509481984))) ORDER BY first_name, last_name ASC;"); |
|
240 #else |
|
241 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE (nbr>13510798882111487 AND nbr<18014398509481984) OR (nbr2>13510798882111487 AND nbr2<18014398509481984) OR (nbr3>13510798882111487 AND nbr3<18014398509481984) OR (nbr4>13510798882111487 AND nbr4<18014398509481984) ORDER BY first_name, last_name ASC;"); |
|
242 #endif |
|
243 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
244 //qDebug() << pattern << " -> result" << result; |
|
245 LOG2(pattern, result); |
|
246 QVERIFY(!result.compare( reference)); |
|
247 |
|
248 // Empty pattern |
|
249 pattern = QString(""); |
|
250 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
251 //qDebug() << pattern << " -> result" << result; |
|
252 LOG2(pattern, result); |
|
253 QVERIFY(result.length() == 0); |
|
254 |
|
255 // Too long pattern (16 digits) |
|
256 pattern = QString("0123456789012345"); |
|
257 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
258 //qDebug() << pattern << " -> result" << result; |
|
259 LOG2(pattern, result); |
|
260 QVERIFY(result.length() == 0); |
|
261 |
|
262 pattern = QString("0000000000000000"); // 16 zeros |
|
263 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
264 //qDebug() << pattern << " -> result" << result; |
|
265 LOG2(pattern, result); |
|
266 QVERIFY(result.length() == 0); |
|
267 |
|
268 // Full of zeros |
|
269 pattern = QString("000000000000000"); // 15 zeros |
|
270 #if defined(USE_DEMORGAN) |
|
271 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE (NOT(NOT(nbr>-1 AND nbr<1) AND NOT(nbr2>-1 AND nbr2<1) AND NOT(nbr3>-1 AND nbr3<1) AND NOT(nbr4>-1 AND nbr4<1))) ORDER BY first_name, last_name ASC;"); |
|
272 #else |
|
273 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE (nbr>-1 AND nbr<1) OR (nbr2>-1 AND nbr2<1) OR (nbr3>-1 AND nbr3<1) OR (nbr4>-1 AND nbr4<1) ORDER BY first_name, last_name ASC;"); |
|
274 #endif |
|
275 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
276 //qDebug() << pattern << " -> result" << result; |
|
277 LOG2(pattern, result); |
|
278 QVERIFY(!result.compare(reference)); |
|
279 |
|
280 // Full of nines |
|
281 pattern = QString("999999999999999"); // 15 nines |
|
282 #if defined(USE_DEMORGAN) |
|
283 reference = QString("SELECT contact_id FROM predictivesearch9 WHERE (NOT(NOT(nbr>691752902764108184 AND nbr<691752902764108186) AND NOT(nbr2>691752902764108184 AND nbr2<691752902764108186) AND NOT(nbr3>691752902764108184 AND nbr3<691752902764108186) AND NOT(nbr4>691752902764108184 AND nbr4<691752902764108186))) ORDER BY first_name, last_name ASC;"); |
|
284 #else |
|
285 reference = QString("SELECT contact_id FROM predictivesearch9 WHERE (nbr>691752902764108184 AND nbr<691752902764108186) OR (nbr2>691752902764108184 AND nbr2<691752902764108186) OR (nbr3>691752902764108184 AND nbr3<691752902764108186) OR (nbr4>691752902764108184 AND nbr4<691752902764108186) ORDER BY first_name, last_name ASC;"); |
|
286 #endif |
|
287 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
288 //qDebug() << pattern << " -> result" << result; |
|
289 LOG2(pattern, result); |
|
290 QVERIFY(!result.compare(reference)); |
|
291 |
|
292 // Leading zeros |
|
293 pattern = QString("001100"); |
|
294 #if defined(USE_DEMORGAN) |
|
295 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE (NOT(NOT(nbr>299067162755071 AND nbr<299135882231808) AND NOT(nbr2>299067162755071 AND nbr2<299135882231808) AND NOT(nbr3>299067162755071 AND nbr3<299135882231808) AND NOT(nbr4>299067162755071 AND nbr4<299135882231808))) ORDER BY first_name, last_name ASC;"); |
|
296 #else |
|
297 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE (nbr>299067162755071 AND nbr<299135882231808) OR (nbr2>299067162755071 AND nbr2<299135882231808) OR (nbr3>299067162755071 AND nbr3<299135882231808) OR (nbr4>299067162755071 AND nbr4<299135882231808) ORDER BY first_name, last_name ASC;"); |
|
298 #endif |
|
299 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
300 //qDebug() << pattern << " -> result" << result; |
|
301 LOG2(pattern, result); |
|
302 QVERIFY(!result.compare(reference)); |
|
303 |
|
304 pattern = QString("43043"); |
|
305 reference = QString("SELECT contact_id FROM predictivesearch4 WHERE NOT(NOT(NOT(NOT(nbr>301814842312884223 AND nbr<301815941824512000) AND NOT(nbr2>301814842312884223 AND nbr2<301815941824512000) AND NOT(nbr3>301814842312884223 AND nbr3<301815941824512000) AND NOT(nbr4>301814842312884223 AND nbr4<301815941824512000))) AND NOT(NOT(NOT(nbr2>301741175033823231 AND nbr2<306244774661193728 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr3>301741175033823231 AND nbr3<306244774661193728 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr3>301741175033823231 AND nbr3<306244774661193728 AND nbr2>301741175033823231 AND nbr2<306244774661193728) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr>301741175033823231 AND nbr<306244774661193728) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr2>301741175033823231 AND nbr2<306244774661193728) AND NOT(nbr4>301741175033823231 AND nbr4<306244774661193728 AND nbr3>301741175033823231 AND nbr3<306244774661193728)))) ORDER BY predictivesearch4.first_name, predictivesearch4.last_name ASC;"); |
|
306 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
307 //qDebug() << pattern << " -> result" << result; |
|
308 LOG2(pattern, result); |
|
309 QVERIFY(!result.compare(reference)); |
|
310 |
|
311 pattern = QString("0020030"); |
|
312 #if defined(USE_DEMORGAN) |
|
313 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE NOT(NOT(NOT(NOT(nbr>563156111851519 AND nbr<563160406818816) AND NOT(nbr2>563156111851519 AND nbr2<563160406818816) AND NOT(nbr3>563156111851519 AND nbr3<563160406818816) AND NOT(nbr4>563156111851519 AND nbr4<563160406818816))) AND NOT(NOT(NOT(nbr2>216172782113783807 AND nbr2<220676381741154304 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr3>216172782113783807 AND nbr3<220676381741154304 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr3>216172782113783807 AND nbr3<220676381741154304 AND nbr2>562949953421311 AND nbr2<844424930131968) AND NOT(nbr4>216172782113783807 AND nbr4<220676381741154304 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr4>216172782113783807 AND nbr4<220676381741154304 AND nbr2>562949953421311 AND nbr2<844424930131968) AND NOT(nbr4>216172782113783807 AND nbr4<220676381741154304 AND nbr3>562949953421311 AND nbr3<844424930131968))) AND NOT(NOT(NOT(nbr2>562949953421311 AND nbr2<844424930131968 AND nbr>216172782113783807 AND nbr<220676381741154304) AND NOT(nbr3>562949953421311 AND nbr3<844424930131968 AND nbr>216172782113783807 AND nbr<220676381741154304) AND NOT(nbr3>562949953421311 AND nbr3<844424930131968 AND nbr2>216172782113783807 AND nbr2<220676381741154304) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr>216172782113783807 AND nbr<220676381741154304) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr2>216172782113783807 AND nbr2<220676381741154304) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr3>216172782113783807 AND nbr3<220676381741154304)))) ORDER BY predictivesearch0.first_name, predictivesearch0.last_name ASC;"); |
|
314 #else |
|
315 // TODO: add non-De Morgan case |
|
316 #endif |
|
317 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
318 //qDebug() << pattern << " -> result" << result; |
|
319 LOG2(pattern, result); |
|
320 QVERIFY(!result.compare(reference)); |
|
321 |
|
322 pattern = QString("00430001020"); |
|
323 #if defined(USE_DEMORGAN) |
|
324 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE NOT(NOT(NOT(NOT(nbr>1178676735508479 AND nbr<1178676735574016) AND NOT(nbr2>1178676735508479 AND nbr2<1178676735574016) AND NOT(nbr3>1178676735508479 AND nbr3<1178676735574016) AND NOT(nbr4>1178676735508479 AND nbr4<1178676735574016))) AND NOT(NOT(NOT(nbr2>72620543991349247 AND nbr2<72638136177393664 AND nbr>1178676464975871 AND nbr<1196268651020288) AND NOT(nbr3>72620543991349247 AND nbr3<72638136177393664 AND nbr>1178676464975871 AND nbr<1196268651020288) AND NOT(nbr3>72620543991349247 AND nbr3<72638136177393664 AND nbr2>1178676464975871 AND nbr2<1196268651020288) AND NOT(nbr4>72620543991349247 AND nbr4<72638136177393664 AND nbr>1178676464975871 AND nbr<1196268651020288) AND NOT(nbr4>72620543991349247 AND nbr4<72638136177393664 AND nbr2>1178676464975871 AND nbr2<1196268651020288) AND NOT(nbr4>72620543991349247 AND nbr4<72638136177393664 AND nbr3>1178676464975871 AND nbr3<1196268651020288))) AND NOT(NOT(NOT(nbr2>1178676464975871 AND nbr2<1196268651020288 AND nbr>72620543991349247 AND nbr<72638136177393664) AND NOT(nbr3>1178676464975871 AND nbr3<1196268651020288 AND nbr>72620543991349247 AND nbr<72638136177393664) AND NOT(nbr3>1178676464975871 AND nbr3<1196268651020288 AND nbr2>72620543991349247 AND nbr2<72638136177393664) AND NOT(nbr4>1178676464975871 AND nbr4<1196268651020288 AND nbr>72620543991349247 AND nbr<72638136177393664) AND NOT(nbr4>1178676464975871 AND nbr4<1196268651020288 AND nbr2>72620543991349247 AND nbr2<72638136177393664) AND NOT(nbr4>1178676464975871 AND nbr4<1196268651020288 AND nbr3>72620543991349247 AND nbr3<72638136177393664)))) ORDER BY predictivesearch0.first_name, predictivesearch0.last_name ASC;"); |
|
325 #else |
|
326 // TODO: add non-De Morgan case |
|
327 #endif |
|
328 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
329 //qDebug() << pattern << " -> result" << result; |
|
330 LOG2(pattern, result); |
|
331 QVERIFY(!result.compare(reference)); |
|
332 |
|
333 pattern = QString("227264583788306"); // 15 digits |
|
334 #if defined(USE_DEMORGAN) |
|
335 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE NOT(NOT(NOT(NOT(nbr>155134792167883525 AND nbr<155134792167883527) AND NOT(nbr2>155134792167883525 AND nbr2<155134792167883527) AND NOT(nbr3>155134792167883525 AND nbr3<155134792167883527) AND NOT(nbr4>155134792167883525 AND nbr4<155134792167883527))) AND NOT(NOT(NOT(nbr2>432345564227567615 AND nbr2<504403158265495552 AND nbr>155134792167883519 AND nbr<155134792167883776) AND NOT(nbr3>432345564227567615 AND nbr3<504403158265495552 AND nbr>155134792167883519 AND nbr<155134792167883776) AND NOT(nbr3>432345564227567615 AND nbr3<504403158265495552 AND nbr2>155134792167883519 AND nbr2<155134792167883776) AND NOT(nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr>155134792167883519 AND nbr<155134792167883776) AND NOT(nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr2>155134792167883519 AND nbr2<155134792167883776) AND NOT(nbr4>432345564227567615 AND nbr4<504403158265495552 AND nbr3>155134792167883519 AND nbr3<155134792167883776))) AND NOT(NOT(NOT(nbr2>155134792167883519 AND nbr2<155134792167883776 AND nbr>432345564227567615 AND nbr<504403158265495552) AND NOT(nbr3>155134792167883519 AND nbr3<155134792167883776 AND nbr>432345564227567615 AND nbr<504403158265495552) AND NOT(nbr3>155134792167883519 AND nbr3<155134792167883776 AND nbr2>432345564227567615 AND nbr2<504403158265495552) AND NOT(nbr4>155134792167883519 AND nbr4<155134792167883776 AND nbr>432345564227567615 AND nbr<504403158265495552) AND NOT(nbr4>155134792167883519 AND nbr4<155134792167883776 AND nbr2>432345564227567615 AND nbr2<504403158265495552) AND NOT(nbr4>155134792167883519 AND nbr4<155134792167883776 AND nbr3>432345564227567615 AND nbr3<504403158265495552)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
336 #else |
|
337 // TODO: add non-De Morgan case |
|
338 #endif |
|
339 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
340 //qDebug() << pattern << " -> result" << result; |
|
341 LOG2(pattern, result); |
|
342 QVERIFY(!result.compare(reference)); |
|
343 |
|
344 |
|
345 pattern = QString("34096"); |
|
346 #if defined(USE_DEMORGAN) |
|
347 reference = QString("SELECT contact_id FROM predictivesearch3 WHERE NOT(NOT(NOT(NOT(nbr>234352107367432191 AND nbr<234353206879059968) AND NOT(nbr2>234352107367432191 AND nbr2<234353206879059968) AND NOT(nbr3>234352107367432191 AND nbr3<234353206879059968) AND NOT(nbr4>234352107367432191 AND nbr4<234353206879059968))) AND NOT(NOT(NOT(nbr2>675539944105574399 AND nbr2<680043543732944896 AND nbr>234187180623265791 AND nbr<238690780250636288) AND NOT(nbr3>675539944105574399 AND nbr3<680043543732944896 AND nbr>234187180623265791 AND nbr<238690780250636288) AND NOT(nbr3>675539944105574399 AND nbr3<680043543732944896 AND nbr2>234187180623265791 AND nbr2<238690780250636288) AND NOT(nbr4>675539944105574399 AND nbr4<680043543732944896 AND nbr>234187180623265791 AND nbr<238690780250636288) AND NOT(nbr4>675539944105574399 AND nbr4<680043543732944896 AND nbr2>234187180623265791 AND nbr2<238690780250636288) AND NOT(nbr4>675539944105574399 AND nbr4<680043543732944896 AND nbr3>234187180623265791 AND nbr3<238690780250636288))) AND NOT(NOT(NOT(nbr2>234187180623265791 AND nbr2<238690780250636288 AND nbr>675539944105574399 AND nbr<680043543732944896) AND NOT(nbr3>234187180623265791 AND nbr3<238690780250636288 AND nbr>675539944105574399 AND nbr<680043543732944896) AND NOT(nbr3>234187180623265791 AND nbr3<238690780250636288 AND nbr2>675539944105574399 AND nbr2<680043543732944896) AND NOT(nbr4>234187180623265791 AND nbr4<238690780250636288 AND nbr>675539944105574399 AND nbr<680043543732944896) AND NOT(nbr4>234187180623265791 AND nbr4<238690780250636288 AND nbr2>675539944105574399 AND nbr2<680043543732944896) AND NOT(nbr4>234187180623265791 AND nbr4<238690780250636288 AND nbr3>675539944105574399 AND nbr3<680043543732944896)))) ORDER BY predictivesearch3.first_name, predictivesearch3.last_name ASC;"); |
|
348 #else |
|
349 // TODO: add non-De Morgan case |
|
350 #endif |
|
351 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
352 //qDebug() << pattern << " -> result" << result; |
|
353 LOG2(pattern, result); |
|
354 QVERIFY(!result.compare(reference)); |
|
355 |
|
356 pattern = QString("522000000000007"); // 15 digits |
|
357 #if defined(USE_DEMORGAN) |
|
358 reference = QString("SELECT contact_id FROM predictivesearch5 WHERE NOT(NOT(NOT(NOT(nbr>369858119397801990 AND nbr<369858119397801992) AND NOT(nbr2>369858119397801990 AND nbr2<369858119397801992) AND NOT(nbr3>369858119397801990 AND nbr3<369858119397801992) AND NOT(nbr4>369858119397801990 AND nbr4<369858119397801992))) AND NOT(NOT(NOT(nbr2>504403158265495551 AND nbr2<576460752303423488 AND nbr>369858119397801983 AND nbr<370139594374512640) AND NOT(nbr3>504403158265495551 AND nbr3<576460752303423488 AND nbr>369858119397801983 AND nbr<370139594374512640) AND NOT(nbr3>504403158265495551 AND nbr3<576460752303423488 AND nbr2>369858119397801983 AND nbr2<370139594374512640) AND NOT(nbr4>504403158265495551 AND nbr4<576460752303423488 AND nbr>369858119397801983 AND nbr<370139594374512640) AND NOT(nbr4>504403158265495551 AND nbr4<576460752303423488 AND nbr2>369858119397801983 AND nbr2<370139594374512640) AND NOT(nbr4>504403158265495551 AND nbr4<576460752303423488 AND nbr3>369858119397801983 AND nbr3<370139594374512640))) AND NOT(NOT(NOT(nbr2>369858119397801983 AND nbr2<370139594374512640 AND nbr>504403158265495551 AND nbr<576460752303423488) AND NOT(nbr3>369858119397801983 AND nbr3<370139594374512640 AND nbr>504403158265495551 AND nbr<576460752303423488) AND NOT(nbr3>369858119397801983 AND nbr3<370139594374512640 AND nbr2>504403158265495551 AND nbr2<576460752303423488) AND NOT(nbr4>369858119397801983 AND nbr4<370139594374512640 AND nbr>504403158265495551 AND nbr<576460752303423488) AND NOT(nbr4>369858119397801983 AND nbr4<370139594374512640 AND nbr2>504403158265495551 AND nbr2<576460752303423488) AND NOT(nbr4>369858119397801983 AND nbr4<370139594374512640 AND nbr3>504403158265495551 AND nbr3<576460752303423488)))) ORDER BY predictivesearch5.first_name, predictivesearch5.last_name ASC;"); |
|
359 #else |
|
360 // TODO: add non-De Morgan case |
|
361 #endif |
|
362 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
363 //qDebug() << pattern << " -> result" << result; |
|
364 LOG2(pattern, result); |
|
365 QVERIFY(!result.compare(reference)); |
|
366 |
|
367 pattern = QString("20"); |
|
368 #if defined(USE_DEMORGAN) |
|
369 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE NOT(NOT(NOT(NOT(nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808))) AND NOT(NOT(NOT(nbr>144115188075855871 AND nbr<148618787703226368) AND NOT(nbr2>144115188075855871 AND nbr2<148618787703226368) AND NOT(nbr3>144115188075855871 AND nbr3<148618787703226368) AND NOT(nbr4>144115188075855871 AND nbr4<148618787703226368)))) ORDER BY first_name, last_name ASC;"); |
|
370 #else |
|
371 // TODO: add non-De Morgan case |
|
372 #endif |
|
373 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
374 //qDebug() << pattern << " -> result" << result; |
|
375 LOG2(pattern, result); |
|
376 QVERIFY(!result.compare(reference)); |
|
377 |
|
378 pattern = QString("200"); |
|
379 #if defined(USE_DEMORGAN) |
|
380 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE (NOT(NOT(nbr>144115188075855871 AND nbr<144396663052566528) AND NOT(nbr2>144115188075855871 AND nbr2<144396663052566528) AND NOT(nbr3>144115188075855871 AND nbr3<144396663052566528) AND NOT(nbr4>144115188075855871 AND nbr4<144396663052566528))) ORDER BY first_name, last_name ASC;"); |
|
381 #else |
|
382 // TODO: add non-De Morgan case |
|
383 #endif |
|
384 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
385 //qDebug() << pattern << " -> result" << result; |
|
386 LOG2(pattern, result); |
|
387 QVERIFY(!result.compare(reference)); |
|
388 |
|
389 pattern = QString("#"); |
|
390 #if defined(USE_DEMORGAN) |
|
391 reference = QString("SELECT contact_id FROM predictivesearch11 ORDER BY first_name, last_name ASC;"); |
|
392 #else |
|
393 // TODO: add non-De Morgan case |
|
394 #endif |
|
395 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
396 //qDebug() << pattern << " -> result" << result; |
|
397 LOG2(pattern, result); |
|
398 QVERIFY(!result.compare(reference)); |
|
399 |
|
400 pattern = QString("#22"); |
|
401 #if defined(USE_DEMORGAN) |
|
402 reference = QString("SELECT contact_id FROM predictivesearch11 WHERE (NOT(NOT(nbr>802203683625369599 AND nbr<802485158602080256) AND NOT(nbr2>802203683625369599 AND nbr2<802485158602080256) AND NOT(nbr3>802203683625369599 AND nbr3<802485158602080256) AND NOT(nbr4>802203683625369599 AND nbr4<802485158602080256))) ORDER BY first_name, last_name ASC;"); |
|
403 #else |
|
404 // TODO: add non-De Morgan case |
|
405 #endif |
|
406 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
407 //qDebug() << pattern << " -> result" << result; |
|
408 LOG2(pattern, result); |
|
409 QVERIFY(!result.compare(reference)); |
|
410 |
|
411 pattern = QString("#0*"); |
|
412 #if defined(USE_DEMORGAN) |
|
413 reference = QString("SELECT contact_id FROM predictivesearch11 WHERE NOT(NOT(NOT(NOT(nbr>795448284184313855 AND nbr<795729759161024512) AND NOT(nbr2>795448284184313855 AND nbr2<795729759161024512) AND NOT(nbr3>795448284184313855 AND nbr3<795729759161024512) AND NOT(nbr4>795448284184313855 AND nbr4<795729759161024512))) AND NOT(NOT(NOT(nbr2>720575940379279359 AND nbr2<792633534417207296 AND nbr>792633534417207295 AND nbr<864691128455135232) AND NOT(nbr3>720575940379279359 AND nbr3<792633534417207296 AND nbr>792633534417207295 AND nbr<864691128455135232) AND NOT(nbr3>720575940379279359 AND nbr3<792633534417207296 AND nbr2>792633534417207295 AND nbr2<864691128455135232) AND NOT(nbr4>720575940379279359 AND nbr4<792633534417207296 AND nbr>792633534417207295 AND nbr<864691128455135232) AND NOT(nbr4>720575940379279359 AND nbr4<792633534417207296 AND nbr2>792633534417207295 AND nbr2<864691128455135232) AND NOT(nbr4>720575940379279359 AND nbr4<792633534417207296 AND nbr3>792633534417207295 AND nbr3<864691128455135232))) AND NOT(NOT(NOT(nbr2>792633534417207295 AND nbr2<864691128455135232 AND nbr>720575940379279359 AND nbr<792633534417207296) AND NOT(nbr3>792633534417207295 AND nbr3<864691128455135232 AND nbr>720575940379279359 AND nbr<792633534417207296) AND NOT(nbr3>792633534417207295 AND nbr3<864691128455135232 AND nbr2>720575940379279359 AND nbr2<792633534417207296) AND NOT(nbr4>792633534417207295 AND nbr4<864691128455135232 AND nbr>720575940379279359 AND nbr<792633534417207296) AND NOT(nbr4>792633534417207295 AND nbr4<864691128455135232 AND nbr2>720575940379279359 AND nbr2<792633534417207296) AND NOT(nbr4>792633534417207295 AND nbr4<864691128455135232 AND nbr3>720575940379279359 AND nbr3<792633534417207296)))) ORDER BY predictivesearch11.first_name, predictivesearch11.last_name ASC;"); |
|
414 #else |
|
415 // TODO: add non-De Morgan case |
|
416 #endif |
|
417 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
418 //qDebug() << pattern << " -> result" << result; |
|
419 LOG2(pattern, result); |
|
420 QVERIFY(!result.compare(reference)); |
|
421 |
|
422 pattern = QString("qz") + QChar(30) + QString("vqwerty"); |
|
423 reference = QString("SELECT contact_id FROM qm0 WHERE (NOT(NOT(n>5348024557502463 AND n<5629499534213120) AND NOT(n2>5348024557502463 AND n2<5629499534213120) AND NOT(n3>5348024557502463 AND n3<5629499534213120) AND NOT(n4>5348024557502463 AND n4<5629499534213120) AND NOT(n5>5348024557502463 AND n5<5629499534213120) AND NOT(n6>5348024557502463 AND n6<5629499534213120) AND NOT(n7>5348024557502463 AND n7<5629499534213120))) ORDER BY first_name, last_name ASC;"); |
|
424 result = mCntSqlSearch->CreatePredictiveSearch(pattern); |
|
425 LOG2(pattern, result); |
|
426 //qDebug() << pattern << " -> result" << result; |
|
427 QVERIFY(!result.compare(reference)); |
|
428 |
|
429 TEST_PASSED_LOG("testPredictiveSearch"); |
|
430 } |
|
431 |
|
432 void UT_CntSqlSearch::testSelectQweryTable() |
|
433 { |
|
434 TEST_BEGIN_LOG("testSelectQweryTable"); |
|
435 QString pattern("q"); |
|
436 QString result = mCntSqlSearch->selectQweryTable(pattern); |
|
437 QVERIFY(result == "qm0" ); |
|
438 |
|
439 pattern = QString("000"); |
|
440 result = mCntSqlSearch->selectQweryTable(pattern); |
|
441 //QVERIFY(result == "qm0" ); |
|
442 |
|
443 pattern = QString("9"); |
|
444 result = mCntSqlSearch->selectQweryTable(pattern); |
|
445 //QVERIFY(result == "qm9" ); |
|
446 TEST_PASSED_LOG("testSelectQweryTable"); |
|
447 } |
|
448 |
|
449 void UT_CntSqlSearch::testSelectTableView() |
|
450 { |
|
451 TEST_BEGIN_LOG("testSelectTableView"); |
|
452 |
|
453 QString pattern = QString("0"); |
|
454 QString reference = QString("predictivesearch0"); |
|
455 QString result = mCntSqlSearch->SelectTable(pattern); |
|
456 QVERIFY( !result.compare( reference) ); |
|
457 |
|
458 pattern = QString("1"); |
|
459 reference = QString("predictivesearch1"); |
|
460 result = mCntSqlSearch->SelectTable(pattern); |
|
461 QVERIFY( !result.compare( reference) ); |
|
462 |
|
463 pattern = QString("2"); |
|
464 reference = QString("predictivesearch2"); |
|
465 result = mCntSqlSearch->SelectTable(pattern); |
|
466 QVERIFY( !result.compare( reference) ); |
|
467 |
|
468 pattern = QString("3"); |
|
469 reference = QString("predictivesearch3"); |
|
470 result = mCntSqlSearch->SelectTable(pattern); |
|
471 QVERIFY( !result.compare( reference) ); |
|
472 |
|
473 pattern = QString("4"); |
|
474 reference = QString("predictivesearch4"); |
|
475 result = mCntSqlSearch->SelectTable(pattern); |
|
476 QVERIFY( !result.compare( reference) ); |
|
477 |
|
478 pattern = QString("5"); |
|
479 reference = QString("predictivesearch5"); |
|
480 result = mCntSqlSearch->SelectTable(pattern); |
|
481 QVERIFY( !result.compare( reference) ); |
|
482 |
|
483 pattern = QString("6"); |
|
484 reference = QString("predictivesearch6"); |
|
485 result = mCntSqlSearch->SelectTable(pattern); |
|
486 QVERIFY( !result.compare( reference) ); |
|
487 |
|
488 pattern = QString("7"); |
|
489 reference = QString("predictivesearch7"); |
|
490 result = mCntSqlSearch->SelectTable(pattern); |
|
491 QVERIFY( !result.compare( reference) ); |
|
492 |
|
493 pattern = QString("8"); |
|
494 reference = QString("predictivesearch8"); |
|
495 result = mCntSqlSearch->SelectTable(pattern); |
|
496 QVERIFY( !result.compare( reference) ); |
|
497 |
|
498 pattern = QString("9"); |
|
499 reference = QString("predictivesearch9"); |
|
500 result = mCntSqlSearch->SelectTable(pattern); |
|
501 QVERIFY( !result.compare( reference) ); |
|
502 |
|
503 pattern = QString("09"); |
|
504 reference = QString("predictivesearch0"); |
|
505 result = mCntSqlSearch->SelectTable(pattern); |
|
506 QVERIFY( !result.compare( reference) ); |
|
507 |
|
508 pattern = QString("090"); |
|
509 reference = QString("predictivesearch0"); |
|
510 result = mCntSqlSearch->SelectTable(pattern); |
|
511 QVERIFY( !result.compare( reference) ); |
|
512 |
|
513 pattern = QString("909"); |
|
514 reference = QString("predictivesearch9"); |
|
515 result = mCntSqlSearch->SelectTable(pattern); |
|
516 QVERIFY( !result.compare( reference) ); |
|
517 |
|
518 pattern = QString("99"); |
|
519 reference = QString("predictivesearch9"); |
|
520 result = mCntSqlSearch->SelectTable(pattern); |
|
521 QVERIFY( !result.compare( reference) ); |
|
522 |
|
523 pattern = QString("000"); |
|
524 reference = QString("predictivesearch0"); |
|
525 result = mCntSqlSearch->SelectTable(pattern); |
|
526 QVERIFY( !result.compare( reference) ); |
|
527 |
|
528 pattern = QString("B"); |
|
529 reference = QString("predictivesearch11"); |
|
530 result = mCntSqlSearch->SelectTable(pattern); |
|
531 QVERIFY( !result.compare( reference) ); |
|
532 |
|
533 pattern = QString("A"); |
|
534 reference = QString("predictivesearch10"); |
|
535 result = mCntSqlSearch->SelectTable(pattern); |
|
536 QVERIFY( !result.compare( reference) ); |
|
537 |
|
538 pattern = QString("A0"); |
|
539 reference = QString("predictivesearch10"); |
|
540 result = mCntSqlSearch->SelectTable(pattern); |
|
541 QVERIFY( !result.compare( reference) ); |
|
542 |
|
543 pattern = QString("A10"); |
|
544 reference = QString("predictivesearch10"); |
|
545 result = mCntSqlSearch->SelectTable(pattern); |
|
546 QVERIFY( !result.compare( reference) ); |
|
547 |
|
548 pattern = QString("0A"); |
|
549 reference = QString("predictivesearch0"); |
|
550 result = mCntSqlSearch->SelectTable(pattern); |
|
551 QVERIFY( !result.compare( reference) ); |
|
552 |
|
553 TEST_PASSED_LOG("testSelectTableView"); |
|
554 } |
|
555 |
|
556 void UT_CntSqlSearch::testCreateQuery() |
|
557 { |
|
558 TEST_BEGIN_LOG("testCreateQuery"); |
|
559 QString pattern = QString("102"); |
|
560 |
|
561 #if defined(SEARCH_FROM_ONE_TABLE) |
|
562 #if defined(USE_DEMORGAN) |
|
563 QString reference("SELECT contact_id FROM predictivesearch1 WHERE NOT(NOT(NOT(NOT(nbr>72620543991349247 AND nbr<72902018968059904) AND NOT(nbr2>72620543991349247 AND nbr2<72902018968059904) AND NOT(nbr3>72620543991349247 AND nbr3<72902018968059904) AND NOT(nbr4>72620543991349247 AND nbr4<72902018968059904))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>72057594037927935 AND nbr2<144115188075855872) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>72057594037927935 AND nbr<144115188075855872) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>72057594037927935 AND nbr2<144115188075855872) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>72057594037927935 AND nbr3<144115188075855872))) AND NOT(NOT(NOT(nbr2>72057594037927935 AND nbr2<144115188075855872 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr3>144115188075855871 AND nbr3<216172782113783808)))) ORDER BY predictivesearch1.first_name, predictivesearch1.last_name ASC;"); |
|
564 #else // #if defined(USE_DEMORGAN) |
|
565 QString reference("SELECT contact_id FROM predictivesearch1 WHERE \ |
|
566 ((nbr>72620543991349247 AND nbr<72902018968059904) OR \ |
|
567 (nbr2>72620543991349247 AND nbr2<72902018968059904) OR \ |
|
568 (nbr3>72620543991349247 AND nbr3<72902018968059904) OR \ |
|
569 (nbr4>72620543991349247 AND nbr4<72902018968059904)) OR \ |
|
570 (nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>72057594037927935 AND nbr<144115188075855872) OR \ |
|
571 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>72057594037927935 AND nbr<144115188075855872) OR \ |
|
572 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>72057594037927935 AND nbr2<144115188075855872) OR \ |
|
573 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>72057594037927935 AND nbr<144115188075855872) OR \ |
|
574 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>72057594037927935 AND nbr2<144115188075855872) OR \ |
|
575 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>72057594037927935 AND nbr3<144115188075855872) OR \ |
|
576 (nbr2>72057594037927935 AND nbr2<144115188075855872 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
577 (nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
578 (nbr3>72057594037927935 AND nbr3<144115188075855872 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
579 (nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
580 (nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
581 (nbr4>72057594037927935 AND nbr4<144115188075855872 AND nbr3>144115188075855871 AND nbr3<216172782113783808) \ |
|
582 ORDER BY predictivesearch1.first_name, predictivesearch1.last_name ASC;"); |
|
583 #endif // #if defined(USE_DEMORGAN) |
|
584 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
585 QString reference("SELECT predictivesearch1.contact_id FROM predictivesearch1 WHERE EXISTS (SELECT contact_id FROM predictivesearch2 WHERE predictivesearch1.contact_id = predictivesearch2.contact_id) OR (SELECT contact_id FROM predictivesearch1 WHERE (NOT(NOT(predictivesearch1.nbr>72620543991349247 AND predictivesearch1.nbr<72902018968059904) AND NOT(predictivesearch1.nbr2>72620543991349247 AND predictivesearch1.nbr2<72902018968059904) AND NOT(predictivesearch1.nbr3>72620543991349247 AND predictivesearch1.nbr3<72902018968059904) AND NOT(predictivesearch1.nbr4>72620543991349247 AND predictivesearch1.nbr4<72902018968059904)))) ORDER BY predictivesearch1.first_name, predictivesearch1.last_name ASC;"); |
|
586 #endif // #if defined(SEARCH_FROM_ONE_TABLE) |
|
587 QString result = mCntSqlSearch->CreateQuery(pattern); |
|
588 //qDebug() << pattern << " -> result" << result; |
|
589 //TODO: Fix test result |
|
590 LOG2(pattern, result); |
|
591 //qDebug() << pattern << " -> result" << result << " -> reference" << reference; |
|
592 QVERIFY(!result.compare(reference)); |
|
593 |
|
594 pattern = QString("00202"); |
|
595 #if defined(SEARCH_FROM_ONE_TABLE) |
|
596 #if defined(USE_DEMORGAN) |
|
597 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE NOT(NOT(NOT(NOT(nbr>565148976676863 AND nbr<566248488304640) AND NOT(nbr2>565148976676863 AND nbr2<566248488304640) AND NOT(nbr3>565148976676863 AND nbr3<566248488304640) AND NOT(nbr4>565148976676863 AND nbr4<566248488304640))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>562949953421311 AND nbr2<844424930131968) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>562949953421311 AND nbr2<844424930131968) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>562949953421311 AND nbr3<844424930131968))) AND NOT(NOT(NOT(nbr2>562949953421311 AND nbr2<844424930131968 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>562949953421311 AND nbr3<844424930131968 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>562949953421311 AND nbr3<844424930131968 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr3>144115188075855871 AND nbr3<216172782113783808)))) ORDER BY predictivesearch0.first_name, predictivesearch0.last_name ASC;"); |
|
598 #else // #if defined(USE_DEMORGAN) |
|
599 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE \ |
|
600 ((nbr>565148976676863 AND nbr<566248488304640) OR \ |
|
601 (nbr2>565148976676863 AND nbr2<566248488304640) OR \ |
|
602 (nbr3>565148976676863 AND nbr3<566248488304640) OR \ |
|
603 (nbr4>565148976676863 AND nbr4<566248488304640)) OR \ |
|
604 (nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>562949953421311 AND nbr<844424930131968) OR \ |
|
605 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>562949953421311 AND nbr<844424930131968) OR \ |
|
606 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>562949953421311 AND nbr2<844424930131968) OR \ |
|
607 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>562949953421311 AND nbr<844424930131968) OR \ |
|
608 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>562949953421311 AND nbr2<844424930131968) OR \ |
|
609 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>562949953421311 AND nbr3<844424930131968) OR \ |
|
610 (nbr2>562949953421311 AND nbr2<844424930131968 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
611 (nbr3>562949953421311 AND nbr3<844424930131968 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
612 (nbr3>562949953421311 AND nbr3<844424930131968 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
613 (nbr4>562949953421311 AND nbr4<844424930131968 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
614 (nbr4>562949953421311 AND nbr4<844424930131968 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
615 (nbr4>562949953421311 AND nbr4<844424930131968 AND nbr3>144115188075855871 AND nbr3<216172782113783808) \ |
|
616 ORDER BY predictivesearch0.first_name, predictivesearch0.last_name ASC;"); |
|
617 #endif // #if defined(USE_DEMORGAN) |
|
618 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
619 // TODO: Test this case on HW and verify leading zeros. |
|
620 reference = QString("SELECT contact_id FROM (SELECT predictivesearch0.contact_id, predictivesearch0.first_name, predictivesearch0.last_name FROM predictivesearch0 WHERE (NOT(NOT(predictivesearch0.nbr>565148976676863 AND predictivesearch0.nbr<566248488304640) AND NOT(predictivesearch0.nbr2>565148976676863 AND predictivesearch0.nbr2<566248488304640) AND NOT(predictivesearch0.nbr3>565148976676863 AND predictivesearch0.nbr3<566248488304640) AND NOT(predictivesearch0.nbr4>565148976676863 AND predictivesearch0.nbr4<566248488304640))) UNION SELECT predictivesearch0.contact_id, predictivesearch0.first_name, predictivesearch0.last_name FROM predictivesearch0 JOIN predictivesearch2 ON predictivesearch0.contact_id = predictivesearch2.contact_id WHERE(NOT(NOT(predictivesearch0.nbr>562949953421311 AND predictivesearch0.nbr<844424930131968) AND NOT(predictivesearch0.nbr2>562949953421311 AND predictivesearch0.nbr2<844424930131968) AND NOT(predictivesearch0.nbr3>562949953421311 AND predictivesearch0.nbr3<844424930131968) AND NOT(predictivesearch0.nbr4>562949953421311 AND predictivesearch0.nbr4<844424930131968)))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
621 #endif // #if defined(SEARCH_FROM_ONE_TABLE) |
|
622 result = mCntSqlSearch->CreateQuery(pattern); |
|
623 //qDebug() << pattern << " -> result" << result; |
|
624 LOG2(pattern, result); |
|
625 QVERIFY( !result.compare( reference) ); |
|
626 |
|
627 pattern = QString("202000"); |
|
628 #if defined(USE_DEMORGAN) |
|
629 // TODO: Test this case on HW and verify trailing zeros. |
|
630 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE NOT(NOT(NOT(NOT(nbr>144678138029277183 AND nbr<144678206748753920) AND NOT(nbr2>144678138029277183 AND nbr2<144678206748753920) AND NOT(nbr3>144678138029277183 AND nbr3<144678206748753920) AND NOT(nbr4>144678138029277183 AND nbr4<144678206748753920))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<144132780261900288 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>144115188075855871 AND nbr3<144132780261900288 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>144115188075855871 AND nbr3<144132780261900288 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>144115188075855871 AND nbr4<144132780261900288 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr4>144115188075855871 AND nbr4<144132780261900288 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>144115188075855871 AND nbr4<144132780261900288 AND nbr3>144115188075855871 AND nbr3<216172782113783808))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>144115188075855871 AND nbr<144132780261900288) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>144115188075855871 AND nbr<144132780261900288) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>144115188075855871 AND nbr2<144132780261900288) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>144115188075855871 AND nbr<144132780261900288) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>144115188075855871 AND nbr2<144132780261900288) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>144115188075855871 AND nbr3<144132780261900288)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
631 #else |
|
632 // TODO: add non-De Morgan version |
|
633 #endif |
|
634 |
|
635 /*reference = QString("SELECT contact_id FROM predictivesearch2 WHERE \ |
|
636 ((nbr>144678138029277183 AND nbr<144678206748753920) OR (nbr2>144678138029277183 AND nbr2<144678206748753920) OR \ |
|
637 (nbr3>144678138029277183 AND nbr3<144678206748753920) OR (nbr4>144678138029277183 AND nbr4<144678206748753920)) OR \ |
|
638 (nbr2>144115188075855871 AND nbr2<144132780261900288 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
639 (nbr3>144115188075855871 AND nbr3<144132780261900288 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
640 (nbr3>144115188075855871 AND nbr3<144132780261900288 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
641 (nbr4>144115188075855871 AND nbr4<144132780261900288 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
642 (nbr4>144115188075855871 AND nbr4<144132780261900288 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
643 (nbr4>144115188075855871 AND nbr4<144132780261900288 AND nbr3>144115188075855871 AND nbr3<216172782113783808) OR \ |
|
644 (nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>144115188075855871 AND nbr<144132780261900288) OR \ |
|
645 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>144115188075855871 AND nbr<144132780261900288) OR \ |
|
646 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>144115188075855871 AND nbr2<144132780261900288) OR \ |
|
647 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>144115188075855871 AND nbr<144132780261900288) OR \ |
|
648 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>144115188075855871 AND nbr2<144132780261900288) OR \ |
|
649 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>144115188075855871 AND nbr3<144132780261900288) \ |
|
650 ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;");*/ |
|
651 |
|
652 result = mCntSqlSearch->CreateQuery(pattern); |
|
653 //qDebug() << pattern << " -> result" << result; |
|
654 LOG2(pattern, result); |
|
655 QVERIFY( !result.compare( reference) ); |
|
656 |
|
657 pattern = QString("0020200"); |
|
658 #if defined(SEARCH_FROM_ONE_TABLE) |
|
659 #if defined(USE_DEMORGAN) |
|
660 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE NOT(NOT(NOT(NOT(nbr>565148976676863 AND nbr<565153271644160) AND NOT(nbr2>565148976676863 AND nbr2<565153271644160) AND NOT(nbr3>565148976676863 AND nbr3<565153271644160) AND NOT(nbr4>565148976676863 AND nbr4<565153271644160))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<144396663052566528 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr3>144115188075855871 AND nbr3<144396663052566528 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr3>144115188075855871 AND nbr3<144396663052566528 AND nbr2>562949953421311 AND nbr2<844424930131968) AND NOT(nbr4>144115188075855871 AND nbr4<144396663052566528 AND nbr>562949953421311 AND nbr<844424930131968) AND NOT(nbr4>144115188075855871 AND nbr4<144396663052566528 AND nbr2>562949953421311 AND nbr2<844424930131968) AND NOT(nbr4>144115188075855871 AND nbr4<144396663052566528 AND nbr3>562949953421311 AND nbr3<844424930131968))) AND NOT(NOT(NOT(nbr2>562949953421311 AND nbr2<844424930131968 AND nbr>144115188075855871 AND nbr<144396663052566528) AND NOT(nbr3>562949953421311 AND nbr3<844424930131968 AND nbr>144115188075855871 AND nbr<144396663052566528) AND NOT(nbr3>562949953421311 AND nbr3<844424930131968 AND nbr2>144115188075855871 AND nbr2<144396663052566528) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr>144115188075855871 AND nbr<144396663052566528) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr2>144115188075855871 AND nbr2<144396663052566528) AND NOT(nbr4>562949953421311 AND nbr4<844424930131968 AND nbr3>144115188075855871 AND nbr3<144396663052566528)))) ORDER BY predictivesearch0.first_name, predictivesearch0.last_name ASC;"); |
|
661 #else // #if defined(USE_DEMORGAN) |
|
662 reference = QString("SELECT contact_id FROM predictivesearch0 WHERE \ |
|
663 ((nbr>565148976676863 AND nbr<565153271644160) OR (nbr2>565148976676863 AND nbr2<565153271644160) OR \ |
|
664 (nbr3>565148976676863 AND nbr3<565153271644160) OR (nbr4>565148976676863 AND nbr4<565153271644160)) OR \ |
|
665 (nbr2>144115188075855871 AND nbr2<144396663052566528 AND nbr>562949953421311 AND nbr<844424930131968) OR \ |
|
666 (nbr3>144115188075855871 AND nbr3<144396663052566528 AND nbr>562949953421311 AND nbr<844424930131968) OR \ |
|
667 (nbr3>144115188075855871 AND nbr3<144396663052566528 AND nbr2>562949953421311 AND nbr2<844424930131968) OR \ |
|
668 (nbr4>144115188075855871 AND nbr4<144396663052566528 AND nbr>562949953421311 AND nbr<844424930131968) OR \ |
|
669 (nbr4>144115188075855871 AND nbr4<144396663052566528 AND nbr2>562949953421311 AND nbr2<844424930131968) OR \ |
|
670 (nbr4>144115188075855871 AND nbr4<144396663052566528 AND nbr3>562949953421311 AND nbr3<844424930131968) OR \ |
|
671 (nbr2>562949953421311 AND nbr2<844424930131968 AND nbr>144115188075855871 AND nbr<144396663052566528) OR \ |
|
672 (nbr3>562949953421311 AND nbr3<844424930131968 AND nbr>144115188075855871 AND nbr<144396663052566528) OR \ |
|
673 (nbr3>562949953421311 AND nbr3<844424930131968 AND nbr2>144115188075855871 AND nbr2<144396663052566528) OR \ |
|
674 (nbr4>562949953421311 AND nbr4<844424930131968 AND nbr>144115188075855871 AND nbr<144396663052566528) OR \ |
|
675 (nbr4>562949953421311 AND nbr4<844424930131968 AND nbr2>144115188075855871 AND nbr2<144396663052566528) OR \ |
|
676 (nbr4>562949953421311 AND nbr4<844424930131968 AND nbr3>144115188075855871 AND nbr3<144396663052566528) \ |
|
677 ORDER BY predictivesearch0.first_name, predictivesearch0.last_name ASC;"); |
|
678 #endif // #if defined(USE_DEMORGAN) |
|
679 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
680 // TODO: Test this case on HW and verify leading zeros. |
|
681 reference = QString("SELECT contact_id FROM (SELECT predictivesearch0.contact_id, predictivesearch0.first_name, predictivesearch0.last_name FROM predictivesearch0 WHERE (NOT(NOT(predictivesearch0.nbr>565148976676863 AND predictivesearch0.nbr<565153271644160) AND NOT(predictivesearch0.nbr2>565148976676863 AND predictivesearch0.nbr2<565153271644160) AND NOT(predictivesearch0.nbr3>565148976676863 AND predictivesearch0.nbr3<565153271644160) AND NOT(predictivesearch0.nbr4>565148976676863 AND predictivesearch0.nbr4<565153271644160))) UNION SELECT predictivesearch0.contact_id, predictivesearch0.first_name, predictivesearch0.last_name FROM predictivesearch0 JOIN predictivesearch2 ON predictivesearch0.contact_id = predictivesearch2.contact_id WHERE((NOT(NOT(predictivesearch0.nbr>562949953421311 AND predictivesearch0.nbr<844424930131968) AND NOT(predictivesearch0.nbr2>562949953421311 AND predictivesearch0.nbr2<844424930131968) AND NOT(predictivesearch0.nbr3>562949953421311 AND predictivesearch0.nbr3<844424930131968) AND NOT(predictivesearch0.nbr4>562949953421311 AND predictivesearch0.nbr4<844424930131968))) AND (NOT(NOT(predictivesearch2.nbr>144115188075855871 AND predictivesearch2.nbr<144396663052566528) AND NOT(predictivesearch2.nbr2>144115188075855871 AND predictivesearch2.nbr2<144396663052566528) AND NOT(predictivesearch2.nbr3>144115188075855871 AND predictivesearch2.nbr3<144396663052566528) AND NOT(predictivesearch2.nbr4>144115188075855871 AND predictivesearch2.nbr4<144396663052566528))))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
682 #endif //#if defined(SEARCH_FROM_ONE_TABLE) |
|
683 result = mCntSqlSearch->CreateQuery(pattern); |
|
684 //qDebug() << pattern << " -> result" << result; |
|
685 LOG2(pattern, result); |
|
686 QVERIFY( !result.compare( reference) ); |
|
687 |
|
688 pattern = QString("20322"); |
|
689 #if defined(SEARCH_FROM_ONE_TABLE) |
|
690 #if defined(USE_DEMORGAN) |
|
691 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE NOT(NOT(NOT(NOT(nbr>144996996401332223 AND nbr<144998095912960000) AND NOT(nbr2>144996996401332223 AND nbr2<144998095912960000) AND NOT(nbr3>144996996401332223 AND nbr3<144998095912960000) AND NOT(nbr4>144996996401332223 AND nbr4<144998095912960000))) AND NOT(NOT(NOT(nbr2>225742931321946111 AND nbr2<226024406298656768 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>225742931321946111 AND nbr3<226024406298656768 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>225742931321946111 AND nbr3<226024406298656768 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>225742931321946111 AND nbr4<226024406298656768 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr4>225742931321946111 AND nbr4<226024406298656768 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>225742931321946111 AND nbr4<226024406298656768 AND nbr3>144115188075855871 AND nbr3<216172782113783808))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>225742931321946111 AND nbr<226024406298656768) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>225742931321946111 AND nbr<226024406298656768) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>225742931321946111 AND nbr2<226024406298656768) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>225742931321946111 AND nbr<226024406298656768) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>225742931321946111 AND nbr2<226024406298656768) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>225742931321946111 AND nbr3<226024406298656768)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
692 #else // #if defined(USE_DEMORGAN) |
|
693 reference = QString("SELECT contact_id FROM predictivesearch2 WHERE \ |
|
694 ((nbr>144996996401332223 AND nbr<144998095912960000) OR (nbr2>144996996401332223 AND nbr2<144998095912960000) OR \ |
|
695 (nbr3>144996996401332223 AND nbr3<144998095912960000) OR (nbr4>144996996401332223 AND nbr4<144998095912960000)) OR \ |
|
696 (nbr2>225742931321946111 AND nbr2<226024406298656768 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
697 (nbr3>225742931321946111 AND nbr3<226024406298656768 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
698 (nbr3>225742931321946111 AND nbr3<226024406298656768 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
699 (nbr4>225742931321946111 AND nbr4<226024406298656768 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
700 (nbr4>225742931321946111 AND nbr4<226024406298656768 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
701 (nbr4>225742931321946111 AND nbr4<226024406298656768 AND nbr3>144115188075855871 AND nbr3<216172782113783808) OR \ |
|
702 (nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>225742931321946111 AND nbr<226024406298656768) OR \ |
|
703 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>225742931321946111 AND nbr<226024406298656768) OR \ |
|
704 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>225742931321946111 AND nbr2<226024406298656768) OR \ |
|
705 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>225742931321946111 AND nbr<226024406298656768) OR \ |
|
706 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>225742931321946111 AND nbr2<226024406298656768) OR \ |
|
707 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>225742931321946111 AND nbr3<226024406298656768) \ |
|
708 ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
709 #endif // #if defined(USE_DEMORGAN) |
|
710 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
711 reference = QString("SELECT contact_id FROM (SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 WHERE (NOT(NOT(predictivesearch2.nbr>144996996401332223 AND predictivesearch2.nbr<144998095912960000) AND NOT(predictivesearch2.nbr2>144996996401332223 AND predictivesearch2.nbr2<144998095912960000) AND NOT(predictivesearch2.nbr3>144996996401332223 AND predictivesearch2.nbr3<144998095912960000) AND NOT(predictivesearch2.nbr4>144996996401332223 AND predictivesearch2.nbr4<144998095912960000))) UNION SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 JOIN predictivesearch3 ON predictivesearch2.contact_id = predictivesearch3.contact_id WHERE(NOT(NOT(predictivesearch3.nbr>225742931321946111 AND predictivesearch3.nbr<226024406298656768) AND NOT(predictivesearch3.nbr2>225742931321946111 AND predictivesearch3.nbr2<226024406298656768) AND NOT(predictivesearch3.nbr3>225742931321946111 AND predictivesearch3.nbr3<226024406298656768) AND NOT(predictivesearch3.nbr4>225742931321946111 AND predictivesearch3.nbr4<226024406298656768)))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
712 #endif // #if defined(SEARCH_FROM_ONE_TABLE) |
|
713 result = mCntSqlSearch->CreateQuery(pattern); |
|
714 //qDebug() << pattern << " -> result" << result; |
|
715 LOG2(pattern, result); |
|
716 QVERIFY( !result.compare( reference) ); |
|
717 |
|
718 TEST_PASSED_LOG("testCreateQuery"); |
|
719 } |
|
720 |
|
721 void UT_CntSqlSearch::testCreateQwertyQuery() |
|
722 { |
|
723 TEST_BEGIN_LOG("testCreateQwertyQuery"); |
|
724 QString pattern = QString("s") + QChar(30) + QString("vqwerty"); |
|
725 QString reference("SELECT contact_id FROM qm11 ORDER BY first_name, last_name ASC;"); |
|
726 QString result = mCntSqlSearch->CreateQwertyQuery(pattern); |
|
727 LOG2(pattern, result); |
|
728 QVERIFY( !result.compare( reference) ); |
|
729 pattern = QString("s ya") + QChar(30) + QString("vqwerty"); |
|
730 reference = QString("SELECT contact_id FROM qm11 WHERE NOT(NOT(NOT(NOT(n>215914052579233922 AND n<215914052579233924) AND NOT(n2>215914052579233922 AND n2<215914052579233924) AND NOT(n3>215914052579233922 AND n3<215914052579233924) AND NOT(n4>215914052579233922 AND n4<215914052579233924) AND NOT(n5>215914052579233922 AND n5<215914052579233924) AND NOT(n6>215914052579233922 AND n6<215914052579233924) AND NOT(n7>215914052579233922 AND n7<215914052579233924))) AND NOT(NOT(NOT(n2>92886742314516479 AND n2<93168217291227136 AND n>198158383604301823 AND n<216172782113783808) AND NOT(n3>92886742314516479 AND n3<93168217291227136 AND n>198158383604301823 AND n<216172782113783808) AND NOT(n3>92886742314516479 AND n3<93168217291227136 AND n2>198158383604301823 AND n2<216172782113783808) AND NOT(n4>92886742314516479 AND n4<93168217291227136 AND n>198158383604301823 AND n<216172782113783808) AND NOT(n4>92886742314516479 AND n4<93168217291227136 AND n2>198158383604301823 AND n2<216172782113783808) AND NOT(n4>92886742314516479 AND n4<93168217291227136 AND n3>198158383604301823 AND n3<216172782113783808))) AND NOT(NOT(NOT(n2>198158383604301823 AND n2<216172782113783808 AND n>92886742314516479 AND n<93168217291227136) AND NOT(n3>198158383604301823 AND n3<216172782113783808 AND n>92886742314516479 AND n<93168217291227136) AND NOT(n3>198158383604301823 AND n3<216172782113783808 AND n2>92886742314516479 AND n2<93168217291227136) AND NOT(n4>198158383604301823 AND n4<216172782113783808 AND n>92886742314516479 AND n<93168217291227136) AND NOT(n4>198158383604301823 AND n4<216172782113783808 AND n2>92886742314516479 AND n2<93168217291227136) AND NOT(n4>198158383604301823 AND n4<216172782113783808 AND n3>92886742314516479 AND n3<93168217291227136)))) ORDER BY qm11.first_name, qm11.last_name ASC;"); |
|
731 result = mCntSqlSearch->CreateQwertyQuery(pattern); |
|
732 //qDebug() << pattern << " -> result" << result; |
|
733 LOG2(pattern, result); |
|
734 QVERIFY( !result.compare( reference) ); |
|
735 pattern = QString("syadira") + QChar(30) + QString("vqwerty"); |
|
736 reference = QString("SELECT contact_id FROM qm11 WHERE (NOT(NOT(n>199610571155832831 AND n<199610571156094976) AND NOT(n2>199610571155832831 AND n2<199610571156094976) AND NOT(n3>199610571155832831 AND n3<199610571156094976) AND NOT(n4>199610571155832831 AND n4<199610571156094976) AND NOT(n5>199610571155832831 AND n5<199610571156094976) AND NOT(n6>199610571155832831 AND n6<199610571156094976) AND NOT(n7>199610571155832831 AND n7<199610571156094976))) ORDER BY first_name, last_name ASC;"); |
|
737 result = mCntSqlSearch->CreateQwertyQuery(pattern); |
|
738 //qDebug() << pattern << " -> result" << result; |
|
739 LOG2(pattern, result); |
|
740 QVERIFY( !result.compare( reference) ); |
|
741 pattern = QString("qz") + QChar(30) + QString("vqwerty"); |
|
742 reference = QString("SELECT contact_id FROM qm0 WHERE (NOT(NOT(n>5348024557502463 AND n<5629499534213120) AND NOT(n2>5348024557502463 AND n2<5629499534213120) AND NOT(n3>5348024557502463 AND n3<5629499534213120) AND NOT(n4>5348024557502463 AND n4<5629499534213120) AND NOT(n5>5348024557502463 AND n5<5629499534213120) AND NOT(n6>5348024557502463 AND n6<5629499534213120) AND NOT(n7>5348024557502463 AND n7<5629499534213120))) ORDER BY first_name, last_name ASC;"); |
|
743 result = mCntSqlSearch->CreateQwertyQuery(pattern); |
|
744 //qDebug() << pattern << " -> result" << result; |
|
745 LOG2(pattern, result); |
|
746 QVERIFY( !result.compare( reference) ); |
|
747 pattern = QString("qz df") + QChar(30) + QString("vqwerty"); |
|
748 reference = QString("SELECT contact_id FROM qm0 WHERE NOT(NOT(NOT(NOT(n>5625941142798401 AND n<5625941142798403) AND NOT(n2>5625941142798401 AND n2<5625941142798403) AND NOT(n3>5625941142798401 AND n3<5625941142798403) AND NOT(n4>5625941142798401 AND n4<5625941142798403) AND NOT(n5>5625941142798401 AND n5<5625941142798403) AND NOT(n6>5625941142798401 AND n6<5625941142798403) AND NOT(n7>5625941142798401 AND n7<5625941142798403))) AND NOT(NOT(NOT(n2>219831956811022335 AND n2<220113431787732992 AND n>5348024557502463 AND n<5629499534213120) AND NOT(n3>219831956811022335 AND n3<220113431787732992 AND n>5348024557502463 AND n<5629499534213120) AND NOT(n3>219831956811022335 AND n3<220113431787732992 AND n2>5348024557502463 AND n2<5629499534213120) AND NOT(n4>219831956811022335 AND n4<220113431787732992 AND n>5348024557502463 AND n<5629499534213120) AND NOT(n4>219831956811022335 AND n4<220113431787732992 AND n2>5348024557502463 AND n2<5629499534213120) AND NOT(n4>219831956811022335 AND n4<220113431787732992 AND n3>5348024557502463 AND n3<5629499534213120))) AND NOT(NOT(NOT(n2>5348024557502463 AND n2<5629499534213120 AND n>219831956811022335 AND n<220113431787732992) AND NOT(n3>5348024557502463 AND n3<5629499534213120 AND n>219831956811022335 AND n<220113431787732992) AND NOT(n3>5348024557502463 AND n3<5629499534213120 AND n2>219831956811022335 AND n2<220113431787732992) AND NOT(n4>5348024557502463 AND n4<5629499534213120 AND n>219831956811022335 AND n<220113431787732992) AND NOT(n4>5348024557502463 AND n4<5629499534213120 AND n2>219831956811022335 AND n2<220113431787732992) AND NOT(n4>5348024557502463 AND n4<5629499534213120 AND n3>219831956811022335 AND n3<220113431787732992)))) ORDER BY qm0.first_name, qm0.last_name ASC;"); |
|
749 result = mCntSqlSearch->CreateQwertyQuery(pattern); |
|
750 //qDebug() << pattern << " -> result" << result; |
|
751 LOG2(pattern, result); |
|
752 QVERIFY( !result.compare( reference) ); |
|
753 pattern = QString("") + QChar(30) + QString("vqwerty"); |
|
754 reference = QString(""); |
|
755 result = mCntSqlSearch->CreateQwertyQuery(pattern); |
|
756 //qDebug() << pattern << " -> result" << result; |
|
757 LOG2(pattern, result); |
|
758 QVERIFY( !result.compare( reference) ); |
|
759 pattern = QString("levis.augu_whatever") + QChar(30) + QString("vqwerty"); |
|
760 reference = QString("SELECT contact_id FROM qm18 WHERE (NOT(NOT(n>324919373450470277 AND n<324919373450470279) AND NOT(n2>324919373450470277 AND n2<324919373450470279) AND NOT(n3>324919373450470277 AND n3<324919373450470279) AND NOT(n4>324919373450470277 AND n4<324919373450470279) AND NOT(n5>324919373450470277 AND n5<324919373450470279) AND NOT(n6>324919373450470277 AND n6<324919373450470279) AND NOT(n7>324919373450470277 AND n7<324919373450470279))) ORDER BY first_name, last_name ASC;"); |
|
761 result = mCntSqlSearch->CreateQwertyQuery(pattern); |
|
762 //qDebug() << pattern << " -> result" << result; |
|
763 LOG2(pattern, result); |
|
764 QVERIFY( !result.compare( reference) ); |
|
765 TEST_PASSED_LOG("testCreateQwertyQuery"); |
|
766 } |
|
767 |
|
768 void UT_CntSqlSearch::testExactMatchSearch() |
|
769 { |
|
770 TEST_BEGIN_LOG("testExactMatchSearch"); |
|
771 |
|
772 QString pattern("120"); |
|
773 #if defined(USE_DEMORGAN) |
|
774 QString reference("SELECT contact_id FROM predictivesearch1 WHERE (NOT(NOT(nbr>81064793292668927 AND nbr<81346268269379584) AND NOT(nbr2>81064793292668927 AND nbr2<81346268269379584) AND NOT(nbr3>81064793292668927 AND nbr3<81346268269379584) AND NOT(nbr4>81064793292668927 AND nbr4<81346268269379584)))"); |
|
775 #else // #if defined(USE_DEMORGAN) |
|
776 QString reference("SELECT contact_id FROM predictivesearch1 WHERE (nbr>81064793292668927 AND nbr<81346268269379584) OR (nbr2>81064793292668927 AND nbr2<81346268269379584) OR (nbr3>81064793292668927 AND nbr3<81346268269379584) OR (nbr4>81064793292668927 AND nbr4<81346268269379584)"); |
|
777 #endif // #if defined(USE_DEMORGAN) |
|
778 QString result = mCntSqlSearch->ExactMatchSearch(pattern); |
|
779 // qDebug() << pattern << " -> result" << result; |
|
780 LOG2(pattern, result); |
|
781 QVERIFY(result == reference); |
|
782 |
|
783 |
|
784 pattern = QString("5"); |
|
785 #if defined(USE_DEMORGAN) |
|
786 reference = "SELECT contact_id FROM predictivesearch5 WHERE (NOT(NOT(nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616)))"; |
|
787 #else // #if defined(USE_DEMORGAN) |
|
788 reference = "SELECT contact_id FROM predictivesearch5 WHERE (nbr>360287970189639679 AND nbr<432345564227567616) OR (nbr2>360287970189639679 AND nbr2<432345564227567616) OR (nbr3>360287970189639679 AND nbr3<432345564227567616) OR (nbr4>360287970189639679 AND nbr4<432345564227567616)"; |
|
789 #endif // #if defined(USE_DEMORGAN) |
|
790 result = mCntSqlSearch->ExactMatchSearch(pattern); |
|
791 // qDebug() << pattern << " -> result" << result; |
|
792 LOG2(pattern, result); |
|
793 QVERIFY(result == reference); |
|
794 |
|
795 |
|
796 pattern = QString("25"); |
|
797 #if defined(USE_DEMORGAN) |
|
798 reference = "SELECT contact_id FROM predictivesearch2 WHERE (NOT(NOT(nbr>166633186212708351 AND nbr<171136785840078848) AND NOT(nbr2>166633186212708351 AND nbr2<171136785840078848) AND NOT(nbr3>166633186212708351 AND nbr3<171136785840078848) AND NOT(nbr4>166633186212708351 AND nbr4<171136785840078848)))"; |
|
799 #else // #if defined(USE_DEMORGAN) |
|
800 reference = "SELECT contact_id FROM predictivesearch2 WHERE (nbr>166633186212708351 AND nbr<171136785840078848) OR (nbr2>166633186212708351 AND nbr2<171136785840078848) OR (nbr3>166633186212708351 AND nbr3<171136785840078848) OR (nbr4>166633186212708351 AND nbr4<171136785840078848)"; |
|
801 #endif // #if defined(USE_DEMORGAN) |
|
802 result = mCntSqlSearch->ExactMatchSearch(pattern); |
|
803 // qDebug() << pattern << " -> result" << result; |
|
804 LOG2(pattern, result); |
|
805 QVERIFY(result == reference); |
|
806 |
|
807 TEST_PASSED_LOG("testExactMatchSearch"); |
|
808 } |
|
809 void UT_CntSqlSearch::testExactMatchSearchQwerty() |
|
810 { |
|
811 TEST_BEGIN_LOG("testExactMatchSearchQwerty"); |
|
812 |
|
813 QString pattern("wt"); |
|
814 #if defined(USE_DEMORGAN) |
|
815 QString reference("(NOT(NOT(n>19140298416324607 AND n<19421773393035264) AND NOT(n2>19140298416324607 AND n2<19421773393035264) AND NOT(n3>19140298416324607 AND n3<19421773393035264) AND NOT(n4>19140298416324607 AND n4<19421773393035264) AND NOT(n5>19140298416324607 AND n5<19421773393035264) AND NOT(n6>19140298416324607 AND n6<19421773393035264) AND NOT(n7>19140298416324607 AND n7<19421773393035264)))"); |
|
816 #else // #if defined(USE_DEMORGAN) |
|
817 QString reference("(NOT(NOT(n>19140298416324607 AND n<19421773393035264) AND NOT(n2>19140298416324607 AND n2<19421773393035264) AND NOT(n3>19140298416324607 AND n3<19421773393035264) AND NOT(n4>19140298416324607 AND n4<19421773393035264) AND NOT(n5>19140298416324607 AND n5<19421773393035264) AND NOT(n6>19140298416324607 AND n6<19421773393035264) AND NOT(n7>19140298416324607 AND n7<19421773393035264)))"); |
|
818 #endif // #if defined(USE_DEMORGAN) |
|
819 QString result = mCntSqlSearch->ExactMatchQwerty(pattern); |
|
820 LOG2(pattern, result); |
|
821 QVERIFY(result == reference); |
|
822 TEST_PASSED_LOG("testExactMatchSearchQwerty"); |
|
823 } |
|
824 |
|
825 void UT_CntSqlSearch::testIntersectionSearch() |
|
826 { |
|
827 TEST_BEGIN_LOG("testIntersectionSearch"); |
|
828 |
|
829 QString pattern("205"); |
|
830 QStringList tokens; |
|
831 tokens << "2" << "5"; |
|
832 #if defined(SEARCH_FROM_ONE_TABLE) |
|
833 #if defined(USE_DEMORGAN) |
|
834 QString reference("SELECT contact_id FROM predictivesearch2 WHERE NOT(NOT(NOT(NOT(nbr>145522562959409151 AND nbr<145804037936119808) AND NOT(nbr2>145522562959409151 AND nbr2<145804037936119808) AND NOT(nbr3>145522562959409151 AND nbr3<145804037936119808) AND NOT(nbr4>145522562959409151 AND nbr4<145804037936119808))) AND NOT(NOT(NOT(nbr2>360287970189639679 AND nbr2<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr3>144115188075855871 AND nbr3<216172782113783808))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>360287970189639679 AND nbr3<432345564227567616)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
835 #else // #if defined(USE_DEMORGAN) |
|
836 QString reference("SELECT contact_id FROM predictivesearch2 WHERE \ |
|
837 ((nbr>145522562959409151 AND nbr<145804037936119808) OR (nbr2>145522562959409151 AND nbr2<145804037936119808) OR \ |
|
838 (nbr3>145522562959409151 AND nbr3<145804037936119808) OR (nbr4>145522562959409151 AND nbr4<145804037936119808)) OR \ |
|
839 (nbr2>360287970189639679 AND nbr2<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
840 (nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
841 (nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
842 (nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) OR \ |
|
843 (nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) OR \ |
|
844 (nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr3>144115188075855871 AND nbr3<216172782113783808) OR \ |
|
845 (nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) OR \ |
|
846 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) OR \ |
|
847 (nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) OR \ |
|
848 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) OR \ |
|
849 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) OR \ |
|
850 (nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>360287970189639679 AND nbr3<432345564227567616) \ |
|
851 ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
852 #endif // #if defined(USE_DEMORGAN) |
|
853 #else // #if defined(SEARCH_FROM_ONE_TABLE) |
|
854 QString reference("SELECT predictivesearch2.contact_id FROM predictivesearch2 WHERE EXISTS (SELECT contact_id FROM predictivesearch5 WHERE predictivesearch2.contact_id = predictivesearch5.contact_id) OR (SELECT contact_id FROM predictivesearch2 WHERE (NOT(NOT(predictivesearch2.nbr>145522562959409151 AND predictivesearch2.nbr<145804037936119808) AND NOT(predictivesearch2.nbr2>145522562959409151 AND predictivesearch2.nbr2<145804037936119808) AND NOT(predictivesearch2.nbr3>145522562959409151 AND predictivesearch2.nbr3<145804037936119808) AND NOT(predictivesearch2.nbr4>145522562959409151 AND predictivesearch2.nbr4<145804037936119808)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
855 #endif // #if defined(SEARCH_FROM_ONE_TABLE) |
|
856 QString result = mCntSqlSearch->IntersectionSearch(pattern, tokens); |
|
857 // qDebug() << pattern << " -> result" << result; |
|
858 LOG2(pattern, result); |
|
859 LOG2("result", result); |
|
860 QVERIFY( !result.compare( reference) ); |
|
861 |
|
862 TEST_PASSED_LOG("testIntersectionSearch"); |
|
863 } |
|
864 void UT_CntSqlSearch::testSearchTokensFromOneTable() |
|
865 { |
|
866 TEST_BEGIN_LOG("testSearchTokensFromOneTable"); |
|
867 QString pattern("205"); |
|
868 QStringList tokens; |
|
869 tokens << "2" << "5"; |
|
870 QString reference("SELECT contact_id FROM predictivesearch2 WHERE NOT(NOT(NOT(NOT(nbr>145522562959409151 AND nbr<145804037936119808) AND NOT(nbr2>145522562959409151 AND nbr2<145804037936119808) AND NOT(nbr3>145522562959409151 AND nbr3<145804037936119808) AND NOT(nbr4>145522562959409151 AND nbr4<145804037936119808))) AND NOT(NOT(NOT(nbr2>360287970189639679 AND nbr2<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr3>360287970189639679 AND nbr3<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr>144115188075855871 AND nbr<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr2>144115188075855871 AND nbr2<216172782113783808) AND NOT(nbr4>360287970189639679 AND nbr4<432345564227567616 AND nbr3>144115188075855871 AND nbr3<216172782113783808))) AND NOT(NOT(NOT(nbr2>144115188075855871 AND nbr2<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr3>144115188075855871 AND nbr3<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr>360287970189639679 AND nbr<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr2>360287970189639679 AND nbr2<432345564227567616) AND NOT(nbr4>144115188075855871 AND nbr4<216172782113783808 AND nbr3>360287970189639679 AND nbr3<432345564227567616)))) ORDER BY predictivesearch2.first_name, predictivesearch2.last_name ASC;"); |
|
871 QString result = mCntSqlSearch->SearchTokensFromOneTable(pattern, tokens); |
|
872 QVERIFY( !result.compare( reference) ); |
|
873 |
|
874 pattern = QString("e p"); |
|
875 tokens.clear(); |
|
876 tokens << "e" << "p"; |
|
877 reference = QString("SELECT contact_id FROM qm2 WHERE NOT(NOT(NOT(NOT(n>53801302970335231 AND n<53805701016846336) AND NOT(n2>53801302970335231 AND n2<53805701016846336) AND NOT(n3>53801302970335231 AND n3<53805701016846336) AND NOT(n4>53801302970335231 AND n4<53805701016846336) AND NOT(n5>53801302970335231 AND n5<53805701016846336) AND NOT(n6>53801302970335231 AND n6<53805701016846336) AND NOT(n7>53801302970335231 AND n7<53805701016846336))) AND NOT(NOT(NOT(n2>162129586585337855 AND n2<180143985094819840 AND n>36028797018963967 AND n<54043195528445952) AND NOT(n3>162129586585337855 AND n3<180143985094819840 AND n>36028797018963967 AND n<54043195528445952) AND NOT(n3>162129586585337855 AND n3<180143985094819840 AND n2>36028797018963967 AND n2<54043195528445952) AND NOT(n4>162129586585337855 AND n4<180143985094819840 AND n>36028797018963967 AND n<54043195528445952) AND NOT(n4>162129586585337855 AND n4<180143985094819840 AND n2>36028797018963967 AND n2<54043195528445952) AND NOT(n4>162129586585337855 AND n4<180143985094819840 AND n3>36028797018963967 AND n3<54043195528445952))) AND NOT(NOT(NOT(n2>36028797018963967 AND n2<54043195528445952 AND n>162129586585337855 AND n<180143985094819840) AND NOT(n3>36028797018963967 AND n3<54043195528445952 AND n>162129586585337855 AND n<180143985094819840) AND NOT(n3>36028797018963967 AND n3<54043195528445952 AND n2>162129586585337855 AND n2<180143985094819840) AND NOT(n4>36028797018963967 AND n4<54043195528445952 AND n>162129586585337855 AND n<180143985094819840) AND NOT(n4>36028797018963967 AND n4<54043195528445952 AND n2>162129586585337855 AND n2<180143985094819840) AND NOT(n4>36028797018963967 AND n4<54043195528445952 AND n3>162129586585337855 AND n3<180143985094819840)))) ORDER BY qm2.first_name, qm2.last_name ASC;"); |
|
878 result = mCntSqlSearch->SearchTokensFromOneTable(pattern, tokens, CntSqlSearch::QwertyEmail); |
|
879 //qDebug() << pattern << " -> result" << result; |
|
880 QVERIFY( !result.compare( reference) ); |
|
881 TEST_PASSED_LOG("testSearchTokensFromOneTable"); |
|
882 } |
|
883 void UT_CntSqlSearch::testExactMatch() |
|
884 { |
|
885 TEST_BEGIN_LOG("testExactMatch"); |
|
886 |
|
887 QString pattern("25"); |
|
888 #if defined(USE_DEMORGAN) |
|
889 QString reference("(NOT(NOT(nbr>166633186212708351 AND nbr<171136785840078848) AND NOT(nbr2>166633186212708351 AND nbr2<171136785840078848) AND NOT(nbr3>166633186212708351 AND nbr3<171136785840078848) AND NOT(nbr4>166633186212708351 AND nbr4<171136785840078848)))"); |
|
890 #else // #if defined(USE_DEMORGAN) |
|
891 QString reference("(nbr>166633186212708351 AND nbr<171136785840078848) OR (nbr2>166633186212708351 AND nbr2<171136785840078848) OR (nbr3>166633186212708351 AND nbr3<171136785840078848) OR (nbr4>166633186212708351 AND nbr4<171136785840078848)"); |
|
892 #endif // #if defined(USE_DEMORGAN) |
|
893 QString result = mCntSqlSearch->ExactMatch(pattern); |
|
894 // LOG2(pattern, result); |
|
895 QVERIFY(!result.compare(reference)); |
|
896 |
|
897 TEST_PASSED_LOG("testExactMatch"); |
|
898 } |
|
899 void UT_CntSqlSearch::testExactMatchQwerty() |
|
900 { |
|
901 TEST_BEGIN_LOG("testExactMatchQwerty"); |
|
902 |
|
903 QString pattern("25"); |
|
904 #if defined(USE_DEMORGAN) |
|
905 QString reference("(NOT(NOT(n>604608249974489087 AND n<604889724951199744) AND NOT(n2>604608249974489087 AND n2<604889724951199744) AND NOT(n3>604608249974489087 AND n3<604889724951199744) AND NOT(n4>604608249974489087 AND n4<604889724951199744) AND NOT(n5>604608249974489087 AND n5<604889724951199744) AND NOT(n6>604608249974489087 AND n6<604889724951199744) AND NOT(n7>604608249974489087 AND n7<604889724951199744)))"); |
|
906 #else // #if defined(USE_DEMORGAN) |
|
907 QString reference("(nbr>166633186212708351 AND nbr<171136785840078848) OR (nbr2>166633186212708351 AND nbr2<171136785840078848) OR (nbr3>166633186212708351 AND nbr3<171136785840078848) OR (nbr4>166633186212708351 AND nbr4<171136785840078848)"); |
|
908 #endif // #if defined(USE_DEMORGAN) |
|
909 QString result = mCntSqlSearch->ExactMatchQwerty(pattern); |
|
910 LOG2(pattern, result); |
|
911 QVERIFY(!result.compare(reference)); |
|
912 |
|
913 TEST_PASSED_LOG("testExactMatchQwerty"); |
|
914 } |
|
915 |
|
916 void UT_CntSqlSearch::testCreateJoinTableSearch() |
|
917 { |
|
918 TEST_BEGIN_LOG("testCreateJoinTableSearch"); |
|
919 |
|
920 QString pattern("5606"); |
|
921 QStringList tokens; |
|
922 tokens << "56" << "6"; |
|
923 QString reference; |
|
924 QString result; |
|
925 #if defined(USE_DEMORGAN) |
|
926 reference = QString("SELECT contact_id FROM (SELECT predictivesearch5.contact_id, predictivesearch5.first_name, predictivesearch5.last_name FROM predictivesearch5 WHERE (NOT(NOT(predictivesearch5.nbr>387415121070129151 AND predictivesearch5.nbr<387432713256173568) AND NOT(predictivesearch5.nbr2>387415121070129151 AND predictivesearch5.nbr2<387432713256173568) AND NOT(predictivesearch5.nbr3>387415121070129151 AND predictivesearch5.nbr3<387432713256173568) AND NOT(predictivesearch5.nbr4>387415121070129151 AND predictivesearch5.nbr4<387432713256173568))) UNION SELECT predictivesearch5.contact_id, predictivesearch5.first_name, predictivesearch5.last_name FROM predictivesearch5 JOIN predictivesearch6 ON predictivesearch5.contact_id = predictivesearch6.contact_id WHERE(NOT(NOT(predictivesearch5.nbr>387309567953862655 AND predictivesearch5.nbr<391813167581233152) AND NOT(predictivesearch5.nbr2>387309567953862655 AND predictivesearch5.nbr2<391813167581233152) AND NOT(predictivesearch5.nbr3>387309567953862655 AND predictivesearch5.nbr3<391813167581233152) AND NOT(predictivesearch5.nbr4>387309567953862655 AND predictivesearch5.nbr4<391813167581233152)))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
927 #else // #if defined(USE_DEMORGAN) |
|
928 // TODO: add non-De Morgan cases |
|
929 #endif // #if defined(USE_DEMORGAN) |
|
930 result = mCntSqlSearch->CreateJoinTableSearch(pattern, tokens); |
|
931 //qDebug() << pattern << " -> result" << result; |
|
932 LOG2(pattern, result); |
|
933 QVERIFY(!result.compare(reference)); |
|
934 |
|
935 pattern = QString ("250052"); |
|
936 tokens.clear(); |
|
937 tokens << "25" << "52"; |
|
938 #if defined(USE_DEMORGAN) |
|
939 reference = QString("SELECT contact_id FROM (SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 WHERE (NOT(NOT(predictivesearch2.nbr>166638821209800703 AND predictivesearch2.nbr<166638889929277440) AND NOT(predictivesearch2.nbr2>166638821209800703 AND predictivesearch2.nbr2<166638889929277440) AND NOT(predictivesearch2.nbr3>166638821209800703 AND predictivesearch2.nbr3<166638889929277440) AND NOT(predictivesearch2.nbr4>166638821209800703 AND predictivesearch2.nbr4<166638889929277440))) UNION SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 JOIN predictivesearch5 ON predictivesearch2.contact_id = predictivesearch5.contact_id WHERE((NOT(NOT(predictivesearch2.nbr>166633186212708351 AND predictivesearch2.nbr<171136785840078848) AND NOT(predictivesearch2.nbr2>166633186212708351 AND predictivesearch2.nbr2<171136785840078848) AND NOT(predictivesearch2.nbr3>166633186212708351 AND predictivesearch2.nbr3<171136785840078848) AND NOT(predictivesearch2.nbr4>166633186212708351 AND predictivesearch2.nbr4<171136785840078848))) AND (NOT(NOT(predictivesearch5.nbr>369295169444380671 AND predictivesearch5.nbr<373798769071751168) AND NOT(predictivesearch5.nbr2>369295169444380671 AND predictivesearch5.nbr2<373798769071751168) AND NOT(predictivesearch5.nbr3>369295169444380671 AND predictivesearch5.nbr3<373798769071751168) AND NOT(predictivesearch5.nbr4>369295169444380671 AND predictivesearch5.nbr4<373798769071751168))))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
940 #else // #if defined(USE_DEMORGAN) |
|
941 // TODO: add non-De Morgan cases |
|
942 #endif // #if defined(USE_DEMORGAN) |
|
943 result = mCntSqlSearch->CreateJoinTableSearch(pattern, tokens); |
|
944 //qDebug() << pattern << " -> result" << result; |
|
945 LOG2(pattern, result); |
|
946 QVERIFY(!result.compare(reference)); |
|
947 |
|
948 pattern.clear(); |
|
949 pattern = "2505"; |
|
950 tokens.clear(); |
|
951 tokens << "25" << "5"; |
|
952 #if defined(USE_DEMORGAN) |
|
953 reference = QString("SELECT contact_id FROM (SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 WHERE (NOT(NOT(predictivesearch2.nbr>166721147142930431 AND predictivesearch2.nbr<166738739328974848) AND NOT(predictivesearch2.nbr2>166721147142930431 AND predictivesearch2.nbr2<166738739328974848) AND NOT(predictivesearch2.nbr3>166721147142930431 AND predictivesearch2.nbr3<166738739328974848) AND NOT(predictivesearch2.nbr4>166721147142930431 AND predictivesearch2.nbr4<166738739328974848))) UNION SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 JOIN predictivesearch5 ON predictivesearch2.contact_id = predictivesearch5.contact_id WHERE(NOT(NOT(predictivesearch2.nbr>166633186212708351 AND predictivesearch2.nbr<171136785840078848) AND NOT(predictivesearch2.nbr2>166633186212708351 AND predictivesearch2.nbr2<171136785840078848) AND NOT(predictivesearch2.nbr3>166633186212708351 AND predictivesearch2.nbr3<171136785840078848) AND NOT(predictivesearch2.nbr4>166633186212708351 AND predictivesearch2.nbr4<171136785840078848)))) AS PR ORDER BY PR.first_name, PR.last_name ASC;"); |
|
954 #else // #if defined(USE_DEMORGAN) |
|
955 // TODO: add non-De Morgan cases |
|
956 #endif // #if defined(USE_DEMORGAN) |
|
957 result = mCntSqlSearch->CreateJoinTableSearch(pattern, tokens); |
|
958 //qDebug() << pattern << " -> result" << result; |
|
959 LOG2(pattern, result); |
|
960 QVERIFY(!result.compare(reference)); |
|
961 |
|
962 // TODO: Test this case on HW and verify leading zeros. |
|
963 pattern.clear(); |
|
964 pattern = "0705"; |
|
965 tokens.clear(); |
|
966 tokens << "7" << "5"; |
|
967 #if defined(USE_DEMORGAN) |
|
968 reference = QString("SELECT contact_id FROM (SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 WHERE (NOT(NOT(predictivesearch2.nbr>145557747331497983 AND predictivesearch2.nbr<145575339517542400) AND NOT(predictivesearch2.nbr2>145557747331497983 AND predictivesearch2.nbr2<145575339517542400) AND NOT(predictivesearch2.nbr3>145557747331497983 AND predictivesearch2.nbr3<145575339517542400) AND NOT(predictivesearch2.nbr4>145557747331497983 AND predictivesearch2.nbr4<145575339517542400))) UNION SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 JOIN predictivesearch5 ON predictivesearch2.contact_id = predictivesearch5.contact_id WHERE(NOT(NOT(predictivesearch5.nbr>369295169444380671 AND predictivesearch5.nbr<373798769071751168) AND NOT(predictivesearch5.nbr2>369295169444380671 AND predictivesearch5.nbr2<373798769071751168) AND NOT(predictivesearch5.nbr3>369295169444380671 AND predictivesearch5.nbr3<373798769071751168) AND NOT(predictivesearch5.nbr4>369295169444380671 AND predictivesearch5.nbr4<373798769071751168)))) AS PR ORDER BY PR.first_name, PR.last_name ASC"); |
|
969 #else // #if defined(USE_DEMORGAN) |
|
970 // TODO: add non-De Morgan cases |
|
971 #endif // #if defined(USE_DEMORGAN) |
|
972 result = mCntSqlSearch->CreateJoinTableSearch(pattern, tokens); |
|
973 //qDebug() << pattern << result; |
|
974 LOG2(pattern, result); |
|
975 QVERIFY(!result.compare(result)); |
|
976 |
|
977 pattern.clear(); |
|
978 pattern = "2052"; |
|
979 tokens.clear(); |
|
980 tokens << "2" << "52"; |
|
981 #if defined(USE_DEMORGAN) |
|
982 reference = QString("SELECT contact_id FROM (SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 WHERE (NOT(NOT(predictivesearch2.nbr>145557747331497983 AND predictivesearch2.nbr<145575339517542400) AND NOT(predictivesearch2.nbr2>145557747331497983 AND predictivesearch2.nbr2<145575339517542400) AND NOT(predictivesearch2.nbr3>145557747331497983 AND predictivesearch2.nbr3<145575339517542400) AND NOT(predictivesearch2.nbr4>145557747331497983 AND predictivesearch2.nbr4<145575339517542400))) UNION SELECT predictivesearch2.contact_id, predictivesearch2.first_name, predictivesearch2.last_name FROM predictivesearch2 JOIN predictivesearch5 ON predictivesearch2.contact_id = predictivesearch5.contact_id WHERE(NOT(NOT(predictivesearch5.nbr>369295169444380671 AND predictivesearch5.nbr<373798769071751168) AND NOT(predictivesearch5.nbr2>369295169444380671 AND predictivesearch5.nbr2<373798769071751168) AND NOT(predictivesearch5.nbr3>369295169444380671 AND predictivesearch5.nbr3<373798769071751168) AND NOT(predictivesearch5.nbr4>369295169444380671 AND predictivesearch5.nbr4<373798769071751168)))) AS PR ORDER BY PR.first_name, PR.last_name ASC"); |
|
983 #else // #if defined(USE_DEMORGAN) |
|
984 // TODO: add non-De Morgan cases |
|
985 #endif // #if defined(USE_DEMORGAN) |
|
986 result = mCntSqlSearch->CreateJoinTableSearch(pattern, tokens); |
|
987 //qDebug() << "pattern " << result; |
|
988 LOG2(pattern, result); |
|
989 QVERIFY(!result.compare(result)); |
|
990 |
|
991 TEST_PASSED_LOG("testCreateJoinTableSearch"); |
|
992 } |
|
993 void UT_CntSqlSearch::testCompareTwoQwertyColumns() |
|
994 { |
|
995 TEST_BEGIN_LOG("testChangeStringPadings"); |
|
996 QString pattern("234"); |
|
997 QString result; |
|
998 QString reference(""); |
|
999 //result = mCntSqlSearch->CompareTwoQwertyColumns(pattern); |
|
1000 //qDebug() << pattern << " -> result" << result; |
|
1001 //QVERIFY( result == reference ); |
|
1002 TEST_PASSED_LOG("testCreateJoinTableSearch"); |
|
1003 } |
|
1004 void UT_CntSqlSearch::testChangeStringPadings() |
|
1005 { |
|
1006 TEST_BEGIN_LOG("testChangeStringPadings"); |
|
1007 |
|
1008 QString pattern("234"); |
|
1009 QString result; |
|
1010 QString reference("234"); |
|
1011 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1012 //qDebug() << pattern << " -> result" << result; |
|
1013 QVERIFY( result == reference ); |
|
1014 |
|
1015 pattern = QString("*"); |
|
1016 reference = QString("A"); |
|
1017 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1018 |
|
1019 pattern = QString("+"); |
|
1020 reference = QString("A"); |
|
1021 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1022 |
|
1023 pattern = QString("p"); |
|
1024 reference = QString("A"); |
|
1025 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1026 |
|
1027 pattern = QString("w"); |
|
1028 reference = QString("A"); |
|
1029 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1030 |
|
1031 pattern = QString("#"); |
|
1032 reference = QString("B"); |
|
1033 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1034 |
|
1035 pattern = QString("0#0"); |
|
1036 reference = QString("0B0"); |
|
1037 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1038 |
|
1039 pattern = QString("#00"); |
|
1040 reference = QString("B00"); |
|
1041 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1042 |
|
1043 pattern = QString("*#"); |
|
1044 reference = QString("AB"); |
|
1045 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1046 |
|
1047 pattern = QString("1*2#3"); |
|
1048 reference = QString("1A2B3"); |
|
1049 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1050 |
|
1051 //Thai tests |
|
1052 QLocale::setDefault(QLocale::Thai); |
|
1053 pattern = QString("*"); |
|
1054 reference = QString(""); |
|
1055 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1056 |
|
1057 pattern = QString("+"); |
|
1058 reference = QString(""); |
|
1059 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1060 |
|
1061 pattern = QString("p"); |
|
1062 reference = QString(""); |
|
1063 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1064 |
|
1065 pattern = QString("w"); |
|
1066 reference = QString(""); |
|
1067 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1068 |
|
1069 pattern = QString("#"); |
|
1070 reference = QString(""); |
|
1071 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1072 |
|
1073 pattern = QString("0#0"); |
|
1074 reference = QString("00"); |
|
1075 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1076 |
|
1077 pattern = QString("#00"); |
|
1078 reference = QString("00"); |
|
1079 |
|
1080 pattern = QString("00*"); |
|
1081 reference = QString("00"); |
|
1082 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1083 |
|
1084 pattern = QString("*#"); |
|
1085 reference = QString(""); |
|
1086 result = mCntSqlSearch->ChangeStringPadings(pattern); |
|
1087 |
|
1088 TEST_PASSED_LOG("testChangeStringPadings"); |
|
1089 } |
|
1090 |
|
1091 void UT_CntSqlSearch::testUpperLimit() |
|
1092 { |
|
1093 TEST_BEGIN_LOG("testUpperLimit"); |
|
1094 |
|
1095 QString pattern("234"); |
|
1096 QString result; |
|
1097 QString reference("159033361841520640"); |
|
1098 result = mCntSqlSearch->UpperLimit(pattern); |
|
1099 //qDebug() << pattern << " -> result" << result; |
|
1100 QVERIFY( result == reference ); |
|
1101 |
|
1102 pattern = QString("234456576687687"); |
|
1103 reference = QString("158828188945381000"); |
|
1104 result = mCntSqlSearch->UpperLimit(pattern); |
|
1105 //qDebug() << pattern << " -> result" << result; |
|
1106 QVERIFY( result == reference ); |
|
1107 |
|
1108 // Same result as above case, characters beyond 15th are ignored |
|
1109 pattern = QString("2344565766876874906754968"); |
|
1110 result = mCntSqlSearch->UpperLimit(pattern); |
|
1111 //qDebug() << pattern << " -> result" << result; |
|
1112 QVERIFY( result == reference ); |
|
1113 |
|
1114 pattern = QString("004456"); |
|
1115 reference = QString("1202247245496320"); |
|
1116 result = mCntSqlSearch->UpperLimit(pattern); |
|
1117 //qDebug() << pattern << " -> result" << result; |
|
1118 QVERIFY( result == reference ); |
|
1119 |
|
1120 pattern = QString(""); |
|
1121 reference = QString("1152921504606846976"); |
|
1122 result = mCntSqlSearch->UpperLimit(pattern); |
|
1123 //qDebug() << pattern << " -> result" << result; |
|
1124 QVERIFY( result == reference ); |
|
1125 |
|
1126 |
|
1127 pattern = QString("000000000000000"); |
|
1128 reference = QString("1"); |
|
1129 result = mCntSqlSearch->UpperLimit(pattern); |
|
1130 //qDebug() << pattern << " -> result" << result; |
|
1131 QVERIFY( result == reference ); |
|
1132 |
|
1133 pattern = QString("0000000000000"); |
|
1134 reference = QString("256"); |
|
1135 result = mCntSqlSearch->UpperLimit(pattern); |
|
1136 //qDebug() << pattern << " -> result" << result; |
|
1137 QVERIFY( result == reference ); |
|
1138 |
|
1139 TEST_PASSED_LOG("testUpperLimit"); |
|
1140 } |
|
1141 |
|
1142 void UT_CntSqlSearch::testLowerLimit() |
|
1143 { |
|
1144 TEST_BEGIN_LOG("testLowerLimit"); |
|
1145 |
|
1146 QString pattern("234"); |
|
1147 QString result; |
|
1148 QString reference("158751886864809983"); |
|
1149 result = mCntSqlSearch->LowerLimit(pattern); |
|
1150 //qDebug() << pattern << " -> result" << result; |
|
1151 QVERIFY( result == reference ); |
|
1152 |
|
1153 pattern = QString("234456576687687"); |
|
1154 reference = QString("158828188945380998"); |
|
1155 result = mCntSqlSearch->LowerLimit(pattern); |
|
1156 //qDebug() << pattern << " -> result" << result; |
|
1157 QVERIFY( result == reference ); |
|
1158 |
|
1159 // Same result as above case, characters beyond 15th are ignored |
|
1160 pattern = QString("23445657668768749067549685"); |
|
1161 result = mCntSqlSearch->LowerLimit(pattern); |
|
1162 //qDebug() << pattern << " -> result" << result; |
|
1163 QVERIFY( result == reference ); |
|
1164 |
|
1165 pattern = QString("001021"); |
|
1166 reference = QString("283742719442943"); |
|
1167 result = mCntSqlSearch->LowerLimit(pattern); |
|
1168 //qDebug() << pattern << " -> result" << result; |
|
1169 QVERIFY( result == reference ); |
|
1170 |
|
1171 pattern = QString("1021500"); |
|
1172 reference = QString("72643633735532543"); |
|
1173 result = mCntSqlSearch->LowerLimit(pattern); |
|
1174 //qDebug() << pattern << " -> result" << result; |
|
1175 QVERIFY( result == reference ); |
|
1176 |
|
1177 pattern = QString(""); |
|
1178 reference = QString("-1"); |
|
1179 result = mCntSqlSearch->LowerLimit(pattern); |
|
1180 //qDebug() << pattern << " -> result" << result; |
|
1181 QVERIFY( result == reference ); |
|
1182 |
|
1183 // Lower limit for this is -1 |
|
1184 pattern = QString("000000000000000"); |
|
1185 reference = QString("-1"); // Lower limit is now zero minus one |
|
1186 result = mCntSqlSearch->LowerLimit(pattern); |
|
1187 //qDebug() << pattern << " -> result" << result; |
|
1188 QVERIFY( result == reference ); |
|
1189 |
|
1190 // Lower limit for this is -1 |
|
1191 pattern = QString("00"); |
|
1192 reference = QString("-1"); |
|
1193 result = mCntSqlSearch->LowerLimit(pattern); |
|
1194 //qDebug() << pattern << " -> result" << result; |
|
1195 QVERIFY( result == reference ); |
|
1196 |
|
1197 // Pattern contains 0xA and 0xB digits |
|
1198 pattern = QString("AB0B9A"); |
|
1199 reference = QString("770319633126260735"); |
|
1200 result = mCntSqlSearch->LowerLimit(pattern); |
|
1201 //qDebug() << pattern << " -> result" << result; |
|
1202 QVERIFY( result == reference ); |
|
1203 |
|
1204 TEST_PASSED_LOG("testLowerLimit"); |
|
1205 } |
|
1206 |
|
1207 void UT_CntSqlSearch::testGetTokens() |
|
1208 { |
|
1209 TEST_BEGIN_LOG("testGetTokens"); |
|
1210 |
|
1211 QStringList tokens = mCntSqlSearch->GetTokens(""); |
|
1212 QVERIFY(tokens.count() == 0); |
|
1213 |
|
1214 tokens = mCntSqlSearch->GetTokens("0"); |
|
1215 QVERIFY(tokens.count() == 0); |
|
1216 |
|
1217 tokens = mCntSqlSearch->GetTokens("00"); |
|
1218 QVERIFY(tokens.count() == 0); |
|
1219 |
|
1220 tokens = mCntSqlSearch->GetTokens("000000000000000000000000"); |
|
1221 QVERIFY(tokens.count() == 0); |
|
1222 |
|
1223 tokens = mCntSqlSearch->GetTokens("1"); |
|
1224 QVERIFY(tokens.count() == 1); |
|
1225 QVERIFY(tokens.at(0) == "1"); |
|
1226 |
|
1227 tokens = mCntSqlSearch->GetTokens("01"); |
|
1228 QVERIFY(tokens.count() == 1); |
|
1229 QVERIFY(tokens.at(0) == "1"); |
|
1230 |
|
1231 tokens = mCntSqlSearch->GetTokens("1"); |
|
1232 QVERIFY(tokens.count() == 1); |
|
1233 QVERIFY(tokens.at(0) == "1"); |
|
1234 |
|
1235 tokens = mCntSqlSearch->GetTokens("000028"); |
|
1236 QVERIFY(tokens.count() == 1); |
|
1237 QVERIFY(tokens.at(0) == "28"); |
|
1238 |
|
1239 tokens = mCntSqlSearch->GetTokens("000019700"); |
|
1240 QVERIFY(tokens.count() == 1); |
|
1241 QVERIFY(tokens.at(0) == "197"); |
|
1242 |
|
1243 tokens = mCntSqlSearch->GetTokens("101"); |
|
1244 QVERIFY(tokens.count() == 2); |
|
1245 QVERIFY(tokens.at(0) == "1"); |
|
1246 QVERIFY(tokens.at(1) == "1"); |
|
1247 |
|
1248 tokens = mCntSqlSearch->GetTokens("1203"); |
|
1249 QVERIFY(tokens.count() == 2); |
|
1250 QVERIFY(tokens.at(0) == "12"); |
|
1251 QVERIFY(tokens.at(1) == "3"); |
|
1252 |
|
1253 tokens = mCntSqlSearch->GetTokens("000012013"); |
|
1254 QVERIFY(tokens.count() == 2); |
|
1255 QVERIFY(tokens.at(0) == "000012"); |
|
1256 QVERIFY(tokens.at(1) == "13"); |
|
1257 |
|
1258 tokens = mCntSqlSearch->GetTokens("00206"); |
|
1259 QVERIFY(tokens.count() == 2); |
|
1260 QVERIFY(tokens.at(0) == "002"); |
|
1261 QVERIFY(tokens.at(1) == "6"); |
|
1262 |
|
1263 tokens = mCntSqlSearch->GetTokens("001230045067800900"); |
|
1264 QVERIFY(tokens.count() == 2); |
|
1265 QVERIFY(tokens.at(0) == "00123"); |
|
1266 QVERIFY(tokens.at(1) == "45067800900"); |
|
1267 |
|
1268 tokens = mCntSqlSearch->GetTokens("1000002030405060708090011"); |
|
1269 QVERIFY(tokens.count() == 2); |
|
1270 QVERIFY(tokens.at(0) == "1"); |
|
1271 QVERIFY(tokens.at(1) == "2030405060708090011"); |
|
1272 |
|
1273 tokens = mCntSqlSearch->GetTokens("4304"); |
|
1274 QVERIFY(tokens.count() == 2); |
|
1275 QVERIFY(tokens.at(0) == "43"); |
|
1276 QVERIFY(tokens.at(1) == "4"); |
|
1277 |
|
1278 tokens = mCntSqlSearch->GetTokens("010203040506070809011001200130014001500"); |
|
1279 QVERIFY(tokens.count() == 2); |
|
1280 QVERIFY(tokens.at(0) == "01"); |
|
1281 QVERIFY(tokens.at(1) == "203040506070809011001200130014001500"); |
|
1282 |
|
1283 TEST_PASSED_LOG("testGetTokens"); |
|
1284 } |
|
1285 |
|
1286 void UT_CntSqlSearch::testTestPattern() |
|
1287 { |
|
1288 TEST_BEGIN_LOG("testTestPattern"); |
|
1289 QString pattern("000"); |
|
1290 int result; |
|
1291 int reference = false; |
|
1292 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1293 QCOMPARE( result, reference ); |
|
1294 |
|
1295 pattern = QString("0"); |
|
1296 reference = false; |
|
1297 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1298 QCOMPARE( result, reference ); |
|
1299 |
|
1300 pattern = QString("20"); |
|
1301 reference = true; |
|
1302 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1303 QCOMPARE( result, reference ); |
|
1304 |
|
1305 pattern = QString("202"); |
|
1306 reference = false; |
|
1307 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1308 QCOMPARE( result, reference ); |
|
1309 |
|
1310 pattern = QString("200"); |
|
1311 reference = false; |
|
1312 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1313 QCOMPARE( result, reference ); |
|
1314 |
|
1315 pattern = QString("2000"); |
|
1316 reference = false; |
|
1317 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1318 QCOMPARE( result, reference ); |
|
1319 |
|
1320 pattern = QString("020002"); |
|
1321 reference = false; |
|
1322 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1323 QCOMPARE( result, reference ); |
|
1324 |
|
1325 pattern = QString("A0"); |
|
1326 reference = true; |
|
1327 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1328 QCOMPARE( result, reference ); |
|
1329 |
|
1330 pattern = QString(""); |
|
1331 reference = false; |
|
1332 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1333 QCOMPARE( result, reference ); |
|
1334 TEST_PASSED_LOG("testTestPattern"); |
|
1335 |
|
1336 pattern = QString("232"); |
|
1337 reference = false; |
|
1338 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZerosEndOfFirstToken); |
|
1339 QCOMPARE( result, reference ); |
|
1340 |
|
1341 pattern = QString("232"); |
|
1342 reference = false; |
|
1343 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1344 QCOMPARE( result, reference ); |
|
1345 |
|
1346 pattern = QString("2320"); |
|
1347 reference = false; |
|
1348 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1349 QCOMPARE( result, reference ); |
|
1350 |
|
1351 pattern = QString("2302"); |
|
1352 reference = false; |
|
1353 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1354 QCOMPARE( result, reference ); |
|
1355 |
|
1356 pattern = QString("23020"); |
|
1357 reference = false; |
|
1358 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1359 QCOMPARE( result, reference ); |
|
1360 |
|
1361 pattern = QString("023020"); |
|
1362 reference = true; |
|
1363 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1364 QCOMPARE( result, reference ); |
|
1365 |
|
1366 pattern = QString("02320"); |
|
1367 reference = true; |
|
1368 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1369 QCOMPARE( result, reference ); |
|
1370 |
|
1371 pattern = QString("02302"); |
|
1372 reference = true; |
|
1373 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1374 QCOMPARE( result, reference ); |
|
1375 |
|
1376 pattern = QString("0232"); |
|
1377 reference = true; |
|
1378 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1379 QCOMPARE( result, reference ); |
|
1380 |
|
1381 pattern = QString("00232"); |
|
1382 reference = false; |
|
1383 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1384 QCOMPARE( result, reference ); |
|
1385 |
|
1386 pattern = QString("0"); |
|
1387 reference = false; |
|
1388 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1389 QCOMPARE( result, reference ); |
|
1390 |
|
1391 pattern = QString("00"); |
|
1392 reference = false; |
|
1393 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1394 QCOMPARE( result, reference ); |
|
1395 |
|
1396 pattern = QString("1"); |
|
1397 reference = false; |
|
1398 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1399 QCOMPARE( result, reference ); |
|
1400 |
|
1401 pattern = QString("05"); |
|
1402 reference = true; |
|
1403 result = mCntSqlSearch->TestPattern(pattern, CntSqlSearch::ZeroIsFirstNumber); |
|
1404 QCOMPARE( result, reference ); |
|
1405 |
|
1406 TEST_PASSED_LOG("testTestPattern"); |
|
1407 } |
|
1408 |
|
1409 void UT_CntSqlSearch::testIsQwerty() |
|
1410 { |
|
1411 TEST_BEGIN_LOG("testTestIsQwerty"); |
|
1412 QString pattern = QString("s") + QChar(30) + QString("vqwerty"); |
|
1413 QVERIFY(mCntSqlSearch->isQwerty(pattern)); |
|
1414 pattern = QString(" ") + QChar(30) + QString("vqwerty"); |
|
1415 QVERIFY(mCntSqlSearch->isQwerty(pattern)); |
|
1416 pattern = QString("") + QChar(30) + QString("vqwerty"); |
|
1417 QVERIFY(mCntSqlSearch->isQwerty(pattern)); |
|
1418 pattern = QString("p a") + QChar(30) + QString("vqwerty"); |
|
1419 QVERIFY(mCntSqlSearch->isQwerty(pattern)); |
|
1420 pattern = QString("&") + QChar(30) + QString("vqwerty"); |
|
1421 QVERIFY(mCntSqlSearch->isQwerty(pattern)); |
|
1422 pattern = QString("6") + QChar(30) + QString("vqwerty"); |
|
1423 QVERIFY(mCntSqlSearch->isQwerty(pattern)); |
|
1424 pattern = QString("6") + QChar(30) + QString("vqwerty"); |
|
1425 QVERIFY(mCntSqlSearch->isQwerty(pattern)); |
|
1426 pattern = QString("vqwerty"); |
|
1427 QVERIFY(!mCntSqlSearch->isQwerty(pattern)); |
|
1428 pattern = QChar(30); |
|
1429 QVERIFY(!mCntSqlSearch->isQwerty(pattern)); |
|
1430 TEST_PASSED_LOG("testIsQwerty"); |
|
1431 } |
|
1432 void UT_CntSqlSearch::testQwertyTokens() |
|
1433 { |
|
1434 TEST_BEGIN_LOG("testQwertyTokens"); |
|
1435 QString pattern = QString("") + QChar(30) + QString("vqwerty"); |
|
1436 QStringList tokens = mCntSqlSearch->qwertyTokens(pattern); |
|
1437 QVERIFY(tokens.count() == 1); |
|
1438 QVERIFY(tokens.at(0) == ""); |
|
1439 |
|
1440 pattern = QString("a") + QChar(30) + QString("vqwerty"); |
|
1441 tokens = mCntSqlSearch->qwertyTokens(pattern); |
|
1442 QVERIFY(tokens.count() == 1); |
|
1443 QVERIFY(tokens.at(0) == "a"); |
|
1444 |
|
1445 pattern = QString("a a") + QChar(30) + QString("vqwerty"); |
|
1446 tokens = mCntSqlSearch->qwertyTokens(pattern); |
|
1447 QVERIFY(tokens.count() == 2); |
|
1448 QVERIFY(tokens.at(0) == "a"); |
|
1449 QVERIFY(tokens.at(1) == "a"); |
|
1450 |
|
1451 pattern = QString("abc") + QChar(30) + QString("vqwerty"); |
|
1452 tokens = mCntSqlSearch->qwertyTokens(pattern); |
|
1453 QVERIFY(tokens.count() == 1); |
|
1454 QVERIFY(tokens.at(0) == "abc"); |
|
1455 |
|
1456 pattern = QString("abc d") + QChar(30) + QString("vqwerty"); |
|
1457 tokens = mCntSqlSearch->qwertyTokens(pattern); |
|
1458 QVERIFY(tokens.count() == 2); |
|
1459 QVERIFY(tokens.at(0) == "abc"); |
|
1460 QVERIFY(tokens.at(1) == "d"); |
|
1461 |
|
1462 pattern = QString(" abc d") + QChar(30) + QString("vqwerty"); |
|
1463 tokens = mCntSqlSearch->qwertyTokens(pattern); |
|
1464 QVERIFY(tokens.count() == 2); |
|
1465 QVERIFY(tokens.at(0) == "abc"); |
|
1466 QVERIFY(tokens.at(1) == "d"); |
|
1467 |
|
1468 pattern = QString("abc d") + QChar(30) + QString("vqwerty"); |
|
1469 tokens = mCntSqlSearch->qwertyTokens(pattern); |
|
1470 QVERIFY(tokens.count() == 2); |
|
1471 QVERIFY(tokens.at(0) == "abc"); |
|
1472 QVERIFY(tokens.at(1) == "d"); |
|
1473 |
|
1474 pattern = QString(" 1234 5 ") + QChar(30) + QString("vqwerty"); |
|
1475 tokens = mCntSqlSearch->qwertyTokens(pattern); |
|
1476 QVERIFY(tokens.count() == 2); |
|
1477 //QVERIFY(tokens.at(0) == "1234"); |
|
1478 //QVERIFY(tokens.at(1) == "5"); |
|
1479 |
|
1480 TEST_PASSED_LOG("TestQwertyTokens"); |
|
1481 } |
|
1482 #if defined(WRITE_LOGS) |
|
1483 void WriteLog(const QString a, const QString b) |
|
1484 { |
|
1485 TPtrC16 ptr(reinterpret_cast<const TUint16*>(a.utf16())); |
|
1486 WritePart(ptr); |
|
1487 |
|
1488 if (b.size() > 0) |
|
1489 { |
|
1490 TPtrC16 ptr2(reinterpret_cast<const TUint16*>(b.utf16())); |
|
1491 WritePart(ptr2); |
|
1492 } |
|
1493 } |
|
1494 |
|
1495 void WritePart(const TDesC& s) |
|
1496 { |
|
1497 // RDebug::Print() only writes first 256 chars |
|
1498 const TInt KMaxLength = 255; |
|
1499 |
|
1500 TInt pos(0); |
|
1501 TInt len = s.Length(); |
|
1502 while (pos < len) |
|
1503 { |
|
1504 TInt partLength = KMaxLength; |
|
1505 if (pos + partLength > len) |
|
1506 { |
|
1507 partLength = len - pos; |
|
1508 } |
|
1509 TPtrC16 part = s.Mid(pos, partLength); |
|
1510 RDebug::Print(part); |
|
1511 pos += KMaxLength; |
|
1512 } |
|
1513 } |
|
1514 #endif // #if defined(WRITE_LOGS) |
|
1515 |
|
1516 |
|
1517 #ifdef SQL_QT_TEST |
|
1518 QTEST_APPLESS_MAIN(UT_CntSqlSearch) |
|
1519 #endif |
|
1520 |