Author: rooneg
Date: Wed Mar  2 19:55:29 2005
New Revision: 156005

URL: http://svn.apache.org/viewcvs?view=rev&rev=156005
Log:
Hey, lets actually return an error when we can't find the document...

* src/index/index.c
  (lcn_index_term_docs): check to see if we never found the doc, and
   return an error in that case.

* test/index/index_test.c
  (test_index_term_docs_notfound): new test.
  (test_index): run new test.

Modified:
    incubator/lucene4c/trunk/src/index/index.c
    incubator/lucene4c/trunk/test/index/index_test.c

Modified: incubator/lucene4c/trunk/src/index/index.c
URL: 
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/index/index.c?view=diff&r1=156004&r2=156005
==============================================================================
--- incubator/lucene4c/trunk/src/index/index.c (original)
+++ incubator/lucene4c/trunk/src/index/index.c Wed Mar  2 19:55:29 2005
@@ -168,6 +168,12 @@
         break;
     }
 
+  if (itr->cur_seg >= itr->num_segs)
+    {
+      *i = NULL;
+      return lcn_error_create (APR_ENOENT, NULL, "term not found");
+    }
+
   *i = itr;
 
   return LCN_NO_ERROR;

Modified: incubator/lucene4c/trunk/test/index/index_test.c
URL: 
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/test/index/index_test.c?view=diff&r1=156004&r2=156005
==============================================================================
--- incubator/lucene4c/trunk/test/index/index_test.c (original)
+++ incubator/lucene4c/trunk/test/index/index_test.c Wed Mar  2 19:55:29 2005
@@ -168,6 +168,26 @@
   apr_pool_clear (p);
 }
 
+static void
+test_index_term_docs_notfound (abts_case *tc, void *data)
+{
+  lcn_term_t *term = lcn_term_create_cstring ("a", "contents", p);
+  lcn_doc_iter_t *itr;
+  lcn_index_t *idx;
+  lcn_error_t *err;
+
+  CHK_ERR (lcn_index_open (&idx, "test/data/index", p));
+
+  err = lcn_index_term_docs (&itr, idx, term, p);
+
+  ABTS_PTR_NOTNULL (tc, err);
+
+  ABTS_INT_EQUAL (tc, err->apr_err, APR_ENOENT);
+
+  apr_pool_clear (p);
+}
+
+
 static const char *path
   = "/Users/rooneg/Hacking/lucene4c/jakarta-lucene/src/demo/CVS/Repository";
 
@@ -261,6 +281,7 @@
   abts_run_test (suite, test_index_term_docs, NULL);
   abts_run_test (suite, test_index_term_docs_cfs, NULL);
   abts_run_test (suite, test_index_term_docs_unopt, NULL);
+  abts_run_test (suite, test_index_term_docs_notfound, NULL);
   abts_run_test (suite, test_index_get_document, NULL);
   abts_run_test (suite, test_index_get_document_unopt, NULL);
 


Reply via email to