1 /*------------------------------------------------------------------------------
2 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
3 *
4 * Distributable under the terms of either the Apache License (Version 2.0) or
5 * the GNU Lesser General Public License, as specified in the COPYING file.
6 ------------------------------------------------------------------------------*/
7 #ifndef _lucene_search_QueryUtils
8 #define _lucene_search_QueryUtils
9 
10 #include "test.h"
11 
12 class QueryUtils
13 {
14 public:
15     static int32_t skip_op;
16     static int32_t next_op;
17     static float_t maxDiff;
18 
19 public:
20     /** Check the types of things query objects should be able to do. */
21     static void check( CuTest* tc, Query * q );
22 
23     /** check very basic hashCode and equals */
24     static void checkHashEquals( CuTest* tc, Query * q );
25     static void checkEqual( CuTest* tc, Query * q1, Query * q2 );
26     static void checkUnequal( CuTest* tc, Query * q1, Query * q2);
27 
28     /** deep check that explanations of a query 'score' correctly */
29     static void checkExplanations( CuTest* tc, Query * q, Searcher * s );
30 
31     /**
32      * various query sanity checks on a searcher, including explanation checks.
33      * @see #checkExplanations
34      * @see #checkSkipTo
35      * @see #check(Query)
36      */
37     static void check( CuTest* tc, Query * q1, Searcher * s );
38 
39     /** alternate scorer skipTo(),skipTo(),next(),next(),skipTo(),skipTo(), etc
40      * and ensure a hitcollector receives same docs and scores
41      */
42     static void checkSkipTo( CuTest* tc, Query * q, IndexSearcher * s );
43 
44 private:
45     /** check that the query weight is serializable.
46      * @throws IOException if serialization check fail.
47      */
48     static void checkSerialization( CuTest* tc, Query * q, Searcher * s );
49 
50     // check that first skip on just created scorers always goes to the right doc
51     static void checkFirstSkipTo( CuTest* tc, Query * q, IndexSearcher * s );
52 };
53 #endif
54 
55