Ticket #109: flint-missing-base-test.patch

File flint-missing-base-test.patch, 1.7 KB (added by Olly Betts, 17 years ago)

Port of reproducing example to C++

  • tests/api_wrdb.cc

     
    11391139    return true;
    11401140}
    11411141
     1142#define path "foo1"
     1143#define base_extn ".baseB"
     1144static bool test_foo1()
     1145{
     1146    Xapian::WritableDatabase db(path, Xapian::DB_CREATE_OR_OVERWRITE);
     1147    Xapian::Document doc;
     1148    // Xapian::Database has full set of baseA, no baseB
     1149
     1150    db.add_document(doc);
     1151    db.flush();
     1152
     1153    // Xapian::Database has full set of baseB, old baseA
     1154
     1155    db.add_document(doc);
     1156    db.flush();
     1157
     1158    // Xapian::Database has full set of baseA, old baseB
     1159    Xapian::Database dbr(path);
     1160    cout << dbr.get_doccount() << endl;
     1161
     1162    // Simulate a transaction starting, some of the baseB getting removed,
     1163    // but then the transaction fails.
     1164    unlink(string(path) + "/record" + base_extn);
     1165    unlink(string(path) + "/term_list" + base_extn);
     1166
     1167    // Xapian::Database has full set of baseA, some old baseB
     1168    dbr = Xapian::Database(path);
     1169    cout << dbr.get_doccount() << endl;
     1170
     1171    db.add_document(doc);
     1172    db.flush();
     1173
     1174    // Xapian::Database has full set of baseB, old baseA
     1175
     1176    dbr = Xapian::Database(path);
     1177    cout << dbr.get_doccount() << endl;
     1178
     1179    db.add_document(doc);
     1180    db.flush();
     1181
     1182    dbr = Xapian::Database(path);
     1183    cout << dbr.get_doccount() << endl;
     1184
     1185    return true;
     1186}
     1187
    11421188// #######################################################################
    11431189// # End of test cases: now we list the tests to run.
    11441190
     
    11641210    {"phraseorneartoand1", test_phraseorneartoand1},
    11651211    {"longpositionlist1",  test_longpositionlist1},
    11661212    {"allpostlist2",       test_allpostlist2},
     1213    {"foo1",               test_foo1},
    11671214    {0, 0}
    11681215};