searchengine/cpix/tsrc/cpixunittest/src/deletiontests.cpp
changeset 3 ae3f1779f6da
parent 0 671dee74050a
child 24 65456528cac2
equal deleted inserted replaced
2:6c1a2771f4b7 3:ae3f1779f6da
    31 #include "suggestion.h"
    31 #include "suggestion.h"
    32 #include "testutils.h"
    32 #include "testutils.h"
    33 #include "testcorpus.h"
    33 #include "testcorpus.h"
    34 #include "setupsentry.h"
    34 #include "setupsentry.h"
    35 
    35 
    36 
    36 #include "std_log_result.h"
    37 class DeletionContext : public Itk::ITestContext
    37 class DeletionContext : public Itk::ITestContext
    38 {
    38 {
    39 private:
    39 private:
    40     SmsIdxUtil         * util_;
    40     SmsIdxUtil         * util_;
    41     cpix_Analyzer      * analyzer_;
    41     cpix_Analyzer      * analyzer_;
   117     //
   117     //
   118     // Test Member Function
   118     // Test Member Function
   119     //
   119     //
   120     void testAdd_00(Itk::TestMgr * testMgr)
   120     void testAdd_00(Itk::TestMgr * testMgr)
   121     {
   121     {
       
   122         char *xml_file = (char *)__FUNCTION__;
       
   123         assert_failed = 0;
   122         testAddSms(testMgr,
   124         testAddSms(testMgr,
   123                    1,
   125                    1,
   124                    L"This is a happy message");
   126                    L"This is a happy message");
   125         util_->flush();
   127         util_->flush();
   126         testSearch(testMgr);
   128         testSearch(testMgr);
       
   129         testResultXml(xml_file);
   127     }
   130     }
   128 
   131 
   129     void testAdd_01(Itk::TestMgr * testMgr)
   132     void testAdd_01(Itk::TestMgr * testMgr)
   130     {
   133     {
       
   134         char *xml_file = (char *)__FUNCTION__;
       
   135         assert_failed = 0;
   131         testAddSms(testMgr,
   136         testAddSms(testMgr,
   132                    2,
   137                    2,
   133                    L"This is another happy message");
   138                    L"This is another happy message");
   134         util_->flush();
   139         util_->flush();
   135         testSearch(testMgr);
   140         testSearch(testMgr);
       
   141         testResultXml(xml_file);
   136     }
   142     }
   137 
   143 
   138     void testFlush_02(Itk::TestMgr * testMgr)
   144     void testFlush_02(Itk::TestMgr * testMgr)
   139     {
   145     {
       
   146         char *xml_file = (char *)__FUNCTION__;
       
   147         assert_failed = 0;
   140         testFlush(testMgr);
   148         testFlush(testMgr);
       
   149         testResultXml(xml_file);
   141     }
   150     }
   142 
   151 
   143     void testAdd_03(Itk::TestMgr * testMgr)
   152     void testAdd_03(Itk::TestMgr * testMgr)
   144     {
   153     {
       
   154         char *xml_file = (char *)__FUNCTION__;
       
   155         assert_failed = 0;
   145         testAddSms(testMgr,
   156         testAddSms(testMgr,
   146                    3,
   157                    3,
   147                    L"This is a 3rd happy message");
   158                    L"This is a 3rd happy message");
   148         util_->flush();
   159         util_->flush();
   149         testSearch(testMgr);
   160         testSearch(testMgr);
       
   161         testResultXml(xml_file);
   150     }
   162     }
   151 
   163 
   152     void testDelete_04(Itk::TestMgr * testMgr)
   164     void testDelete_04(Itk::TestMgr * testMgr)
   153     {
   165     {
       
   166         char *xml_file = (char *)__FUNCTION__;
       
   167         assert_failed = 0;
   154         testDeleteSms(3,
   168         testDeleteSms(3,
   155                       testMgr);
   169                       testMgr);
   156         util_->flush();
   170         util_->flush();
   157         testSearch(testMgr);
   171         testSearch(testMgr);
       
   172         testResultXml(xml_file);
   158     }
   173     }
   159 
   174 
   160     void testDelete_05(Itk::TestMgr * testMgr)
   175     void testDelete_05(Itk::TestMgr * testMgr)
   161     {
   176     {
       
   177         char *xml_file = (char *)__FUNCTION__;
       
   178         assert_failed = 0;
   162         testDeleteSms(1,
   179         testDeleteSms(1,
   163                       testMgr);
   180                       testMgr);
   164         util_->flush();
   181         util_->flush();
   165         testSearch(testMgr);
   182         testSearch(testMgr);
       
   183         testResultXml(xml_file);
   166     }
   184     }
   167 
   185 
   168     void testReOpenIdx_06(Itk::TestMgr * testMgr)
   186     void testReOpenIdx_06(Itk::TestMgr * testMgr)
   169     {
   187     {
       
   188         char *xml_file = (char *)__FUNCTION__;
       
   189         assert_failed = 0;
   170         testReOpenIdxDb(testMgr);
   190         testReOpenIdxDb(testMgr);
   171         testSearch(testMgr);
   191         testSearch(testMgr);
       
   192         testResultXml(xml_file);
   172     }
   193     }
   173     
   194     
   174     void testAdd_07(Itk::TestMgr * testMgr)
   195     void testAdd_07(Itk::TestMgr * testMgr)
   175     {
   196     {
       
   197         char *xml_file = (char *)__FUNCTION__;
       
   198         assert_failed = 0;
   176         testAddSms(testMgr,
   199         testAddSms(testMgr,
   177                    4,
   200                    4,
   178                    L"This is the 4th happy message");
   201                    L"This is the 4th happy message");
   179         util_->flush();
   202         util_->flush();
   180         testSearch(testMgr);
   203         testSearch(testMgr);
       
   204         testResultXml(xml_file);
   181     }
   205     }
   182 
   206 
   183     void testAdd_08(Itk::TestMgr * testMgr)
   207     void testAdd_08(Itk::TestMgr * testMgr)
   184     {
   208     {
       
   209         char *xml_file = (char *)__FUNCTION__;
       
   210         assert_failed = 0;
   185         testAddSms(testMgr,
   211         testAddSms(testMgr,
   186                    5,
   212                    5,
   187                    L"This is the 5th happy message");
   213                    L"This is the 5th happy message");
   188         util_->flush();
   214         util_->flush();
   189         testSearch(testMgr);
   215         testSearch(testMgr);
       
   216         testResultXml(xml_file);
   190     }
   217     }
   191 
   218 
   192     void testDelete_09(Itk::TestMgr * testMgr)
   219     void testDelete_09(Itk::TestMgr * testMgr)
   193     {
   220     {
       
   221         char *xml_file = (char *)__FUNCTION__;
       
   222         assert_failed = 0;
   194         testDeleteSms(2,
   223         testDeleteSms(2,
   195                       testMgr);
   224                       testMgr);
   196         util_->flush();
   225         util_->flush();
   197         testSearch(testMgr);
   226         testSearch(testMgr);
       
   227         testResultXml(xml_file);
   198     }
   228     }
   199 
   229 
   200     void testDelete_10(Itk::TestMgr * testMgr)
   230     void testDelete_10(Itk::TestMgr * testMgr)
   201     {
   231     {
       
   232         char *xml_file = (char *)__FUNCTION__;
       
   233         assert_failed = 0;
   202         testDeleteSms(4,
   234         testDeleteSms(4,
   203                       testMgr);
   235                       testMgr);
   204         util_->flush();
   236         util_->flush();
   205         testSearch(testMgr);
   237         testSearch(testMgr);
       
   238         testResultXml(xml_file);
   206     }
   239     }
   207 
   240 
   208     void testReOpenIdx_11(Itk::TestMgr * testMgr)
   241     void testReOpenIdx_11(Itk::TestMgr * testMgr)
   209     {
   242     {
       
   243         char *xml_file = (char *)__FUNCTION__;
       
   244         assert_failed = 0;
   210         testReOpenIdxDb(testMgr);
   245         testReOpenIdxDb(testMgr);
   211         testSearch(testMgr);
   246         testSearch(testMgr);
       
   247         testResultXml(xml_file);
   212     }
   248     }
   213     
   249     
   214 
   250 
   215 
   251 
   216 private:
   252 private:
   262         cpix_IdxDb_flush(util_->idxDb());
   298         cpix_IdxDb_flush(util_->idxDb());
   263 
   299 
   264         ITK_EXPECT(testMgr,
   300         ITK_EXPECT(testMgr,
   265                    cpix_Succeeded(util_->idxDb()),
   301                    cpix_Succeeded(util_->idxDb()),
   266                    "Could not flush idx");
   302                    "Could not flush idx");
       
   303         if(!cpix_Succeeded(util_->idxDb()))
       
   304         {
       
   305         assert_failed = 1;
       
   306         }
       
   307                 
   267     }
   308     }
   268 
   309 
   269 
   310 
   270     void testDeleteSms(size_t         docUid,
   311     void testDeleteSms(size_t         docUid,
   271                        Itk::TestMgr * testMgr)
   312                        Itk::TestMgr * testMgr)
   287             {
   328             {
   288                 ITK_EXPECT(testMgr,
   329                 ITK_EXPECT(testMgr,
   289                            false,
   330                            false,
   290                            "Failed to search");
   331                            "Failed to search");
   291                 cpix_ClearError(util_->idxDb());
   332                 cpix_ClearError(util_->idxDb());
       
   333                 assert_failed = 1;
   292             }
   334             }
   293         else
   335         else
   294             {
   336             {
   295                 util_->printHits(hits,
   337                 util_->printHits(hits,
   296                                  testMgr);
   338                                  testMgr);