searchengine/cpix/tsrc/cpixunittest/src/en_stemtests.cpp
changeset 24 65456528cac2
parent 3 ae3f1779f6da
equal deleted inserted replaced
23:d4d56f5e7c55 24:65456528cac2
   190                                                      fieldValues[i]);
   190                                                      fieldValues[i]);
   191                 if (cpix_Failed(util_->idxDb()))
   191                 if (cpix_Failed(util_->idxDb()))
   192                     {
   192                     {
   193                         printf("Failed to delete\n");
   193                         printf("Failed to delete\n");
   194                         cpix_ClearError(util_->idxDb());
   194                         cpix_ClearError(util_->idxDb());
   195                         assert_failed = 1;
   195                                 break;
   196                         break;
       
   197                     }
   196                     }
   198                 else
   197                 else
   199                     {
   198                     {
   200                         std::string
   199                         std::string
   201                             docUid(docUids[i]);
   200                             docUid(docUids[i]);
   211                    "Only %d docs instead of %d have been deleted",
   210                    "Only %d docs instead of %d have been deleted",
   212                    result,
   211                    result,
   213                    expectedDelCount);
   212                    expectedDelCount);
   214         if(result != expectedDelCount)
   213         if(result != expectedDelCount)
   215             {
   214             {
   216                 assert_failed = 1;
   215                 
   217             }
   216             }
   218 
   217 
   219         for (size_t i = 0; i < count; ++i)
   218         for (size_t i = 0; i < count; ++i)
   220             {
   219             {
   221                 delete[] fieldValues[i];
   220                 delete[] fieldValues[i];
   275     // public operations
   274     // public operations
   276     //
   275     //
   277 
   276 
   278     void testAddFiles(Itk::TestMgr * testMgr)
   277     void testAddFiles(Itk::TestMgr * testMgr)
   279     {
   278     {
   280         char *xml_file = (char *)__FUNCTION__;
       
   281         assert_failed = 0;
       
   282         testMgr_ = testMgr;
   279         testMgr_ = testMgr;
   283         Cpt::traverse(FILE_TEST_CORPUS_PATH "\\en",
   280         Cpt::traverse(FILE_TEST_CORPUS_PATH "\\en",
   284                       this);
   281                       this);
   285         util_->flush();
   282         util_->flush();
   286         testResultXml(xml_file);
       
   287     }
       
   288 
       
   289 
       
   290     
       
   291     void testSearchFiles(Itk::TestMgr * testMgr)
   283     void testSearchFiles(Itk::TestMgr * testMgr)
   292     {
   284     {
   293         using namespace Itk;
   285         using namespace Itk;
   294         char *xml_file = (char *)__FUNCTION__;
       
   295         assert_failed = 0;
       
   296         cpix_Hits
   286         cpix_Hits
   297             * hits = cpix_IdxDb_search(util_->idxDb(),
   287             * hits = cpix_IdxDb_search(util_->idxDb(),
   298                                        query_);
   288                                        query_);
   299         
   289         
   300         if (cpix_Failed(util_->idxDb()))
   290         if (cpix_Failed(util_->idxDb()))
   301             {
   291             {
   302                 ITK_EXPECT(testMgr,
   292                 ITK_EXPECT(testMgr,
   303                            false,
   293                            false,
   304                            "Failed to search index");
   294                            "Failed to search index");
   305                 cpix_ClearError(util_->idxDb());
   295                 cpix_ClearError(util_->idxDb());
   306                 assert_failed = 1;
   296                 
   307             }
   297             }
   308         else
   298         else
   309             {
   299             {
   310                 util_->printHits(hits,
   300                 util_->printHits(hits,
   311                                  testMgr);
   301                                  testMgr);
   312 
   302 
   313                 cpix_Hits_destroy(hits);
   303                 cpix_Hits_destroy(hits);
   314             }
   304             }
   315         testResultXml(xml_file);
   305        
   316 
   306 
   317     }
   307     }
   318 
   308 
   319 
   309 
   320     void testDeleteFiles(Itk::TestMgr * testMgr)
   310     void testDeleteFiles(Itk::TestMgr * testMgr)
   321     {
   311     {
   322         char *xml_file = (char *)__FUNCTION__;
       
   323         assert_failed = 0;
       
   324         deleteFiles(testMgr,
   312         deleteFiles(testMgr,
   325                     EnglishDocsToDelete,
   313                     EnglishDocsToDelete,
   326                     sizeof(EnglishDocsToDelete)/sizeof(wchar_t*),
   314                     sizeof(EnglishDocsToDelete)/sizeof(wchar_t*),
   327                     2);
   315                     2);
   328         util_->flush();
   316         util_->flush();
   329         testResultXml(xml_file);
   317        
   330     }
   318     }
   331 
   319 
   332 
   320 
   333 };
   321 };
   334 
   322