searchengine/cpix/tsrc/cpixunittest/src/partialsmstests.cpp
changeset 0 671dee74050a
child 3 ae3f1779f6da
equal deleted inserted replaced
-1:000000000000 0:671dee74050a
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <wchar.h>
       
    19 #include <stddef.h>
       
    20 
       
    21 #include <iostream>
       
    22 #include <algorithm>
       
    23 
       
    24 #include "cpixfstools.h"
       
    25 
       
    26 #include "itk.h"
       
    27 
       
    28 #include "cpixidxdb.h"
       
    29 
       
    30 #include "config.h"
       
    31 #include "suggestion.h"
       
    32 #include "testutils.h"
       
    33 #include "testcorpus.h"
       
    34 #include "setupsentry.h"
       
    35 
       
    36 /****
       
    37  * Simple test cases (one client)
       
    38  */
       
    39 
       
    40 class SimpleSmsContext : public Itk::ITestContext
       
    41 {
       
    42 protected:
       
    43     //
       
    44     // protected members
       
    45     //
       
    46     SmsIdxUtil        * util_;
       
    47     cpix_Analyzer     * analyzer_;
       
    48     cpix_Query        * query_;
       
    49     cpix_Query        * termsQuery_;
       
    50 
       
    51     cpix_QueryParser  * queryParser_;
       
    52 
       
    53     LineTestCorpusRef   corpus_;
       
    54     
       
    55 
       
    56 public:
       
    57     //
       
    58     // From interface Itk::ITestContext
       
    59     //
       
    60     virtual void setup() throw (Itk::PanicExc)
       
    61     {
       
    62         SetupSentry
       
    63             ss(*this);
       
    64 
       
    65         util_ = new SmsIdxUtil;
       
    66         util_->init();
       
    67 
       
    68         cpix_Result
       
    69             result;
       
    70 
       
    71         analyzer_ = cpix_CreateSimpleAnalyzer(&result);
       
    72 
       
    73         if (analyzer_ == NULL)
       
    74             {
       
    75                 ITK_PANIC("Could not create analyzer");
       
    76             }
       
    77 
       
    78         queryParser_ = cpix_QueryParser_create(&result,
       
    79                                                LBODY_FIELD,
       
    80                                                analyzer_);
       
    81         if (queryParser_ == NULL)
       
    82             {
       
    83                 ITK_PANIC("Could not create query parser");
       
    84             }
       
    85 
       
    86         query_ = cpix_QueryParser_parse(queryParser_,
       
    87                                         L"happy");
       
    88         if (cpix_Failed(queryParser_)
       
    89             || query_ == NULL)
       
    90             {
       
    91                 ITK_PANIC("Could not parse query string");
       
    92             }
       
    93         
       
    94         // terms (suggestions) query using unified search API
       
    95         termsQuery_ = cpix_QueryParser_parse(queryParser_,
       
    96                                              L"$terms<50>(h*)");
       
    97 
       
    98         if (cpix_Failed(queryParser_)
       
    99             || termsQuery_ == NULL)
       
   100             {
       
   101                 ITK_PANIC("Could not parse terms query string");
       
   102             }
       
   103 
       
   104         ss.setupComplete();
       
   105     }
       
   106 
       
   107 
       
   108     virtual void tearDown() throw()
       
   109     {
       
   110         cleanup();
       
   111     }
       
   112 
       
   113 
       
   114     virtual ~SimpleSmsContext()
       
   115     {
       
   116         cleanup();
       
   117     }
       
   118 
       
   119 
       
   120     //
       
   121     // public operations
       
   122     //
       
   123     SimpleSmsContext()
       
   124         : util_(NULL),
       
   125           analyzer_(NULL),
       
   126           query_(NULL),
       
   127           termsQuery_(NULL),
       
   128           queryParser_(NULL),
       
   129           corpus_(DEFAULT_TEST_CORPUS_PATH)
       
   130     {
       
   131         ;
       
   132     }
       
   133     
       
   134 private:
       
   135     //
       
   136     // private methods
       
   137     //
       
   138     void cleanup()
       
   139     {
       
   140         delete util_;
       
   141         util_ = NULL;
       
   142 
       
   143         cpix_Analyzer_destroy(analyzer_);
       
   144         analyzer_ = NULL;
       
   145 
       
   146         cpix_Query_destroy(query_);
       
   147         query_ = NULL;
       
   148 
       
   149         cpix_Query_destroy(termsQuery_);
       
   150         termsQuery_ = NULL;
       
   151 
       
   152         cpix_QueryParser_destroy(queryParser_);
       
   153         queryParser_ = NULL;
       
   154     }
       
   155 };
       
   156 
       
   157 
       
   158 /********
       
   159  * Simple Indexing Test Sequence
       
   160  */
       
   161 class SimpleIdxSeq : public SimpleSmsContext
       
   162 {
       
   163 public:
       
   164 
       
   165     void testAddSome(Itk::TestMgr * testMgr)
       
   166     {
       
   167         using namespace Itk;
       
   168 
       
   169         Timestamp
       
   170             start,
       
   171             end;
       
   172         getTimestamp(&start);
       
   173 
       
   174         for (size_t i = 0; i < 200; ++i) 
       
   175             {
       
   176                 std::wstring
       
   177                     body = corpus_.item(i);
       
   178                 util_->indexSms(i,
       
   179                                 body.c_str(),
       
   180                                 analyzer_,
       
   181                                 testMgr);
       
   182                 if ((i % 5) == 0)
       
   183                     {
       
   184                         ITK_DBGMSG(testMgr,
       
   185                                    ".");
       
   186                     }
       
   187             }
       
   188 
       
   189         getTimestamp(&end);
       
   190 
       
   191         long
       
   192             ms = getElapsedMs(&end,
       
   193                               &start);
       
   194         ITK_REPORT(testMgr,
       
   195                    "Adding 200 SMS",
       
   196                    "%d ms",
       
   197                    ms);
       
   198 
       
   199         util_->flush();
       
   200     }
       
   201 
       
   202 
       
   203     void testSearch(Itk::TestMgr * testMgr)
       
   204     {
       
   205         using namespace Itk;
       
   206 
       
   207         Timestamp
       
   208             start,
       
   209             end;
       
   210         getTimestamp(&start);
       
   211 
       
   212         cpix_Hits
       
   213             * hits = cpix_IdxDb_search(util_->idxDb(),
       
   214                                        query_);
       
   215 
       
   216         if (cpix_Failed(util_->idxDb()))
       
   217             {
       
   218                 ITK_EXPECT(testMgr,
       
   219                            false,
       
   220                            "Failed to search index");
       
   221                 cpix_ClearError(util_->idxDb());
       
   222             }
       
   223         else
       
   224             {
       
   225                 util_->printHits(hits,
       
   226                                  testMgr);
       
   227             }
       
   228 
       
   229         getTimestamp(&end);
       
   230         
       
   231         cpix_Hits_destroy( hits );  
       
   232 
       
   233         long
       
   234             ms = getElapsedMs(&end,
       
   235                               &start);
       
   236         ITK_REPORT(testMgr,
       
   237                    "Searching 'happy' in 200 SMS idx",
       
   238                    "%d ms",
       
   239                    ms);
       
   240     }
       
   241 
       
   242 
       
   243 
       
   244     void testSuggest(Itk::TestMgr * testMgr)
       
   245     {
       
   246         using namespace Itk;
       
   247 
       
   248         Timestamp
       
   249             start,
       
   250             end;
       
   251         getTimestamp(&start);
       
   252 
       
   253         // getting terms (suggestions) using unified search API
       
   254         cpix_Hits
       
   255             * hits = cpix_IdxDb_search(util_->idxDb(),
       
   256                                        termsQuery_);
       
   257 
       
   258         if (cpix_Failed(util_->idxDb()))
       
   259             {
       
   260                 ITK_EXPECT(testMgr,
       
   261                            false,
       
   262                            "Failed to get suggestions form the index");
       
   263                 cpix_ClearError(util_->idxDb());
       
   264             }
       
   265         else
       
   266             {
       
   267                 using namespace std;
       
   268 
       
   269                 int32_t
       
   270                     hitCount = cpix_Hits_length(hits);
       
   271 
       
   272                 if (cpix_Failed(hits))
       
   273                     {
       
   274                         ITK_EXPECT(testMgr,
       
   275                                    false,
       
   276                                    "Failed to get number of hits");
       
   277                         cpix_ClearError(hits);
       
   278                         return;
       
   279                     }
       
   280 
       
   281                 cout << "Number of hits: " << hitCount << endl;
       
   282             }
       
   283 
       
   284         getTimestamp(&end);
       
   285         
       
   286         Suggestion::printSuggestions(hits,
       
   287                                      testMgr);
       
   288         
       
   289         cpix_Hits_destroy( hits );  
       
   290         
       
   291         long
       
   292             ms = getElapsedMs(&end,
       
   293                               &start);
       
   294         ITK_REPORT(testMgr,
       
   295                    "Suggesting 'h' in 200 SMS idx",
       
   296                    "%d ms",
       
   297                    ms);
       
   298     }
       
   299     
       
   300 
       
   301     void testDump(Itk::TestMgr  * testMgr,
       
   302                   const wchar_t * dumpQryStr)
       
   303     {
       
   304         using namespace Itk;
       
   305 
       
   306         cpix_Query
       
   307             * dumpQuery = cpix_QueryParser_parse(queryParser_,
       
   308                                                  dumpQryStr);
       
   309 
       
   310         ITK_EXPECT(testMgr,
       
   311                    cpix_Succeeded(queryParser_),
       
   312                    "Could not parse dump query string '%S'",
       
   313                    dumpQryStr);
       
   314 
       
   315         if (cpix_Failed(queryParser_))
       
   316             {
       
   317                 return;
       
   318             }
       
   319 
       
   320         Timestamp
       
   321             start,
       
   322             end;
       
   323         getTimestamp(&start);
       
   324 
       
   325         cpix_Hits
       
   326             * hits = cpix_IdxDb_search(util_->idxDb(),
       
   327                                        dumpQuery);
       
   328 
       
   329         getTimestamp(&end);
       
   330 
       
   331         if (cpix_Failed(util_->idxDb()))
       
   332             {
       
   333                 ITK_EXPECT(testMgr,
       
   334                            false,
       
   335                            "Failed to dump");
       
   336                 cpix_ClearError(util_->idxDb());
       
   337             }
       
   338         else
       
   339             {
       
   340                 util_->printHits(hits,
       
   341                                  testMgr);
       
   342                 
       
   343             }
       
   344 
       
   345         long
       
   346             ms = getElapsedMs(&end,
       
   347                               &start);
       
   348         ITK_REPORT(testMgr,
       
   349                    "Dumping in 200 SMS idx",
       
   350                    "%d ms",
       
   351                    ms);
       
   352 
       
   353         cpix_Hits_destroy(hits);  
       
   354         cpix_Query_destroy(dumpQuery);
       
   355     }
       
   356 
       
   357 
       
   358     void testDump1(Itk::TestMgr * testMgr)
       
   359     {
       
   360         testDump(testMgr,
       
   361                   L"*");
       
   362     }
       
   363 
       
   364     
       
   365     void testDump2(Itk::TestMgr * testMgr)
       
   366     {
       
   367         testDump(testMgr,
       
   368                   L"$dump");
       
   369     }
       
   370 
       
   371 
       
   372     void testDump3(Itk::TestMgr * testMgr)
       
   373     {
       
   374         testDump(testMgr,
       
   375                   L"* AND _aggregate:happy");
       
   376     }
       
   377 
       
   378 
       
   379     void testDump4(Itk::TestMgr * testMgr)
       
   380     {
       
   381         testDump(testMgr,
       
   382                   L"$dump(_aggregate:happy)");
       
   383     }
       
   384 
       
   385 
       
   386     void testUpdate(Itk::TestMgr * testMgr)
       
   387     {
       
   388         using namespace Itk;
       
   389 
       
   390         Timestamp
       
   391             start,
       
   392             end;
       
   393         getTimestamp(&start);
       
   394 
       
   395         int32_t
       
   396             maxInsertBufSize = 32 * 1024;
       
   397 
       
   398         cpix_IdxDb_setMaxInsertBufSize(util_->idxDb(),
       
   399                                           maxInsertBufSize);
       
   400         ITK_EXPECT(testMgr,
       
   401                    cpix_Succeeded(util_->idxDb()),
       
   402                    "Failed to set max insert buffer size to %d",
       
   403                    maxInsertBufSize);
       
   404 
       
   405         util_->indexSms(23,
       
   406                         L"This UPDATED msg body does not have the h.appy word in it anymore",
       
   407                         analyzer_,
       
   408                         testMgr,
       
   409                         true); // update
       
   410         util_->indexSms(32,
       
   411                         L"This UPDATED msg body does have the happy word in it",
       
   412                         analyzer_,
       
   413                         testMgr,
       
   414                         true); // update
       
   415 
       
   416         for (int i = 0; i < 10; ++i)
       
   417             {
       
   418                 util_->indexSms(40 + i,
       
   419                                 L"Just to update couple of times, to fill up the insert buffer in update state too. Garble, gobledegook.",
       
   420                                 analyzer_,
       
   421                                 testMgr,
       
   422                                 true); // update
       
   423             }
       
   424 
       
   425         getTimestamp(&end);
       
   426 
       
   427         long
       
   428             ms = getElapsedMs(&end,
       
   429                               &start);
       
   430         ITK_REPORT(testMgr,
       
   431                    "Updating 2 docs in 200 SMS idx",
       
   432                    "%d ms",
       
   433                    ms);
       
   434 
       
   435         util_->flush();
       
   436     }
       
   437 };
       
   438 
       
   439 
       
   440 #define SUITE "partsms"
       
   441 
       
   442 Itk::TesterBase * CreateSimpleIdxSequence()
       
   443 {
       
   444     using namespace Itk;
       
   445 
       
   446 #define SEQUENCE "simpleidx"
       
   447 
       
   448     SimpleIdxSeq
       
   449         * simpleIdxSeq = new SimpleIdxSeq;
       
   450     ContextTester
       
   451         * simpleIdxer = new ContextTester(SEQUENCE,
       
   452                                           simpleIdxSeq);
       
   453 
       
   454 #define TEST "addSome"
       
   455     simpleIdxer->add(TEST,
       
   456                      simpleIdxSeq,
       
   457                      &SimpleIdxSeq::testAddSome,
       
   458                      TEST);
       
   459 #undef TEST
       
   460 
       
   461 #define TEST "search"
       
   462     simpleIdxer->add(TEST,
       
   463                      simpleIdxSeq,
       
   464                      &SimpleIdxSeq::testSearch,
       
   465                      TEST);
       
   466 #undef TEST
       
   467 
       
   468 #define TEST "suggest"
       
   469     simpleIdxer->add(TEST,
       
   470                      simpleIdxSeq,
       
   471                      &SimpleIdxSeq::testSuggest,
       
   472                      TEST);
       
   473 #undef TEST
       
   474 
       
   475 #define TEST "dump1"
       
   476     simpleIdxer->add(TEST,
       
   477                      simpleIdxSeq,
       
   478                      &SimpleIdxSeq::testDump1,
       
   479                      TEST);
       
   480 #undef TEST
       
   481 
       
   482     
       
   483 #define TEST "dump2"
       
   484     simpleIdxer->add(TEST,
       
   485                      simpleIdxSeq,
       
   486                      &SimpleIdxSeq::testDump2,
       
   487                      TEST);
       
   488 #undef TEST
       
   489 
       
   490 #define TEST "dump3"
       
   491     simpleIdxer->add(TEST,
       
   492                      simpleIdxSeq,
       
   493                      &SimpleIdxSeq::testDump3,
       
   494                      TEST);
       
   495 #undef TEST
       
   496 
       
   497 #define TEST "dump4"
       
   498     simpleIdxer->add(TEST,
       
   499                      simpleIdxSeq,
       
   500                      &SimpleIdxSeq::testDump4,
       
   501                      TEST);
       
   502 #undef TEST
       
   503 
       
   504 #define TEST "update"
       
   505     simpleIdxer->add(TEST,
       
   506                      simpleIdxSeq,
       
   507                      &SimpleIdxSeq::testUpdate,
       
   508                      TEST);
       
   509 #undef TEST
       
   510 
       
   511 #define TEST "search2"
       
   512     simpleIdxer->add(TEST,
       
   513                      simpleIdxSeq,
       
   514                      &SimpleIdxSeq::testSearch,       // Same test func with 
       
   515                      TEST);  // different name! :-)
       
   516 #undef TEST
       
   517 
       
   518 #define TEST "suggest2"
       
   519     simpleIdxer->add(TEST,
       
   520                      simpleIdxSeq,
       
   521                      &SimpleIdxSeq::testSuggest,
       
   522                      TEST);
       
   523 #undef TEST
       
   524 
       
   525     return simpleIdxer;
       
   526 
       
   527 #undef SEQUENCE
       
   528 }
       
   529 
       
   530 
       
   531 
       
   532     /****
       
   533      * Parallel test cases (two clients)
       
   534      */
       
   535     // TODO perhaps move it to a common utils file
       
   536 class ParallelSmsContext : public Itk::ITestContext
       
   537 {
       
   538 protected:
       
   539     //
       
   540     // protected members
       
   541     //
       
   542     SmsIdxUtil       * util1_;
       
   543     SmsIdxUtil       * util2_;
       
   544     cpix_Analyzer    * analyzer_;
       
   545     cpix_Query       * query_;
       
   546     LineTestCorpusRef  corpus_;
       
   547     cpix_QueryParser * queryParser_;
       
   548     
       
   549 
       
   550 public:
       
   551     //
       
   552     // From interface Itk::ITestContext
       
   553     //
       
   554     virtual void setup() throw (Itk::PanicExc)
       
   555     {
       
   556         SetupSentry
       
   557             ss(*this);
       
   558 
       
   559         util1_ = new SmsIdxUtil;
       
   560         util1_->init();
       
   561         util2_ = new SmsIdxUtil;
       
   562         util2_->init(false);  // only open
       
   563 
       
   564         cpix_Result
       
   565             result;
       
   566 
       
   567         analyzer_ = cpix_CreateSimpleAnalyzer(&result);
       
   568 
       
   569         if (analyzer_ == NULL)
       
   570             {
       
   571                 ITK_PANIC("Could not create analyzer");
       
   572             }
       
   573 
       
   574         queryParser_ = cpix_QueryParser_create(&result,
       
   575                                               LBODY_FIELD,
       
   576                                               analyzer_);
       
   577         if (queryParser_ == NULL)
       
   578             {
       
   579                 ITK_PANIC("Could not create query parser");
       
   580             }
       
   581 
       
   582         query_ = cpix_QueryParser_parse(queryParser_,
       
   583                                         L"happy");
       
   584         if (cpix_Failed(queryParser_)
       
   585             || query_ == NULL)
       
   586             {
       
   587                 ITK_PANIC("Could not parse query string");
       
   588             }
       
   589         
       
   590         ss.setupComplete();
       
   591     }
       
   592 
       
   593 
       
   594     virtual void tearDown() throw()
       
   595     {
       
   596         cleanup();
       
   597     }
       
   598 
       
   599 
       
   600     virtual ~ParallelSmsContext()
       
   601     {
       
   602         cleanup();
       
   603     }
       
   604 
       
   605 
       
   606     //
       
   607     // public operations
       
   608     //
       
   609     ParallelSmsContext()
       
   610         : util1_(NULL),
       
   611           util2_(NULL),
       
   612           analyzer_(NULL),
       
   613           query_(NULL),          
       
   614           corpus_(DEFAULT_TEST_CORPUS_PATH),
       
   615           queryParser_(NULL)
       
   616     {
       
   617         ;
       
   618     }
       
   619 
       
   620     
       
   621 private:
       
   622     //
       
   623     // private methods
       
   624     //
       
   625     void cleanup()
       
   626     {
       
   627         delete util1_;
       
   628         delete util2_;
       
   629         util1_ = NULL;
       
   630         util2_ = NULL;
       
   631 
       
   632         cpix_Analyzer_destroy(analyzer_);
       
   633         analyzer_ = NULL;
       
   634 
       
   635         cpix_Query_destroy(query_);
       
   636         query_ = NULL;
       
   637 
       
   638         cpix_QueryParser_destroy(queryParser_);
       
   639         queryParser_ = NULL;
       
   640     }
       
   641 };
       
   642 
       
   643 
       
   644 
       
   645 
       
   646     /********
       
   647      * Parallel Indexing Test Sequence
       
   648      *
       
   649      * One client is indexing and updating content while the other is
       
   650      * searching - and it should make no difference whatsoever.
       
   651      */
       
   652 class ParallelIdxSeq : public ParallelSmsContext
       
   653 {
       
   654 private:
       
   655     size_t curId_;
       
   656 
       
   657 public:
       
   658 
       
   659     virtual void setup() throw (Itk::PanicExc)
       
   660     {
       
   661         ParallelSmsContext::setup();
       
   662 
       
   663         curId_ = 0;
       
   664     }
       
   665 
       
   666 
       
   667     void testAddSome(Itk::TestMgr * testMgr)
       
   668     {
       
   669         // the same function is invoked multiple times to add
       
   670         // more and more documents (in batches of 50)
       
   671         for (size_t i = 0; i < 50; ++i)
       
   672             {
       
   673                 ++curId_;
       
   674                 std::wstring
       
   675                     body = corpus_.item(curId_);
       
   676                 util1_->indexSms(curId_,
       
   677                                  body.c_str(),
       
   678                                  analyzer_,
       
   679                                  testMgr);
       
   680             }
       
   681         util1_->flush();
       
   682     }
       
   683 
       
   684 
       
   685     void testSearch(Itk::TestMgr * testMgr)
       
   686     {
       
   687         cpix_Hits
       
   688             * hits = cpix_IdxDb_search(util2_->idxDb(),
       
   689                                        query_);
       
   690 
       
   691         if (cpix_Failed(util2_->idxDb()))
       
   692             {
       
   693                 ITK_EXPECT(testMgr,
       
   694                            false,
       
   695                            "Failed to search index");
       
   696                 cpix_ClearError(util2_->idxDb());
       
   697             }
       
   698         else
       
   699             {
       
   700                 util2_->printHits(hits,
       
   701                                   testMgr);
       
   702                 
       
   703                 cpix_Hits_destroy( hits );  
       
   704             }
       
   705     }
       
   706 
       
   707     
       
   708     void testUpdate(Itk::TestMgr * testMgr)
       
   709     {
       
   710         int32_t
       
   711             maxInsertBufSize = 32 * 1024; // 32 KB
       
   712 
       
   713         cpix_IdxDb_setMaxInsertBufSize(util1_->idxDb(),
       
   714                                        maxInsertBufSize);
       
   715         ITK_EXPECT(testMgr,
       
   716                    cpix_Succeeded(util1_->idxDb()),
       
   717                    "Failed to set max insert buffer size to %d",
       
   718                    maxInsertBufSize);
       
   719 
       
   720         util1_->indexSms(23,
       
   721                          L"This UPDATED msg body does not have the h.appy word in it anymore",
       
   722                          analyzer_,
       
   723                          testMgr,
       
   724                          true); // update
       
   725         util1_->indexSms(32,
       
   726                          L"This UPDATED msg body does have the happy word in it",
       
   727                          analyzer_,
       
   728                          testMgr,
       
   729                          true); // update
       
   730 
       
   731         for (int i = 0; i < 10; ++i)
       
   732             {
       
   733                 util1_->indexSms(40 + i,
       
   734                                  L"Just to update couple of times, to fill up the insert buffer in update state too. Garble, gobledegook.",
       
   735                                  analyzer_,
       
   736                                  testMgr,
       
   737                                  true); // update
       
   738             }
       
   739         util1_->flush();
       
   740     }
       
   741 };
       
   742 
       
   743 
       
   744 
       
   745 Itk::TesterBase * CreateParallelIdxSequence()
       
   746 {
       
   747     using namespace Itk;
       
   748 
       
   749 #define SEQUENCE "parallelidx"
       
   750 
       
   751     ParallelIdxSeq
       
   752         * parallelIdxSeq = new ParallelIdxSeq;
       
   753     ContextTester
       
   754         * parallelIdxer = new ContextTester(SEQUENCE,
       
   755                                             parallelIdxSeq);
       
   756 
       
   757 #define TEST "addSome1"
       
   758     parallelIdxer->add(TEST,
       
   759                        parallelIdxSeq,
       
   760                        &ParallelIdxSeq::testAddSome,
       
   761                        TEST);
       
   762 #undef TEST
       
   763 
       
   764 #define TEST "search1"
       
   765     parallelIdxer->add(TEST,
       
   766                        parallelIdxSeq,
       
   767                        &ParallelIdxSeq::testSearch,
       
   768                        TEST);
       
   769 #undef TEST
       
   770 
       
   771 #define TEST "addSome2"
       
   772     parallelIdxer->add(TEST,
       
   773                        parallelIdxSeq,
       
   774                        &ParallelIdxSeq::testAddSome,
       
   775                        TEST);
       
   776 #undef TEST
       
   777 
       
   778 #define TEST "search2"
       
   779     parallelIdxer->add(TEST,
       
   780                        parallelIdxSeq,
       
   781                        &ParallelIdxSeq::testSearch,
       
   782                        TEST);
       
   783 #undef TEST
       
   784 
       
   785 #define TEST "addSome3"
       
   786     parallelIdxer->add(TEST,
       
   787                        parallelIdxSeq,
       
   788                        &ParallelIdxSeq::testAddSome,
       
   789                        TEST);
       
   790 #undef TEST
       
   791 
       
   792 #define TEST "search3"
       
   793     parallelIdxer->add(TEST,
       
   794                        parallelIdxSeq,
       
   795                        &ParallelIdxSeq::testSearch,
       
   796                        TEST);
       
   797 #undef TEST
       
   798 
       
   799 #define TEST "addSome4"
       
   800     parallelIdxer->add(TEST,
       
   801                        parallelIdxSeq,
       
   802                        &ParallelIdxSeq::testAddSome,
       
   803                        TEST);
       
   804 #undef TEST
       
   805 
       
   806 #define TEST "search4"
       
   807     parallelIdxer->add(TEST,
       
   808                        parallelIdxSeq,
       
   809                        &ParallelIdxSeq::testSearch,
       
   810                        TEST);
       
   811 #undef TEST
       
   812 
       
   813 #define TEST "update"
       
   814     parallelIdxer->add(TEST,
       
   815                        parallelIdxSeq,
       
   816                        &ParallelIdxSeq::testUpdate,
       
   817                        TEST);
       
   818 #undef TEST
       
   819 
       
   820 #define TEST "search5"
       
   821     parallelIdxer->add(TEST,
       
   822                        parallelIdxSeq,
       
   823                        &ParallelIdxSeq::testSearch,  // Same test func with 
       
   824                        TEST);                        // different name! :-)
       
   825 #undef TEST
       
   826 
       
   827     return parallelIdxer;
       
   828 
       
   829 #undef SEQUENCE
       
   830 }
       
   831 
       
   832 
       
   833     /****
       
   834      * Mixed index test cases
       
   835      */
       
   836 class MixedContext : public Itk::ITestContext
       
   837 {
       
   838 protected:
       
   839     //
       
   840     // protected members
       
   841     //
       
   842     SmsIdxUtil   * smsUtil1_;
       
   843     SmsIdxUtil   * smsUtil2_;
       
   844     FileIdxUtil  * fileUtil1_;
       
   845     FileIdxUtil  * fileUtil2_;
       
   846 
       
   847     cpix_Analyzer  * analyzer_;
       
   848     cpix_Query     * smsQuery_;
       
   849     cpix_Query     * fileQuery_;
       
   850     LineTestCorpusRef   corpus_;
       
   851 
       
   852     cpix_QueryParser * queryParser_;
       
   853     
       
   854 public:
       
   855     virtual void setup() throw (Itk::PanicExc)
       
   856     {
       
   857         SetupSentry
       
   858             ss(*this);
       
   859 
       
   860         cpix_Result
       
   861             result;
       
   862 
       
   863         cpix_IdxDb_dbgScrapAll(&result);
       
   864 
       
   865         using namespace std;
       
   866 
       
   867         smsUtil1_ = new SmsIdxUtil;
       
   868         smsUtil1_->init();
       
   869 
       
   870         smsUtil2_ = new SmsIdxUtil;
       
   871         smsUtil2_->init(false);
       
   872 
       
   873         fileUtil1_ = new FileIdxUtil;
       
   874         fileUtil1_->init();
       
   875 
       
   876         fileUtil2_ = new FileIdxUtil;
       
   877         fileUtil2_->init(false);
       
   878         
       
   879         analyzer_ = cpix_CreateSimpleAnalyzer(&result);
       
   880         if (analyzer_ == NULL)
       
   881             {
       
   882                 ITK_PANIC("Could not create analyzer");
       
   883             }
       
   884 
       
   885         queryParser_ = cpix_QueryParser_create(&result,
       
   886                                               LBODY_FIELD,
       
   887                                               analyzer_);
       
   888         if (queryParser_ == NULL)
       
   889             {
       
   890                 ITK_PANIC("Could not create query parser");
       
   891             }
       
   892 
       
   893         smsQuery_ = cpix_QueryParser_parse(queryParser_,
       
   894                                            L"happy");
       
   895         if (cpix_Failed(queryParser_)
       
   896             || smsQuery_ == NULL)
       
   897             {
       
   898                 ITK_PANIC("Could not parser query string");
       
   899             }
       
   900 
       
   901         fileQuery_ = cpix_QueryParser_parse(queryParser_,
       
   902                                             CONTENTS_FIELD L":happy");
       
   903         if (cpix_Failed(queryParser_)
       
   904             || fileQuery_ == NULL)
       
   905             {
       
   906                 ITK_PANIC("Could not parser query string");
       
   907             }
       
   908         
       
   909         ss.setupComplete();
       
   910     }
       
   911 
       
   912 
       
   913     virtual void tearDown() throw ()
       
   914     {
       
   915         cleanup();
       
   916     }
       
   917 
       
   918 
       
   919     virtual ~MixedContext()
       
   920     {
       
   921         cleanup();
       
   922     }
       
   923 
       
   924 
       
   925     //
       
   926     // public operations
       
   927     //
       
   928     MixedContext()
       
   929         : smsUtil1_(NULL),
       
   930           smsUtil2_(NULL),
       
   931           fileUtil1_(NULL),
       
   932           fileUtil2_(NULL),
       
   933           analyzer_(NULL),
       
   934           smsQuery_(NULL),
       
   935           fileQuery_(NULL),
       
   936           corpus_(DEFAULT_TEST_CORPUS_PATH),
       
   937           queryParser_(NULL)
       
   938     {
       
   939         ;
       
   940     }
       
   941 
       
   942 
       
   943 private:
       
   944     //
       
   945     // private methods
       
   946     //
       
   947     void cleanup()
       
   948     {
       
   949         delete smsUtil1_;
       
   950         delete smsUtil2_;
       
   951         delete fileUtil1_;
       
   952         delete fileUtil2_;
       
   953         smsUtil1_ = NULL;
       
   954         smsUtil2_ = NULL;
       
   955         fileUtil1_ = NULL;
       
   956         fileUtil2_ = NULL;
       
   957 
       
   958         cpix_Analyzer_destroy(analyzer_);
       
   959         analyzer_ = NULL;
       
   960 
       
   961         cpix_Query_destroy(smsQuery_);
       
   962         smsQuery_ = NULL;
       
   963 
       
   964         cpix_Query_destroy(fileQuery_);
       
   965         fileQuery_ = NULL;
       
   966 
       
   967         cpix_QueryParser_destroy(queryParser_);
       
   968         queryParser_ = NULL;
       
   969     }
       
   970 
       
   971 };
       
   972 
       
   973 
       
   974     /******
       
   975      * Mixed Indexing test sequence (2x2 clients on 2 indexes).
       
   976      */
       
   977 class MixedIdxSeq : public MixedContext, public Cpt::IFileVisitor
       
   978 {
       
   979 private:
       
   980     size_t        curId_;
       
   981     Itk::TestMgr * testMgr_;
       
   982 
       
   983 
       
   984 public:
       
   985 
       
   986     //
       
   987     // from Cpt::IFileVisitor
       
   988     //
       
   989     virtual bool visitFile(const char * path)
       
   990     {
       
   991         bool
       
   992             goOn = true;
       
   993 
       
   994         fileUtil1_->indexFile(path,
       
   995                               analyzer_,
       
   996                               testMgr_);
       
   997 
       
   998         return goOn;
       
   999     }
       
  1000     
       
  1001     
       
  1002     virtual DirVisitResult visitDirPre(const char * /*path*/)
       
  1003     {
       
  1004         return IFV_CONTINUE;
       
  1005     }
       
  1006 
       
  1007 
       
  1008     virtual bool visitDirPost(const char * /*path*/)
       
  1009     {
       
  1010         return true;
       
  1011     }
       
  1012 
       
  1013 
       
  1014     //
       
  1015     // actual tests
       
  1016     //
       
  1017     virtual void setup() throw (Itk::PanicExc)
       
  1018     {
       
  1019         MixedContext::setup();
       
  1020 
       
  1021         curId_ = 0;
       
  1022     }
       
  1023 
       
  1024     
       
  1025     void testAddSomeSms(Itk::TestMgr * testMgr)
       
  1026     {
       
  1027         for (size_t i = 0; i < 50; ++i)
       
  1028             {
       
  1029                 ++curId_;
       
  1030                 std::wstring
       
  1031                     body = corpus_.item(curId_);
       
  1032                 smsUtil1_->indexSms(curId_,
       
  1033                                     body.c_str(),
       
  1034                                     analyzer_,
       
  1035                                     testMgr);
       
  1036             }
       
  1037         smsUtil1_->flush();
       
  1038     }
       
  1039 
       
  1040 
       
  1041     void testAddFiles(Itk::TestMgr * testMgr)
       
  1042     {
       
  1043         testMgr_ = testMgr;
       
  1044         Cpt::traverse(FILE_TEST_CORPUS_PATH "\\en",
       
  1045                       this);
       
  1046         fileUtil1_->flush();
       
  1047     }
       
  1048 
       
  1049     
       
  1050     void testSearchSms(Itk::TestMgr * testMgr)
       
  1051     {
       
  1052         using namespace Itk;
       
  1053 
       
  1054         cpix_Hits
       
  1055             * hits = cpix_IdxDb_search(smsUtil2_->idxDb(),
       
  1056                                        smsQuery_);
       
  1057 
       
  1058         if (cpix_Failed(smsUtil2_->idxDb()))
       
  1059             {
       
  1060                 ITK_EXPECT(testMgr,
       
  1061                            false,
       
  1062                            "Failed to search index");
       
  1063                 cpix_ClearError(smsUtil2_->idxDb());
       
  1064             }
       
  1065         else
       
  1066             {
       
  1067                 smsUtil2_->printHits(hits,
       
  1068                                      testMgr);
       
  1069                 cpix_Hits_destroy(hits);
       
  1070             }
       
  1071 
       
  1072     }
       
  1073 
       
  1074 
       
  1075     void testSearchFiles(Itk::TestMgr * testMgr)
       
  1076     {
       
  1077         using namespace Itk;
       
  1078 
       
  1079         cpix_Hits
       
  1080             * hits = cpix_IdxDb_search(fileUtil2_->idxDb(),
       
  1081                                        fileQuery_);
       
  1082 
       
  1083         if (cpix_Failed(fileUtil2_->idxDb()))
       
  1084             {
       
  1085                 ITK_EXPECT(testMgr,
       
  1086                            false,
       
  1087                            "Failed to search index");
       
  1088                 cpix_ClearError(fileUtil2_->idxDb());
       
  1089             }
       
  1090         else
       
  1091             {
       
  1092                 fileUtil2_->printHits(hits,
       
  1093                                       testMgr);
       
  1094                 cpix_Hits_destroy(hits);
       
  1095             }
       
  1096     }
       
  1097     
       
  1098 };
       
  1099 
       
  1100 
       
  1101 
       
  1102 Itk::TesterBase * CreateMixedIdxSequence()
       
  1103 {
       
  1104     using namespace Itk;
       
  1105 
       
  1106 #define SEQUENCE "mixedidx"
       
  1107 
       
  1108     MixedIdxSeq
       
  1109         * mixedIdxSeq = new MixedIdxSeq;
       
  1110     ContextTester
       
  1111         * mixedIdxer = new ContextTester(SEQUENCE,
       
  1112                                          mixedIdxSeq);
       
  1113 
       
  1114 #define TEST "addSomeSms1"
       
  1115     mixedIdxer->add(TEST,
       
  1116                     mixedIdxSeq,
       
  1117                     &MixedIdxSeq::testAddSomeSms,
       
  1118                     TEST);
       
  1119 #undef TEST
       
  1120 
       
  1121 #define TEST "searchSms1"
       
  1122     mixedIdxer->add(TEST,
       
  1123                     mixedIdxSeq,
       
  1124                     &MixedIdxSeq::testSearchSms,
       
  1125                     TEST);
       
  1126 #undef TEST
       
  1127 
       
  1128 #define TEST "addSomeFiles1"
       
  1129     mixedIdxer->add(TEST,
       
  1130                     mixedIdxSeq,
       
  1131                     &MixedIdxSeq::testAddFiles,
       
  1132                     TEST);
       
  1133 #undef TEST
       
  1134 /*
       
  1135 #define TEST "searchFiles1"
       
  1136     mixedIdxer->add(TEST,
       
  1137                     mixedIdxSeq,
       
  1138                     &MixedIdxSeq::testSearchFiles,
       
  1139                     TEST);
       
  1140 #undef TEST
       
  1141 
       
  1142 #define TEST "addSomeSms2"
       
  1143     mixedIdxer->add(TEST,
       
  1144                     mixedIdxSeq,
       
  1145                     &MixedIdxSeq::testAddSomeSms,
       
  1146                     TEST);
       
  1147 #undef TEST
       
  1148 
       
  1149 #define TEST "searchSms2"
       
  1150     mixedIdxer->add(TEST,
       
  1151                     mixedIdxSeq,
       
  1152                     &MixedIdxSeq::testSearchSms,
       
  1153                     TEST);
       
  1154 #undef TEST
       
  1155 */
       
  1156 
       
  1157     return mixedIdxer;
       
  1158 
       
  1159 #undef SEQUENCE
       
  1160 }
       
  1161 
       
  1162 
       
  1163 
       
  1164 
       
  1165 
       
  1166     /****
       
  1167      * ParMSearcher test cases (two clients)
       
  1168      */
       
  1169     // TODO perhaps move it to a common utils file
       
  1170 class ParMSearcherSmsContext : public Itk::ITestContext
       
  1171 {
       
  1172 protected:
       
  1173     //
       
  1174     // protected members
       
  1175     //
       
  1176     SmsIdxUtil       * util_;
       
  1177     cpix_IdxSearcher * searcher_;
       
  1178     cpix_Analyzer    * analyzer_;
       
  1179     cpix_Query       * query_;
       
  1180     LineTestCorpusRef  corpus_;
       
  1181     cpix_QueryParser * queryParser_;
       
  1182     
       
  1183 
       
  1184 public:
       
  1185     //
       
  1186     // From interface Itk::ITestContext
       
  1187     //
       
  1188     virtual void setup() throw (Itk::PanicExc)
       
  1189     {
       
  1190         SetupSentry
       
  1191             ss(*this);
       
  1192 
       
  1193         util_ = new SmsIdxUtil;
       
  1194         util_->init();
       
  1195         cpix_Result
       
  1196             result;
       
  1197 
       
  1198         analyzer_ = cpix_CreateSimpleAnalyzer(&result);
       
  1199 
       
  1200         if (analyzer_ == NULL)
       
  1201             {
       
  1202                 ITK_PANIC("Could not create analyzer");
       
  1203             }
       
  1204 
       
  1205         queryParser_ = cpix_QueryParser_create(&result,
       
  1206                                               LBODY_FIELD,
       
  1207                                               analyzer_);
       
  1208         if (queryParser_ == NULL)
       
  1209             {
       
  1210                 ITK_PANIC("Could not create query parser");
       
  1211             }
       
  1212 
       
  1213         query_ = cpix_QueryParser_parse(queryParser_,
       
  1214                                         L"happy");
       
  1215         if (cpix_Failed(queryParser_)
       
  1216             || query_ == NULL)
       
  1217             {
       
  1218                 ITK_PANIC("Could not parse query string");
       
  1219             }
       
  1220         
       
  1221         searcher_ = cpix_IdxSearcher_openDb(&result,
       
  1222                                             SMS_QBASEAPPCLASS);
       
  1223                                      
       
  1224         if (searcher_ == NULL)
       
  1225             {
       
  1226                 ITK_PANIC("Could not create idx searcher");
       
  1227             }
       
  1228 
       
  1229         ss.setupComplete();
       
  1230     }
       
  1231 
       
  1232 
       
  1233     virtual void tearDown() throw()
       
  1234     {
       
  1235         cleanup();
       
  1236     }
       
  1237 
       
  1238 
       
  1239     virtual ~ParMSearcherSmsContext()
       
  1240     {
       
  1241         cleanup();
       
  1242     }
       
  1243 
       
  1244 
       
  1245     //
       
  1246     // public operations
       
  1247     //
       
  1248     ParMSearcherSmsContext()
       
  1249         : util_(NULL),
       
  1250           searcher_(NULL),
       
  1251           analyzer_(NULL),
       
  1252           query_(NULL),          
       
  1253           corpus_(DEFAULT_TEST_CORPUS_PATH),
       
  1254           queryParser_(NULL)
       
  1255     {
       
  1256         ;
       
  1257     }
       
  1258 
       
  1259     
       
  1260 private:
       
  1261     //
       
  1262     // private methods
       
  1263     //
       
  1264     void cleanup()
       
  1265     {
       
  1266         delete util_;
       
  1267         util_ = NULL;
       
  1268 
       
  1269         cpix_IdxSearcher_releaseDb(searcher_);
       
  1270         searcher_ = NULL;
       
  1271 
       
  1272         cpix_Analyzer_destroy(analyzer_);
       
  1273         analyzer_ = NULL;
       
  1274 
       
  1275         cpix_Query_destroy(query_);
       
  1276         query_ = NULL;
       
  1277 
       
  1278         cpix_QueryParser_destroy(queryParser_);
       
  1279         queryParser_ = NULL;
       
  1280     }
       
  1281 };
       
  1282 
       
  1283 
       
  1284 
       
  1285 
       
  1286     /********
       
  1287      * ParMSearcher Indexing Test Sequence
       
  1288      *
       
  1289      * One client is indexing and updating content while the other is
       
  1290      * searching - and it should make no difference whatsoever.
       
  1291      */
       
  1292 class ParMSearcherIdxSeq : public ParMSearcherSmsContext
       
  1293 {
       
  1294 private:
       
  1295     size_t curId_;
       
  1296 
       
  1297 public:
       
  1298 
       
  1299     virtual void setup() throw (Itk::PanicExc)
       
  1300     {
       
  1301         ParMSearcherSmsContext::setup();
       
  1302 
       
  1303         curId_ = 0;
       
  1304     }
       
  1305 
       
  1306 
       
  1307     void testAddSome(Itk::TestMgr * testMgr)
       
  1308     {
       
  1309         // the same function is invoked multiple times to add
       
  1310         // more and more documents (in batches of 50)
       
  1311         for (size_t i = 0; i < 50; ++i)
       
  1312             {
       
  1313                 ++curId_;
       
  1314                 std::wstring
       
  1315                     body = corpus_.item(curId_);
       
  1316                 util_->indexSms(curId_,
       
  1317                                 body.c_str(),
       
  1318                                 analyzer_,
       
  1319                                 testMgr);
       
  1320             }
       
  1321         util_->flush();
       
  1322     }
       
  1323 
       
  1324 
       
  1325     void testSearch(Itk::TestMgr * testMgr)
       
  1326     {
       
  1327         cpix_Hits
       
  1328             * hits = cpix_IdxSearcher_search(searcher_,
       
  1329                                              query_);
       
  1330 
       
  1331         if (cpix_Failed(searcher_))
       
  1332             {
       
  1333                 ITK_EXPECT(testMgr,
       
  1334                            false,
       
  1335                            "Failed to search index");
       
  1336                 cpix_ClearError(searcher_);
       
  1337             }
       
  1338         else
       
  1339             {
       
  1340                 util_->printHits(hits,
       
  1341                                  testMgr);
       
  1342 
       
  1343                 cpix_Hits_destroy(hits);
       
  1344             }
       
  1345     }
       
  1346 
       
  1347     
       
  1348     void testUpdate(Itk::TestMgr * testMgr)
       
  1349     {
       
  1350         int32_t
       
  1351             maxInsertBufSize = 32 * 1024; // 32 KB
       
  1352 	
       
  1353         cpix_IdxDb_setMaxInsertBufSize(util_->idxDb(),
       
  1354                                        maxInsertBufSize);
       
  1355         ITK_EXPECT(testMgr,
       
  1356                    cpix_Succeeded(util_->idxDb()),
       
  1357                    "Failed to set max insert buffer size to %d",
       
  1358                    maxInsertBufSize);
       
  1359 
       
  1360         util_->indexSms(23,
       
  1361                         L"This UPDATED msg body does not have the h.appy word in it anymore",
       
  1362                         analyzer_,
       
  1363                         testMgr,
       
  1364                         true); // update
       
  1365         util_->indexSms(32,
       
  1366                         L"This UPDATED msg body does have the happy word in it",
       
  1367                         analyzer_,
       
  1368                         testMgr,
       
  1369                         true); // update
       
  1370 
       
  1371         for (int i = 0; i < 10; ++i)
       
  1372             {
       
  1373                 util_->indexSms(40 + i,
       
  1374                                 L"Just to update couple of times, to fill up the insert buffer in update state too. Garble, gobledegook.",
       
  1375                                 analyzer_,
       
  1376                                 testMgr,
       
  1377                                 true); // update
       
  1378             }
       
  1379         util_->flush();
       
  1380     }
       
  1381 };
       
  1382 
       
  1383 
       
  1384 
       
  1385 Itk::TesterBase * CreateParMSearcherIdxSequence()
       
  1386 {
       
  1387     using namespace Itk;
       
  1388 
       
  1389 #define SEQUENCE "parmsearcheridx"
       
  1390 
       
  1391     ParMSearcherIdxSeq
       
  1392         * parallelIdxSeq = new ParMSearcherIdxSeq;
       
  1393     ContextTester
       
  1394         * parallelIdxer = new ContextTester(SEQUENCE,
       
  1395                                             parallelIdxSeq);
       
  1396 
       
  1397 #define TEST "addSome1"
       
  1398     parallelIdxer->add(TEST,
       
  1399                        parallelIdxSeq,
       
  1400                        &ParMSearcherIdxSeq::testAddSome,
       
  1401                        TEST);
       
  1402 #undef TEST
       
  1403 
       
  1404 #define TEST "search1"
       
  1405     parallelIdxer->add(TEST,
       
  1406                        parallelIdxSeq,
       
  1407                        &ParMSearcherIdxSeq::testSearch,
       
  1408                        TEST);
       
  1409 #undef TEST
       
  1410 
       
  1411 #define TEST "addSome2"
       
  1412     parallelIdxer->add(TEST,
       
  1413                        parallelIdxSeq,
       
  1414                        &ParMSearcherIdxSeq::testAddSome,
       
  1415                        TEST);
       
  1416 #undef TEST
       
  1417 
       
  1418 #define TEST "search2"
       
  1419     parallelIdxer->add(TEST,
       
  1420                        parallelIdxSeq,
       
  1421                        &ParMSearcherIdxSeq::testSearch,
       
  1422                        TEST);
       
  1423 #undef TEST
       
  1424 
       
  1425 #define TEST "addSome3"
       
  1426     parallelIdxer->add(TEST,
       
  1427                        parallelIdxSeq,
       
  1428                        &ParMSearcherIdxSeq::testAddSome,
       
  1429                        TEST);
       
  1430 #undef TEST
       
  1431 
       
  1432 #define TEST "search3"
       
  1433     parallelIdxer->add(TEST,
       
  1434                        parallelIdxSeq,
       
  1435                        &ParMSearcherIdxSeq::testSearch,
       
  1436                        TEST);
       
  1437 #undef TEST
       
  1438 
       
  1439 #define TEST "addSome4"
       
  1440     parallelIdxer->add(TEST,
       
  1441                        parallelIdxSeq,
       
  1442                        &ParMSearcherIdxSeq::testAddSome,
       
  1443                        TEST);
       
  1444 #undef TEST
       
  1445 
       
  1446 #define TEST "search4"
       
  1447     parallelIdxer->add(TEST,
       
  1448                        parallelIdxSeq,
       
  1449                        &ParMSearcherIdxSeq::testSearch,
       
  1450                        TEST);
       
  1451 #undef TEST
       
  1452 
       
  1453 #define TEST "update"
       
  1454     parallelIdxer->add(TEST,
       
  1455                        parallelIdxSeq,
       
  1456                        &ParMSearcherIdxSeq::testUpdate,
       
  1457                        TEST);
       
  1458 #undef TEST
       
  1459 
       
  1460 #define TEST "search5"
       
  1461     parallelIdxer->add(TEST,
       
  1462                        parallelIdxSeq,
       
  1463                        &ParMSearcherIdxSeq::testSearch,  // Same test func with 
       
  1464                        TEST);                        // different name! :-)
       
  1465 #undef TEST
       
  1466 
       
  1467     return parallelIdxer;
       
  1468 
       
  1469 #undef SEQUENCE
       
  1470 }
       
  1471 
       
  1472 
       
  1473 
       
  1474 
       
  1475     /*******
       
  1476      *
       
  1477      */
       
  1478 
       
  1479 
       
  1480 Itk::TesterBase * CreatePartialSmsTests()
       
  1481 {
       
  1482     using namespace Itk;
       
  1483 
       
  1484     SuiteTester
       
  1485         * partialSmsTests = new SuiteTester(SUITE);
       
  1486 
       
  1487     partialSmsTests->add(CreateSimpleIdxSequence());
       
  1488     partialSmsTests->add(CreateParallelIdxSequence());
       
  1489     partialSmsTests->add(CreateMixedIdxSequence());
       
  1490     partialSmsTests->add(CreateParMSearcherIdxSequence());
       
  1491 
       
  1492     // TODO add more tests to suite
       
  1493         
       
  1494     return partialSmsTests;
       
  1495 }
       
  1496 
       
  1497