Exemple #1
0
// Technically, this should produce an acceptably small result set, but it's
// too difficult to prune -- so QParser_Prune just lops it because it's a
// top-level NOTQuery.
static TestQueryParser*
logical_test_nested_negations(uint32_t boolop) {
    Query *query = make_leaf_query(NULL, "a");
    query = make_poly_query(boolop, query, NULL);
    query = make_not_query(query);
    query = make_poly_query(BOOLOP_AND, query, NULL);
    query = make_not_query(query);
    return TestQP_new("-(-(a))", query, NULL, 0);
}
Exemple #2
0
static TestQueryParser*
prune_test_not_and_not() {
    Query   *a_leaf  = make_leaf_query(NULL, "a");
    Query   *b_leaf  = make_leaf_query(NULL, "b");
    Query   *not_a   = make_not_query(a_leaf);
    Query   *not_b   = make_not_query(b_leaf);
    Query   *tree    = make_poly_query(BOOLOP_AND, not_a, not_b, NULL);
    Query   *pruned  = make_poly_query(BOOLOP_AND, NULL);
    return TestQP_new(NULL, tree, pruned, 0);
}
static TestQueryParser*
syntax_test_minus_plus()
{
    Query *leaf = make_leaf_query(NULL, "a");
    Query *tree = make_not_query(leaf);
    return TestQP_new("-+a", tree, NULL, 0);
}
Exemple #4
0
static TestQueryParser*
logical_test_triple_negative(uint32_t boolop) {
    Query   *leaf   = make_leaf_query(NULL, "a");
    Query   *tree   = make_not_query(leaf);
    UNUSED_VAR(boolop);
    return TestQP_new("---a", tree, NULL, 0);
}
Exemple #5
0
static TestQueryParser*
logical_test_pure_negation(uint32_t boolop) {
    Query   *leaf   = make_leaf_query(NULL, "x");
    Query   *tree   = make_not_query(leaf);
    UNUSED_VAR(boolop);
    return TestQP_new("-x", tree, NULL, 0);
}
Exemple #6
0
static TestQueryParser*
syntax_test_not_plus() {
    // Not a perfect result, but then it's not a good query string.
    Query *leaf = make_leaf_query(NULL, "a");
    Query *tree = make_not_query(leaf);
    return TestQP_new("NOT +a", tree, NULL, 0);
}
Exemple #7
0
static TestQueryParser*
logical_test_required_phrase_negated_term(uint32_t boolop) {
    Query *bc_query   = make_leaf_query(NULL, "\"b c\"");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *not_d      = make_not_query(d_query);
    Query *tree       = make_poly_query(BOOLOP_AND, bc_query, not_d, NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("+\"b c\" -d", tree, NULL, 1);
}
Exemple #8
0
static TestQueryParser*
logical_test_and_not(uint32_t boolop) {
    Query   *a_query = make_leaf_query(NULL, "a");
    Query   *b_query = make_leaf_query(NULL, "b");
    Query   *not_b   = make_not_query(b_query);
    Query   *tree    = make_poly_query(BOOLOP_AND, a_query, not_b, NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a AND NOT b", tree, NULL, 1);
}
Exemple #9
0
static TestQueryParser*
prune_test_optional_not() {
    Query   *a_leaf  = make_leaf_query(NULL, "a");
    Query   *b_leaf  = make_leaf_query(NULL, "b");
    Query   *not_b   = make_not_query(b_leaf);
    Query   *tree    = make_poly_query(BOOLOP_OR, (Query*)INCREF(a_leaf),
                                       not_b, NULL);
    Query   *nomatch = (Query*)NoMatchQuery_new();
    Query   *pruned  = make_poly_query(BOOLOP_OR, a_leaf, nomatch, NULL);
    return TestQP_new(NULL, tree, pruned, 4);
}
Exemple #10
0
static TestQueryParser*
logical_test_and_not_nested_or(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *nested     = make_poly_query(BOOLOP_OR, b_query, c_query, NULL);
    Query *not_nested = make_not_query(nested);
    Query *tree       = make_poly_query(BOOLOP_AND, a_query,
                                        not_nested, NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a AND NOT (b OR c)", tree, NULL, 1);
}
Exemple #11
0
static TestQueryParser*
prune_test_reqopt_required_not() {
    Query   *a_leaf  = make_leaf_query(NULL, "a");
    Query   *b_leaf  = make_leaf_query(NULL, "b");
    Query   *not_a   = make_not_query(a_leaf);
    Query   *tree    = (Query*)ReqOptQuery_new(not_a, b_leaf);
    Query   *nomatch = (Query*)NoMatchQuery_new();
    Query   *pruned  = (Query*)ReqOptQuery_new(nomatch, b_leaf);
    DECREF(nomatch);
    DECREF(not_a);
    DECREF(b_leaf);
    return TestQP_new(NULL, tree, pruned, 0);
}
Exemple #12
0
static TestQueryParser*
prune_test_reqopt_optional_not() {
    Query   *a_leaf  = make_leaf_query(NULL, "a");
    Query   *b_leaf  = make_leaf_query(NULL, "b");
    Query   *not_b   = make_not_query(b_leaf);
    Query   *tree    = (Query*)ReqOptQuery_new(a_leaf, not_b);
    Query   *nomatch = (Query*)NoMatchQuery_new();
    Query   *pruned  = (Query*)ReqOptQuery_new(a_leaf, nomatch);
    DECREF(nomatch);
    DECREF(not_b);
    DECREF(a_leaf);
    return TestQP_new(NULL, tree, pruned, 4);
}
Exemple #13
0
static TestQueryParser*
logical_test_nested_nest(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *innermost  = make_poly_query(BOOLOP_AND, c_query, d_query, NULL);
    Query *inner      = make_poly_query(BOOLOP_OR, b_query, innermost, NULL);
    Query *not_inner  = make_not_query(inner);
    Query *tree       = make_poly_query(BOOLOP_AND, a_query, not_inner, NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a AND NOT (b OR (c AND d))", tree, NULL, 1);
}