searchengine/cpix/tsrc/cpixunittest/src/mapstests.cpp
changeset 3 ae3f1779f6da
parent 0 671dee74050a
child 24 65456528cac2
equal deleted inserted replaced
2:6c1a2771f4b7 3:ae3f1779f6da
    30 
    30 
    31 #include "config.h"
    31 #include "config.h"
    32 #include "testutils.h"
    32 #include "testutils.h"
    33 #include "setupsentry.h"
    33 #include "setupsentry.h"
    34 
    34 
       
    35 #include "std_log_result.h"
    35 
    36 
    36 const Volume Volumes[] = {
    37 const Volume Volumes[] = {
    37     { "@fin:root maps city",
    38     { "@fin:root maps city",
    38       MAPS_TEST_CORPUS_PATH "\\root\\maps\\city\\fin"
    39       MAPS_TEST_CORPUS_PATH "\\root\\maps\\city\\fin"
    39     },
    40     },
   209     }
   210     }
   210 
   211 
   211 
   212 
   212     void testLoadMaps(Itk::TestMgr * testMgr)
   213     void testLoadMaps(Itk::TestMgr * testMgr)
   213     {
   214     {
       
   215         char *xml_file = (char *)__FUNCTION__;
       
   216         assert_failed = 0;
   214         cpix_Result
   217         cpix_Result
   215             result;
   218             result;
   216 
   219 
   217         cpix_IdxDb_dbgScrapAll(&result);
   220         cpix_IdxDb_dbgScrapAll(&result);
   218 
   221 
   219         ITK_ASSERT(testMgr,
   222         ITK_ASSERT(testMgr,
   220                    cpix_Succeeded(&result),
   223                    cpix_Succeeded(&result),
   221                    "Could not reset qbac-path registry");
   224                    "Could not reset qbac-path registry");
       
   225         if(!cpix_Succeeded(&result))
       
   226             {
       
   227         assert_failed = 1;    
       
   228             }
   222 
   229 
   223         const Volume
   230         const Volume
   224             *p = Volumes;
   231             *p = Volumes;
   225 
   232 
   226         for (; p->qbac_ != NULL; ++p)
   233         for (; p->qbac_ != NULL; ++p)
   231 
   238 
   232                 ITK_ASSERT(testMgr,
   239                 ITK_ASSERT(testMgr,
   233                            cpix_Succeeded(&result),
   240                            cpix_Succeeded(&result),
   234                            "Could not define volume '%s'",
   241                            "Could not define volume '%s'",
   235                            p->qbac_);
   242                            p->qbac_);
       
   243                 if(!cpix_Succeeded(&result))
       
   244                     {
       
   245                     assert_failed = 1;    
       
   246                     }
   236             }
   247             }
   237 
   248 
   238         idxSearcher_ = cpix_IdxSearcher_openDb(&result,
   249         idxSearcher_ = cpix_IdxSearcher_openDb(&result,
   239                                                "root maps");
   250                                                "root maps");
   240 
   251 
   241         ITK_ASSERT(testMgr,
   252         ITK_ASSERT(testMgr,
   242                    cpix_Succeeded(&result),
   253                    cpix_Succeeded(&result),
   243                    "Could not create searcher for 'root maps'");
   254                    "Could not create searcher for 'root maps'");
       
   255         if(!cpix_Succeeded(&result))
       
   256             {
       
   257             assert_failed = 1;    
       
   258             }
       
   259         testResultXml(xml_file);
   244     }
   260     }
   245 
   261 
   246 
   262 
   247     void testSearchMaps(Itk::TestMgr * testMgr)
   263     void testSearchMaps(Itk::TestMgr * testMgr)
   248     {
   264     {
   249         printf("Testing searching maps index\n");
   265         printf("Testing searching maps index\n");
   250 
   266         char *xml_file = (char *)__FUNCTION__;
       
   267         assert_failed = 0;
   251         const wchar_t
   268         const wchar_t
   252             ** p = MapsSearchTerms;
   269             ** p = MapsSearchTerms;
   253         for (; *p != NULL; ++p)
   270         for (; *p != NULL; ++p)
   254             {
   271             {
   255                 printf("\n\nSearching for '%S':\n",
   272                 printf("\n\nSearching for '%S':\n",
   288                 else
   305                 else
   289                     {
   306                     {
   290                         ITK_EXPECT(testMgr,
   307                         ITK_EXPECT(testMgr,
   291                                    false,
   308                                    false,
   292                                    "Failed to do address search");
   309                                    "Failed to do address search");
       
   310                         assert_failed = 1;
   293                     }
   311                     }
   294 
   312 
   295                 cpix_Query_destroy(query);
   313                 cpix_Query_destroy(query);
   296             }
   314             }
       
   315         testResultXml(xml_file);
   297     }
   316     }
   298 
   317 
   299 
   318 
   300 private:
   319 private:
   301     void cleanup()
   320     void cleanup()