Ticket #299: test_valueweightsource5.patch

File test_valueweightsource5.patch, 1.1 KB (added by Olly Betts, 16 years ago)

Add test valueweightsource5

  • api_wrdb.cc

     
    22022202
    22032203    return true;
    22042204}
     2205
     2206// Check that valueweightsource handles last_docid of 0xffffffff.
     2207DEFINE_TESTCASE(valueweightsource5, writable && valuestats) {
     2208    // FIXME: PostingSource doesn't currently work well with multi databases
     2209    // but we should try to resolve that issue.
     2210    SKIP_TEST_FOR_BACKEND("multi");
     2211    // inmemory's memory use is currently O(last_docid)!
     2212    SKIP_TEST_FOR_BACKEND("inmemory");
     2213    Xapian::WritableDatabase db = get_writable_database();
     2214    Xapian::Document doc;
     2215    doc.add_value(1, Xapian::sortable_serialise(3.14));
     2216    db.replace_document(1, doc);
     2217    db.replace_document(0xffffffff, doc);
     2218    db.flush();
     2219
     2220    Xapian::ValueWeightPostingSource src(db, 1);
     2221    src.next(0.0);
     2222    TEST(!src.at_end());
     2223    TEST_EQUAL(src.get_docid(), 1);
     2224    src.next(0.0);
     2225    TEST(!src.at_end());
     2226    TEST_EQUAL(src.get_docid(), 0xffffffff);
     2227    src.next(0.0);
     2228    TEST(src.at_end());
     2229
     2230    return true;
     2231}