From: Sebastian B. <sb...@us...> - 2014-01-19 18:27:09
|
Update of /cvsroot/simplemail/simplemail/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21885/tests Modified Files: index_unittest.c Log Message: Refactored unit testing to have a core unit test. Index: index_unittest.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/tests/index_unittest.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- index_unittest.c 19 Jan 2014 18:26:27 -0000 1.6 +++ index_unittest.c 19 Jan 2014 18:27:07 -0000 1.7 @@ -40,16 +40,13 @@ CU_ASSERT(0); } -/*******************************************************/ - -/* @Test */ -void test_index_naive(void) +static void test_index_for_algorithm(struct index_algorithm *alg, const char *name) { struct index *index; int ok; int nd; - index = index_create(&index_naive,"naive-index.dat"); + index = index_create(alg, name); CU_ASSERT(index != NULL); ok = index_put_document(index,4,"This is a very long text."); @@ -73,29 +70,15 @@ /*******************************************************/ /* @Test */ -void test_index_external(void) +void test_index_naive(void) { - struct index *index; - int ok; - int nd; - - index = index_create(&index_external,"external-index.dat"); - CU_ASSERT(index != NULL); - - ok = index_put_document(index,4,"This is a very long text."); - CU_ASSERT(ok != 0); - - ok = index_put_document(index,12,"This is a short text."); - CU_ASSERT(ok != 0); - - nd = index_find_documents(index,test_index_naive_callback,NULL,1,"very"); - CU_ASSERT(nd == 1); - - ok = index_remove_document(index,4); - CU_ASSERT(ok != 0); + test_index_for_algorithm(&index_naive, "naive-index.dat"); +} - nd = index_find_documents(index,test_index_naive_callback2,NULL,1,"very"); - CU_ASSERT(nd == 0); +/*******************************************************/ - index_dispose(index); +/* @Test */ +void test_index_external(void) +{ + test_index_for_algorithm(&index_external, "external-index.dat"); } |