Ticket #216: bug216-testcase.patch

File bug216-testcase.patch, 2.4 KB (added by Olly Betts, 15 years ago)

Updated testcase patch for current SVN trunk

  • tests/api_percentages.cc

     
    3232
    3333using namespace std;
    3434
     35// Test that percentages reported are the same regardless of which part of the
     36// mset is returned, for sort-by-value search.  Regression test for a bug in
     37// 1.0.9 and earlier with returned percentages.
     38DEFINE_TESTCASE(consistency3, backend) {
     39    Xapian::Database db(get_database("apitest_sortconsist"));
     40    Xapian::Enquire enquire(db);
     41    enquire.set_query(Xapian::Query("foo"));
     42    enquire.set_sort_by_value(1, 0);
     43    Xapian::doccount lots = 3;
     44    Xapian::MSet bigmset = enquire.get_mset(0, lots);
     45    TEST_EQUAL(bigmset.size(), lots);
     46    for (Xapian::doccount start = 0; start < lots; ++start) {
     47        tout << *bigmset[start] << ":" << bigmset[start].get_weight() << ":"
     48             << bigmset[start].get_percent() << "%" << endl;
     49        for (Xapian::doccount size = 0; size < lots - start; ++size) {
     50            Xapian::MSet mset = enquire.get_mset(start, size);
     51            if (mset.size()) {
     52                TEST_EQUAL(start + mset.size(),
     53                           min(start + size, bigmset.size()));
     54            } else if (size) {
     55                TEST(start >= bigmset.size());
     56            }
     57            for (Xapian::doccount i = 0; i < mset.size(); ++i) {
     58                TEST_EQUAL(*mset[i], *bigmset[start + i]);
     59                TEST_EQUAL_DOUBLE(mset[i].get_weight(),
     60                                  bigmset[start + i].get_weight());
     61                TEST_EQUAL_DOUBLE(mset[i].get_percent(),
     62                                  bigmset[start + i].get_percent());
     63            }
     64        }
     65    }
     66    return true;
     67}
     68
    3569class MyPostingSource : public Xapian::PostingSource {
    3670    std::vector<std::pair<Xapian::docid, Xapian::weight> > weights;
    3771    std::vector<std::pair<Xapian::docid, Xapian::weight> >::const_iterator i;
  • tests/testdata/apitest_sortconsist.txt

     
     1A foo
     2
     3A foo
     4
     5B foo foo
  • tests/Makefile.am

     
    178178        testdata/apitest_allterms4.txt \
    179179        testdata/apitest_poslist.txt \
    180180        testdata/apitest_manydocs.txt \
     181        testdata/apitest_sortconsist.txt \
    181182        testdata/apitest_sortrel.txt \
    182183        testdata/etext.txt \
    183184        testdata/flint-0.9.9/flicklock \