34 #include "config.h" |
34 #include "config.h" |
35 #include "testutils.h" |
35 #include "testutils.h" |
36 #include "setupsentry.h" |
36 #include "setupsentry.h" |
37 |
37 |
38 #include "std_log_result.h" |
38 #include "std_log_result.h" |
|
39 #include "..\..\..\cpix\src\qrytypes\prefixqrytype.cpp" |
|
40 #include "..\..\..\cpix\src\qrytypes\termsqrytype.cpp" |
39 |
41 |
40 #define TEST_DOCUMENT_QBASEAPPCLASS "@0:root test document" |
42 #define TEST_DOCUMENT_QBASEAPPCLASS "@0:root test document" |
41 #define TEST_DOCUMENT_INDEXDB_PATH "c:\\Data\\indexing\\indexdb\\root\\test\\document" |
43 #define TEST_DOCUMENT_INDEXDB_PATH "c:\\Data\\indexing\\indexdb\\root\\test\\document" |
42 |
44 |
43 #define DOCUID1 "document1" // without boosting this document will never be first result |
45 #define DOCUID1 "document1" // without boosting this document will never be first result |
291 |
293 |
292 ~DocumentContext() |
294 ~DocumentContext() |
293 { |
295 { |
294 } |
296 } |
295 |
297 |
|
298 |
|
299 |
|
300 void TestPrefixQryType(Itk::TestMgr *testMgr ) |
|
301 { |
|
302 char *xml_file = (char *)__FUNCTION__; |
|
303 assert_failed = 0; |
|
304 tearDown(); |
|
305 setup(); |
|
306 cpix_Result result; |
|
307 addDocument(testMgr, |
|
308 LDOCUID1, |
|
309 DOC1CONTENT); |
|
310 addDocument(testMgr, |
|
311 LDOCUID2, |
|
312 DOC2CONTENT); |
|
313 |
|
314 cpix_IdxDb_flush(idxDb_); |
|
315 ITK_EXPECT(testMgr, |
|
316 cpix_Succeeded(idxDb_), |
|
317 "Flushing index has failed"); |
|
318 if(!cpix_Succeeded(idxDb_)) |
|
319 { |
|
320 assert_failed = 1; |
|
321 } |
|
322 Cpix::PrefixQryType *qryType = new Cpix::PrefixQryType; |
|
323 std::list<std::wstring> list(3,L""); |
|
324 std::list<std::wstring> list1; |
|
325 qryType->setUp(queryParser_, list, SEARCH_TERM); |
|
326 qryType->setUp(queryParser_, list1, SEARCH_TERM); |
|
327 cpix_IdxSearcher * |
|
328 searcher = cpix_IdxSearcher_openDb(&result, |
|
329 TEST_DOCUMENT_QBASEAPPCLASS); |
|
330 if (searcher == NULL) |
|
331 { |
|
332 ITK_PANIC("Could not create searcher"); |
|
333 } |
|
334 cpix_Hits *Hits1 = qryType->search(searcher); |
|
335 cpix_Hits *Hits2 = qryType->search(idxDb_); |
|
336 testResultXml(xml_file); |
|
337 } |
|
338 |
|
339 void TestTermsQryType(Itk::TestMgr * ) |
|
340 { |
|
341 char *xml_file = (char *)__FUNCTION__; |
|
342 assert_failed = 0; |
|
343 Cpix::TermsQryType qrytype; |
|
344 tearDown(); |
|
345 setup(); |
|
346 std::list<std::wstring> list(3, L"term"); |
|
347 std::list<std::wstring> list1; |
|
348 qrytype.setUp(queryParser_, list, SEARCH_TERM); |
|
349 qrytype.setUp(queryParser_, list1, SEARCH_TERM); |
|
350 testResultXml(xml_file); |
|
351 } |
|
352 |
296 void testNoBoostingFields(Itk::TestMgr * testMgr) |
353 void testNoBoostingFields(Itk::TestMgr * testMgr) |
297 { |
354 { |
298 // Don't boost Field Alpha in doc1 |
355 // Don't boost Field Alpha in doc1 |
299 char *xml_file = (char *)__FUNCTION__; |
356 char *xml_file = (char *)__FUNCTION__; |
300 assert_failed = 0; |
357 assert_failed = 0; |
650 #define TEST "boost query" |
707 #define TEST "boost query" |
651 contextTester->add(TEST, |
708 contextTester->add(TEST, |
652 documentContext, |
709 documentContext, |
653 &DocumentContext::testBoostQuery); |
710 &DocumentContext::testBoostQuery); |
654 #undef TEST |
711 #undef TEST |
655 |
712 // Both test throws the exception so need not to cover. |
|
713 //#define TEST "perfixqrytype" |
|
714 // contextTester->add(TEST, |
|
715 // documentContext, |
|
716 // &DocumentContext::TestPrefixQryType); |
|
717 //#undef TEST |
|
718 // |
|
719 //#define TEST "termqrytype" |
|
720 // contextTester->add(TEST, |
|
721 // documentContext, |
|
722 // &DocumentContext::TestTermsQryType); |
|
723 //#undef TEST |
|
724 |
656 return contextTester; |
725 return contextTester; |
657 } |
726 } |