searchengine/cpix/tsrc/cpixunittest/src/aggregatetests.cpp
changeset 24 65456528cac2
parent 3 ae3f1779f6da
equal deleted inserted replaced
23:d4d56f5e7c55 24:65456528cac2
   346     // Test operations
   346     // Test operations
   347     //
   347     //
   348     void testAddFiles(Itk::TestMgr * testMgr)
   348     void testAddFiles(Itk::TestMgr * testMgr)
   349     {
   349     {
   350         testMgr_ = testMgr;
   350         testMgr_ = testMgr;
   351         char *xml_file = (char*)__FUNCTION__;
       
   352         assert_failed = 0;
       
   353         Cpt::traverse(FILE_TEST_CORPUS_PATH "\\en",
   351         Cpt::traverse(FILE_TEST_CORPUS_PATH "\\en",
   354                       this);
   352                       this);
   355 
   353 
   356         util_->flush();
   354         util_->flush();
   357         testResultXml(xml_file);
   355        
   358     }
   356     }
   359 
   357 
   360 
   358 
   361     void testSearchForHappy(Itk::TestMgr * testMgr)
   359     void testSearchForHappy(Itk::TestMgr * testMgr)
   362     {
   360     {
   363         const wchar_t
   361         const wchar_t
   364             * word = L"happy";
   362             * word = L"happy";
   365             char *xml_file = (char*)__FUNCTION__;
       
   366             assert_failed = 0;
       
   367         testSearchFor(testMgr,
   363         testSearchFor(testMgr,
   368                       word);
   364                       word);
   369         testResultXml(xml_file);
   365        
   370         
   366         
   371     }
   367     }
   372 
   368 
   373     void testSearchForImportant(Itk::TestMgr * testMgr)
   369     void testSearchForImportant(Itk::TestMgr * testMgr)
   374     {
   370     {
   375         const wchar_t
   371         const wchar_t
   376             * word = L"important";
   372             * word = L"important";
   377         char *xml_file = (char*)__FUNCTION__;
       
   378         assert_failed = 0;
       
   379         testSearchFor(testMgr,
   373         testSearchFor(testMgr,
   380                       word);
   374                       word);
   381         testResultXml(xml_file);
   375        
   382     }
   376     }
   383 
   377 
   384     void testSearchForHappening(Itk::TestMgr * testMgr)
   378     void testSearchForHappening(Itk::TestMgr * testMgr)
   385     {
   379     {
   386         const wchar_t
   380         const wchar_t
   387             * word = L"happening";
   381             * word = L"happening";
   388         char *xml_file = (char*)__FUNCTION__;
       
   389         assert_failed = 0;
       
   390         testSearchFor(testMgr,
   382         testSearchFor(testMgr,
   391                       word);
   383                       word);
   392         testResultXml(xml_file);
   384        
   393     }
   385     }
   394 
   386 
   395     void testSearchForLook(Itk::TestMgr * testMgr)
   387     void testSearchForLook(Itk::TestMgr * testMgr)
   396     {
   388     {
   397         const wchar_t
   389         const wchar_t
   398             * word = L"look";
   390             * word = L"look";
   399         char *xml_file = (char*)__FUNCTION__;
       
   400         assert_failed = 0;
       
   401         testSearchFor(testMgr,
   391         testSearchFor(testMgr,
   402                       word);
   392                       word);
   403         testResultXml(xml_file);
   393        
   404     }
   394     }
   405 
   395 
   406     void testSearchForChristmas(Itk::TestMgr * testMgr)
   396     void testSearchForChristmas(Itk::TestMgr * testMgr)
   407     {
   397     {
   408         const wchar_t
   398         const wchar_t
   409             * word = L"christmas";
   399             * word = L"christmas";
   410         char *xml_file = (char*)__FUNCTION__;
       
   411         assert_failed = 0;
       
   412         testSearchFor(testMgr,
   400         testSearchFor(testMgr,
   413                       word);
   401                       word);
   414         testResultXml(xml_file);
   402        
   415     }
   403     }
   416 
   404 
   417 
   405 
   418 private:
   406 private:
   419     //
   407     //
   443                 else
   431                 else
   444                     {
   432                     {
   445                         cpix_Error_report(util_->idxDb()->err_,
   433                         cpix_Error_report(util_->idxDb()->err_,
   446                                           report,
   434                                           report,
   447                                           sizeof(report)/sizeof(wchar_t));
   435                                           sizeof(report)/sizeof(wchar_t));
   448                         if(expected)
   436  
   449                             assert_failed = 1;
       
   450                         else
       
   451                             assert_failed = 0;  
       
   452                         ITK_EXPECT(testMgr,
   437                         ITK_EXPECT(testMgr,
   453                                    false,
   438                                    false,
   454                                    "Failed to search: %S",
   439                                    "Failed to search: %S",
   455                                    report);
   440                                    report);
   456                         cpix_ClearError(util_->idxDb());
   441                         cpix_ClearError(util_->idxDb());
   461         else
   446         else
   462             {
   447             {
   463                 cpix_Error_report(query->err_,
   448                 cpix_Error_report(query->err_,
   464                                   report,
   449                                   report,
   465                                   sizeof(report)/sizeof(wchar_t));
   450                                   sizeof(report)/sizeof(wchar_t));
   466                 if(expected)
   451 
   467                     assert_failed = 1;
       
   468                 else
       
   469                     assert_failed = 0;  
       
   470                 ITK_EXPECT(testMgr,
   452                 ITK_EXPECT(testMgr,
   471                            false,
   453                            false,
   472                            "Failed to parse '%S': %S",
   454                            "Failed to parse '%S': %S",
   473                            word,
   455                            word,
   474                            report);
   456                            report);