1 /* api_snipper.cc: tests Snipper class
3 * Copyright 2012 Mihai Bivol
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 #include "api_snipper.h"
28 #include "backendmanager_local.h"
29 #include "testsuite.h"
30 #include "testutils.h"
38 // tests that the number of indexed documents is the size of the one set
39 DEFINE_TESTCASE(snipper1
, backend
) {
40 Xapian::Enquire
enquire(get_database("apitest_simpledata"));
41 enquire
.set_query(Xapian::Query("this"));
42 Xapian::MSet mymset
= enquire
.get_mset(0, 10);
44 // MSet size should be 6.
45 TEST_MSET_SIZE(mymset
, 6);
47 Xapian::Snipper snipper
;
48 snipper
.set_mset(mymset
, 4);
49 TEST(snipper
.get_description().find("rm_doccount=4,") != string::npos
);
53 // tests that the relevance model is reset when setting another mset
54 DEFINE_TESTCASE(snipper2
, backend
) {
55 Xapian::Enquire
enquire(get_database("apitest_simpledata"));
56 enquire
.set_query(Xapian::Query("this"));
57 Xapian::MSet mymset1
= enquire
.get_mset(0, 10);
59 enquire
.set_query(Xapian::Query("word"));
60 Xapian::MSet mymset2
= enquire
.get_mset(0, 10);
62 // MSet sizes for the two queries should be 6 and 2.
63 TEST_MSET_SIZE(mymset1
, 6);
64 TEST_MSET_SIZE(mymset2
, 2);
66 Xapian::Snipper snipper
;
67 snipper
.set_mset(mymset1
);
68 // Should add to relevance model 6 documents.
69 TEST(snipper
.get_description().find("rm_doccount=6,") != string::npos
);
71 snipper
.set_mset(mymset2
);
72 // Should add to relevance model 2 documents.
73 TEST(snipper
.get_description().find("rm_doccount=2,") != string::npos
);