30 #include "itk.h" |
30 #include "itk.h" |
31 #include "cpixidxdb.h" |
31 #include "cpixidxdb.h" |
32 #include "cpixdoc.h" |
32 #include "cpixdoc.h" |
33 #include "cpixsearch.h" |
33 #include "cpixsearch.h" |
34 #include "cpixidxdb.h" |
34 #include "cpixidxdb.h" |
|
35 #include "std_log_result.h" |
35 |
36 |
36 #define TEST_DOCUMENT_QBASEAPPCLASS "@0:root test document" |
37 #define TEST_DOCUMENT_QBASEAPPCLASS "@0:root test document" |
37 #define TEST_SAMPLE_QBASEAPPCLASS "@:root test sample" |
38 #define TEST_SAMPLE_QBASEAPPCLASS "@:root test sample" |
38 #define TEST_CORRUPTTEST1_QBASEAPPCLASS "@:root test corrupttest1" |
39 #define TEST_CORRUPTTEST1_QBASEAPPCLASS "@:root test corrupttest1" |
39 #define TEST_CORRUPTTEST2_QBASEAPPCLASS "@:root test corrupttest2" |
40 #define TEST_CORRUPTTEST2_QBASEAPPCLASS "@:root test corrupttest2" |
268 |
269 |
269 } |
270 } |
270 |
271 |
271 void testCreateDb(Itk::TestMgr* /*testMgr */) |
272 void testCreateDb(Itk::TestMgr* /*testMgr */) |
272 { |
273 { |
|
274 char *xml_file = (char *)__FUNCTION__; |
|
275 assert_failed = 0; |
273 cpix_IdxDb *itestDb_ = NULL, *inewDb_ = NULL; |
276 cpix_IdxDb *itestDb_ = NULL, *inewDb_ = NULL; |
274 cpix_Result result; |
277 cpix_Result result; |
275 |
278 |
276 testInit(&itestDb_, cpix_IDX_CREATE, |
279 testInit(&itestDb_, cpix_IDX_CREATE, |
277 TEST_SAMPLE_QBASEAPPCLASS, TEST_SAMPLE_INDEXDB_PATH); |
280 TEST_SAMPLE_QBASEAPPCLASS, TEST_SAMPLE_INDEXDB_PATH); |
298 { |
302 { |
299 cpix_IdxDb_releaseDb(inewDb_); |
303 cpix_IdxDb_releaseDb(inewDb_); |
300 inewDb_ = 0; |
304 inewDb_ = 0; |
301 } |
305 } |
302 cpix_IdxDb_undefineVolume(TEST_SAMPLE_QBASEAPPCLASS); |
306 cpix_IdxDb_undefineVolume(TEST_SAMPLE_QBASEAPPCLASS); |
|
307 testResultXml(xml_file); |
303 } |
308 } |
304 |
309 |
305 void testOpenDb(Itk::TestMgr * testMgr) |
310 void testOpenDb(Itk::TestMgr * testMgr) |
306 { |
311 { |
|
312 char *xml_file = (char *)__FUNCTION__; |
|
313 assert_failed = 0; |
307 cpix_Result result; |
314 cpix_Result result; |
308 cpix_IdxDb *idxDb_ = NULL; |
315 cpix_IdxDb *idxDb_ = NULL; |
309 |
316 |
310 //try to open a Db an of undefined volume |
317 //try to open a Db an of undefined volume |
311 idxDb_ = cpix_IdxDb_openDb(&result, |
318 idxDb_ = cpix_IdxDb_openDb(&result, |
312 "@0:root test1", |
319 "@0:root test1", |
313 cpix_IDX_CREATE); |
320 cpix_IDX_CREATE); |
314 if(idxDb_ == NULL ) |
321 if(idxDb_ == NULL ) |
315 { |
322 { |
316 ITK_MSG(testMgr, "Tried to open a database of undefined volume"); |
323 ITK_MSG(testMgr, "Tried to open a database of undefined volume"); |
|
324 assert_failed = 1; |
317 } |
325 } |
318 |
326 |
319 if (idxDb_) |
327 if (idxDb_) |
320 { |
328 { |
321 cpix_IdxDb_releaseDb(idxDb_); |
329 cpix_IdxDb_releaseDb(idxDb_); |
322 idxDb_ = 0; |
330 idxDb_ = 0; |
323 } |
331 } |
|
332 testResultXml(xml_file); |
324 } |
333 } |
325 |
334 |
326 void testCorruptedIndex(Itk::TestMgr * testMgr) |
335 void testCorruptedIndex(Itk::TestMgr * testMgr) |
327 { |
336 { |
|
337 char *xml_file = (char *)__FUNCTION__; |
|
338 assert_failed = 0; |
328 cpix_Analyzer * analyzer_ = NULL ; |
339 cpix_Analyzer * analyzer_ = NULL ; |
329 cpix_IdxDb * iCrptDb1_ = NULL, *iCrptDb2_ = NULL; |
340 cpix_IdxDb * iCrptDb1_ = NULL, *iCrptDb2_ = NULL; |
330 |
341 |
331 CreateAnalyser(testMgr, |
342 CreateAnalyser(testMgr, |
332 &analyzer_); |
343 &analyzer_); |
368 TEST_CORRUPTTEST2_INDEXDB_PATH); |
379 TEST_CORRUPTTEST2_INDEXDB_PATH); |
369 int hit_search2=0; |
380 int hit_search2=0; |
370 if(iCrptDb2_) |
381 if(iCrptDb2_) |
371 hit_search2= search(&analyzer_,&iCrptDb2_, SEARCH_TERM); |
382 hit_search2= search(&analyzer_,&iCrptDb2_, SEARCH_TERM); |
372 else |
383 else |
373 ITK_MSG(testMgr, "Corrupted database, search not possible"); |
384 { |
|
385 ITK_MSG(testMgr, "Corrupted database, search not possible"); |
|
386 assert_failed = 0; |
|
387 } |
374 |
388 |
375 cleanUp(&analyzer_,&iCrptDb1_); |
389 cleanUp(&analyzer_,&iCrptDb1_); |
376 |
390 |
377 if(iCrptDb2_) |
391 if(iCrptDb2_) |
378 { |
392 { |