Created
July 26, 2012 15:27
-
-
Save dcolish/3182702 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/xapian-core/tests/api_db.cc b/xapian-core/tests/api_db.cc | |
| index 0fd1e70..30da24d 100644 | |
| --- a/xapian-core/tests/api_db.cc | |
| +++ b/xapian-core/tests/api_db.cc | |
| @@ -226,7 +226,7 @@ DEFINE_TESTCASE(stubdb6, inmemory) { | |
| return true; | |
| } | |
| -#if 0 // the "force error" mechanism is no longer in place... | |
| + | |
| class MyErrorHandler : public Xapian::ErrorHandler { | |
| public: | |
| int count; | |
| @@ -241,12 +241,41 @@ class MyErrorHandler : public Xapian::ErrorHandler { | |
| MyErrorHandler() : count (0) {} | |
| }; | |
| +class NeverUseMeKeyMaker : public Xapian::KeyMaker { | |
| + public: | |
| + std::string operator() (const Xapian::Document &) const | |
| + { | |
| + throw "NeverUseMeKeyMaker was called"; | |
| + } | |
| +}; | |
| + | |
| +DEFINE_TESTCASE(errorhandlercalled, remote) { | |
| + MyErrorHandler myhandler; | |
| + | |
| + Xapian::Database mydb2(get_remote_database("apitest_simpledata", 5000)); | |
| + Xapian::Database dbs; | |
| + dbs.add_database(mydb2); | |
| + | |
| + dbs.set_error_handler(&myhandler); | |
| + Xapian::Enquire enquire(dbs); | |
| + | |
| + enquire.set_query(Xapian::Query("word")); | |
| + NeverUseMeKeyMaker sorter; | |
| + | |
| + enquire.set_sort_by_key(&sorter, true); | |
| + Xapian::MSet mset = enquire.get_mset(0, 25); | |
| + TEST_EQUAL(myhandler.count, 2); | |
| + return true; | |
| +} | |
| + | |
| +#if 0 // the "force error" mechanism is no longer in place... | |
| // tests error handler in multimatch(). | |
| DEFINE_TESTCASE(multierrhandler1, backend) { | |
| MyErrorHandler myhandler; | |
| Xapian::Database mydb2(get_database("apitest_simpledata")); | |
| Xapian::Database mydb3(get_database("apitest_simpledata2")); | |
| + | |
| int errcount = 1; | |
| for (int testcount = 0; testcount < 14; testcount ++) { | |
| tout << "testcount=" << testcount << "\n"; | |
| @@ -332,7 +361,8 @@ DEFINE_TESTCASE(multierrhandler1, backend) { | |
| break; | |
| } | |
| tout << "db=" << dbs << "\n"; | |
| - Xapian::Enquire enquire(dbs, &myhandler); | |
| + dbs.set_error_handler(myhandler); | |
| + Xapian::Enquire enquire(dbs); | |
| // make a query | |
| Xapian::Query myquery = query(Xapian::Query::OP_OR, "inmemory", "word"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment