454 if ( indexed( item ) ) |
455 if ( indexed( item ) ) |
455 { |
456 { |
456 bool found = false; |
457 bool found = false; |
457 for ( int i = 0; i < cpix_Hits_length( hits ); i++ ) |
458 for ( int i = 0; i < cpix_Hits_length( hits ); i++ ) |
458 { |
459 { |
459 cpix_Document doc; |
460 cpix_Document **doc; |
460 cpix_Hits_doc( hits, i, &doc ); |
461 ALLOC_DOC (doc, 1); |
461 |
462 cpix_Hits_doc( hits, i, doc, 1 ); |
462 const wchar_t* id = cpix_Document_getFieldValue( &doc, LCPIX_DOCUID_FIELD ); |
463 if (doc[0]->ptr_ != NULL) { |
|
464 const wchar_t* id = cpix_Document_getFieldValue( doc[0], LCPIX_DOCUID_FIELD ); |
463 |
465 |
464 if ( id ) |
466 if ( id ) |
465 { |
467 { |
466 wstring str( id ); |
468 wstring str( id ); |
467 if ( GetItemIndex( str.c_str() ) == item ) |
469 if ( GetItemIndex( str.c_str() ) == item ) |
468 { |
470 { |
469 found = true; |
471 found = true; |
470 break; |
472 break; |
471 } |
473 } |
472 } |
474 } |
|
475 } |
|
476 FREE_DOC(doc, 1); |
473 } |
477 } |
474 if ( !found ) |
478 if ( !found ) |
475 { |
479 { |
476 assert_failed = 1; |
480 assert_failed = 1; |
477 ITK_MSG( testMgr, "Failed content %d", item ); |
481 ITK_MSG( testMgr, "Failed content %d", item ); |
536 cpix_IdxDb_search(idxUtil_->idxDb(), |
540 cpix_IdxDb_search(idxUtil_->idxDb(), |
537 query); |
541 query); |
538 |
542 |
539 if ( hits ) |
543 if ( hits ) |
540 { |
544 { |
541 for ( int i = 0; i < cpix_Hits_length( hits ); i++ ) |
545 for ( int i = 0; i < cpix_Hits_length( hits ); i++ ) { |
542 { |
546 |
543 cpix_Document doc; |
547 cpix_Document **doc; |
544 cpix_Hits_doc( hits, i, &doc ); |
548 ALLOC_DOC(doc, 1); |
545 |
549 cpix_Hits_doc( hits, i, doc, 1 ); |
546 const wchar_t* id = cpix_Document_getFieldValue( &doc, LCPIX_DOCUID_FIELD ); |
550 |
547 |
551 if (doc[0]->ptr_ != NULL) { |
548 if ( id ) |
552 |
549 { |
553 const wchar_t* id = cpix_Document_getFieldValue(doc[0], |
550 wstring str( id ); |
554 LCPIX_DOCUID_FIELD); |
551 size_t index = GetItemIndex( str.c_str() ); |
555 |
552 wstring content( testCorpus_.item( index ) ); |
556 if (id) |
553 |
557 { |
554 // TODO expect instead of |
558 wstring str(id); |
555 // assert otherwise cpix_Hits |
559 size_t index = GetItemIndex(str.c_str()); |
556 // instance leaks |
560 wstring content(testCorpus_.item(index)); |
557 ITK_ASSERT( testMgr, |
561 |
558 containsTerm( content, term ), |
562 // TODO expect instead of |
559 "False positive? Term %S not found in %S", term.c_str(), content.c_str() ); |
563 // assert otherwise cpix_Hits |
560 matches++; |
564 // instance leaks |
561 } |
565 ITK_ASSERT( testMgr, |
|
566 containsTerm( content, term ), |
|
567 "False positive? Term %S not found in %S", term.c_str(), content.c_str() ); |
|
568 matches++; |
|
569 } |
|
570 } |
|
571 FREE_DOC(doc, 1); |
562 } |
572 } |
563 cpix_Hits_destroy( hits ); |
573 cpix_Hits_destroy( hits ); |
564 } |
574 } |
565 cpix_Query_destroy( query ); |
575 cpix_Query_destroy( query ); |
566 } |
576 } |