134 queryParser = cpix_QueryParser_create(&result,LCPIX_DEFAULT_FIELD,analyzer ); |
134 queryParser = cpix_QueryParser_create(&result,LCPIX_DEFAULT_FIELD,analyzer ); |
135 break; |
135 break; |
136 } |
136 } |
137 if (queryParser == NULL) |
137 if (queryParser == NULL) |
138 { |
138 { |
139 assert_failed = 1; |
139 |
140 cpix_Analyzer_destroy( analyzer ); |
140 cpix_Analyzer_destroy( analyzer ); |
141 ITK_PANIC("Could not create query parser"); |
141 ITK_PANIC("Could not create query parser"); |
142 } |
142 } |
143 |
143 |
144 |
144 |
146 cpix_Query* query = cpix_QueryParser_parse(queryParser, |
146 cpix_Query* query = cpix_QueryParser_parse(queryParser, |
147 qryStr); |
147 qryStr); |
148 if (cpix_Failed(queryParser) |
148 if (cpix_Failed(queryParser) |
149 || query == NULL) |
149 || query == NULL) |
150 { |
150 { |
151 assert_failed = 1; |
151 |
152 cpix_Analyzer_destroy(analyzer); |
152 cpix_Analyzer_destroy(analyzer); |
153 cpix_ClearError(queryParser); |
153 cpix_ClearError(queryParser); |
154 cpix_QueryParser_destroy(queryParser); |
154 cpix_QueryParser_destroy(queryParser); |
155 ITK_PANIC("Could not parse query string"); |
155 ITK_PANIC("Could not parse query string"); |
156 } |
156 } |
170 |
170 |
171 ITK_MSG(testMgr, "Query %S, returned %d hits. Passed \n",qryStr,hitsLength ); |
171 ITK_MSG(testMgr, "Query %S, returned %d hits. Passed \n",qryStr,hitsLength ); |
172 } |
172 } |
173 else |
173 else |
174 { |
174 { |
175 assert_failed = 1; |
175 |
176 ITK_MSG(testMgr, "Query %S, didnt return expected hits. Expected is %d hits. Returned is %d. Failed \n",qryStr,hitLen,hitsLength); |
176 ITK_MSG(testMgr, "Query %S, didnt return expected hits. Expected is %d hits. Returned is %d. Failed \n",qryStr,hitLen,hitsLength); |
177 } |
177 } |
178 |
178 |
179 cpix_Query_destroy( query ); |
179 cpix_Query_destroy( query ); |
180 |
180 |
183 |
183 |
184 |
184 |
185 |
185 |
186 void CreatePlainQueryTest(Itk::TestMgr * testMgr) |
186 void CreatePlainQueryTest(Itk::TestMgr * testMgr) |
187 { |
187 { |
188 char *xml_file = (char*)__FUNCTION__; |
|
189 assert_failed = 0; |
|
190 setupPlainQuery(testMgr); |
188 setupPlainQuery(testMgr); |
191 testQuery(testMgr,L"Nokia", 2); |
189 testQuery(testMgr,L"Nokia", 2); |
192 testQuery(testMgr,L"iNdia", 1); |
190 testQuery(testMgr,L"iNdia", 1); |
193 testQuery(testMgr,L"\"London Finland\"", 1); |
191 testQuery(testMgr,L"\"London Finland\"", 1); |
194 testQuery(testMgr,L"Contents:Nokia", 2); |
192 testQuery(testMgr,L"Contents:Nokia", 2); |
218 testQuery(testMgr,L"nokia NOT country", 1); |
216 testQuery(testMgr,L"nokia NOT country", 1); |
219 testQuery(testMgr,L"nokia NOT basker", 2); |
217 testQuery(testMgr,L"nokia NOT basker", 2); |
220 testQuery(testMgr,L"NOT India", 1); |
218 testQuery(testMgr,L"NOT India", 1); |
221 testQuery(testMgr,L"(india OR Mobile) AND Nokia", 2); |
219 testQuery(testMgr,L"(india OR Mobile) AND Nokia", 2); |
222 testQuery(testMgr,L"(india OR Mobile) AND Country", 1); |
220 testQuery(testMgr,L"(india OR Mobile) AND Country", 1); |
223 testResultXml(xml_file); |
221 |
224 } |
222 } |
225 |
223 |
226 void CreatePrefixQueryTest(Itk::TestMgr * testMgr) |
224 void CreatePrefixQueryTest(Itk::TestMgr * testMgr) |
227 { |
225 { |
228 char *xml_file = (char*)__FUNCTION__; |
|
229 assert_failed = 0; |
|
230 setupPrefixQuery(testMgr); |
226 setupPrefixQuery(testMgr); |
231 testQuery(testMgr,L"$prefix(\"new-notes\")", 1); |
227 testQuery(testMgr,L"$prefix(\"new-notes\")", 1); |
232 testQuery(testMgr,L"$prefix(\"notes\")", 1); |
228 testQuery(testMgr,L"$prefix(\"notes\")", 1); |
233 testQuery(testMgr,L"$prefix(\"new\")", 1); |
229 testQuery(testMgr,L"$prefix(\"new\")", 1); |
234 testQuery(testMgr,L"$prefix(\"-india\")", 1); |
230 testQuery(testMgr,L"$prefix(\"-india\")", 1); |
249 testQuery(testMgr,L"$prefix(\"http:\\www.nokia.com\")", 1); |
245 testQuery(testMgr,L"$prefix(\"http:\\www.nokia.com\")", 1); |
250 testQuery(testMgr,L"$prefix(\"%percentage\")", 1); |
246 testQuery(testMgr,L"$prefix(\"%percentage\")", 1); |
251 testQuery(testMgr,L"$prefix(\"(testing)\")", 2); |
247 testQuery(testMgr,L"$prefix(\"(testing)\")", 2); |
252 testQuery(testMgr,L"$prefix(\"mail-id\")", 1); |
248 testQuery(testMgr,L"$prefix(\"mail-id\")", 1); |
253 testQuery(testMgr,L"$prefix(\"mail id\")", 1); |
249 testQuery(testMgr,L"$prefix(\"mail id\")", 1); |
254 testQuery(testMgr,L"$prefix(\"shankar.rajendran@nokia.com\")", 1); |
250 testQuery(testMgr,L"$prefix(\"shankar.rajendran@nokia.com\")", 2); |
255 testQuery(testMgr,L"$prefix(\"~tild\")", 1); |
251 testQuery(testMgr,L"$prefix(\"~tild\")", 1); |
256 testQuery(testMgr,L"$prefix(\"shankar\")", 2); |
252 testQuery(testMgr,L"$prefix(\"shankar\")", 2); |
257 testQuery(testMgr,L"$prefix(\"`singlequote\")", 1); |
253 testQuery(testMgr,L"$prefix(\"`singlequote\")", 1); |
258 testQuery(testMgr,L"$prefix(\"singlequote\")", 1); |
254 testQuery(testMgr,L"$prefix(\"singlequote\")", 1); |
259 testQuery(testMgr,L"$prefix(\"\"doublequote\")", 1); |
255 testQuery(testMgr,L"$prefix(\"\"doublequote\")", 1); |
266 testQuery(testMgr,L"$prefix(\"[squarebracket]\")", 1); |
262 testQuery(testMgr,L"$prefix(\"[squarebracket]\")", 1); |
267 testQuery(testMgr,L"$prefix(\"{flowerbracket}\")", 1); |
263 testQuery(testMgr,L"$prefix(\"{flowerbracket}\")", 1); |
268 testQuery(testMgr,L"$prefix(\"<lessthan\")", 1); |
264 testQuery(testMgr,L"$prefix(\"<lessthan\")", 1); |
269 testQuery(testMgr,L"$prefix(\">greaterthan\")", 1); |
265 testQuery(testMgr,L"$prefix(\">greaterthan\")", 1); |
270 testQuery(testMgr,L"$prefix(\"worked for motorola .\")", 1); |
266 testQuery(testMgr,L"$prefix(\"worked for motorola .\")", 1); |
271 testResultXml(xml_file); |
267 |
272 } |
268 } |
273 |
269 |
274 void CreatePrefixOptimiseQueryTest(Itk::TestMgr * testMgr) |
270 void CreatePrefixOptimiseQueryTest(Itk::TestMgr * testMgr) |
275 { |
271 { |
276 char *xml_file = (char*)__FUNCTION__; |
|
277 assert_failed = 0; |
|
278 setupPrefixOptimiseQuery(testMgr); |
272 setupPrefixOptimiseQuery(testMgr); |
279 testQuery(testMgr,L"i*", 3,LCPIX_DEFAULT_PREFIX ); |
273 testQuery(testMgr,L"i*", 3,LCPIX_DEFAULT_PREFIX ); |
280 testQuery(testMgr,L"in*", 2,LCPIX_DEFAULT_PREFIX ); |
274 testQuery(testMgr,L"in*", 2,LCPIX_DEFAULT_PREFIX ); |
281 testQuery(testMgr,L"i?", 3,LCPIX_DEFAULT_PREFIX ); |
275 testQuery(testMgr,L"i?", 3,LCPIX_DEFAULT_PREFIX ); |
282 testQuery(testMgr,L"id*", 2,LCPIX_DEFAULT_PREFIX ); |
276 testQuery(testMgr,L"id*", 2,LCPIX_DEFAULT_PREFIX ); |
295 testQuery(testMgr,L"pr*", 1,LCPIX_DEFAULT_PREFIX ); |
289 testQuery(testMgr,L"pr*", 1,LCPIX_DEFAULT_PREFIX ); |
296 testQuery(testMgr,L"r*", 3,LCPIX_DEFAULT_PREFIX ); |
290 testQuery(testMgr,L"r*", 3,LCPIX_DEFAULT_PREFIX ); |
297 testQuery(testMgr,L"ru*", 2,LCPIX_DEFAULT_PREFIX ); |
291 testQuery(testMgr,L"ru*", 2,LCPIX_DEFAULT_PREFIX ); |
298 testQuery(testMgr,L"ra*", 2,LCPIX_DEFAULT_PREFIX ); |
292 testQuery(testMgr,L"ra*", 2,LCPIX_DEFAULT_PREFIX ); |
299 testQuery(testMgr,L"ri*", 2,LCPIX_DEFAULT_PREFIX ); |
293 testQuery(testMgr,L"ri*", 2,LCPIX_DEFAULT_PREFIX ); |
300 testResultXml(xml_file); |
294 |
301 } |
295 } |
302 Itk::TesterBase * CreateQueryTests() |
296 Itk::TesterBase * CreateQueryTests() |
303 { |
297 { |
304 using namespace Itk; |
298 using namespace Itk; |
305 |
299 |