Ticket #28: diffs

File diffs, 1.3 KB (added by Richard Boulton, 21 years ago)

Testcase (patch to api_db.cc)

Line 
1Index: api_db.cc
2===================================================================
3RCS file: /home/cvs/xapian/xapian-core/tests/api_db.cc,v
4retrieving revision 1.168
5diff -u -r1.168 api_db.cc
6--- api_db.cc 9 Mar 2004 19:06:20 -0000 1.168
7+++ api_db.cc 27 Apr 2004 08:47:13 -0000
8@@ -1414,6 +1414,22 @@
9 return true;
10 }
11
12+// regression test for bug with iterating through an mset - bug caused
13+// an access to uninitialised memory when iteration through partial mset
14+// reached end. (This test only reliably fails when run under valgrind.)
15+static bool test_partialmset1()
16+{
17+ Xapian::Query myquery = query(Xapian::Query::OP_OR, "this", "word");
18+ Xapian::MSet mymset = do_get_simple_query_mset(myquery, 10, 1);
19+
20+ Xapian::MSetIterator it;
21+ for (it = mymset.begin(); it != mymset.end(); it++) {
22+ TEST_NOT_EQUAL(it.get_document().get_data(), "");
23+ }
24+
25+ return true;
26+}
27+
28 // test that prefetching documents works (at least, gives same results)
29 static bool test_fetchdocs1()
30 {
31@@ -3255,6 +3271,7 @@
32 {"poscollapse1", test_poscollapse1},
33 {"poscollapse2", test_poscollapse2},
34 {"repeatquery1", test_repeatquery1},
35+ {"partialmset1", test_partialmset1},
36 {"fetchdocs1", test_fetchdocs1},
37 {"absentterm1", test_absentterm1},
38 {"absentterm2", test_absentterm2},