Changeset 8d89448795e517f0f1afd9bb633dc677fde09712
- Timestamp:
- 04/29/08 20:45:14 (8 months ago)
- Author:
- David Balmain <dbalmain@…>
- Parents:
- 2ac444617a25eb599de0faec801ffa532425f554
- Children:
- 76d73d55aa0ba896da711c5ed3d0e2b3e236ef3e
- git-committer:
- David Balmain <dbalmain@gmail.com> / 2008-04-29T20:45:14Z+1000
- Message:
-
Full gcov test coverage for TermQuery?
- Location:
- c
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r0c11a5
|
r8d8944
|
|
| 147 | 147 | TermQuery *tq = TQ(self->query); |
| 148 | 148 | TermDocEnum *tde = ir_term_docs_for(ir, tq->field, tq->term); |
| 149 | | if (!tde) { |
| 150 | | return NULL; |
| 151 | | } |
| | 149 | /* ir_term_docs_for should always return a TermDocEnum */ |
| | 150 | assert(NULL != tde); |
| 152 | 151 | |
| 153 | 152 | return tsc_new(self, tde, ir_get_norms(ir, tq->field)); |
-
|
r2ac444
|
r8d8944
|
|
| 168 | 168 | {"20051003", "word1 word3 one two", |
| 169 | 169 | "cat1/sub2", "3999"}, |
| 170 | | {"20051004", "word1 word2", |
| | 170 | /* we have 33 * "word2" below to cause cache miss in TermQuery */ |
| | 171 | {"20051004", "word1 word2 word2 word2 word2 word2 word2 word2 word2 " |
| | 172 | "word2 word2 word2 word2 word2 word2 word2 word2 word2 " |
| | 173 | "word2 word2 word2 word2 word2 word2 word2 word2 word2 " |
| | 174 | "word2 word2 word2 word2 word2 word2 word2", |
| 171 | 175 | "cat1/sub2/subsub2", "+.3413"}, |
| 172 | 176 | {"20051005", "word1 one two x x x x x one two", |
| … |
… |
|
| 331 | 335 | static void test_term_query(TestCase *tc, void *data) |
| 332 | 336 | { |
| | 337 | MatchVector *mv; |
| | 338 | HashSet *hs; |
| 333 | 339 | Searcher *searcher = (Searcher *)data; |
| 334 | 340 | TopDocs *top_docs; |
| | 341 | Weight *w; |
| | 342 | char *t, e[100]; |
| 335 | 343 | Query *tq = tq_new(field, "word2"); |
| 336 | 344 | check_to_s(tc, tq, field, "word2"); |
| … |
… |
|
| 340 | 348 | check_to_s(tc, tq, field, "word2^100.0"); |
| 341 | 349 | check_to_s(tc, tq, NULL, "field:word2^100.0"); |
| | 350 | |
| | 351 | /* test PhraseWeight.to_s */ |
| | 352 | w = searcher->create_weight(searcher, tq); |
| | 353 | sprintf(e, "TermWeight(%f)", w->value); |
| | 354 | t = w->to_s(w); Asnequal(e, t, 17); free(t); |
| | 355 | tq->boost = 10.5f; |
| | 356 | sprintf(e, "TermWeight(%f)", w->value); |
| | 357 | t = w->to_s(w); Asnequal(e, t, 17); free(t); |
| | 358 | w->destroy(w); |
| | 359 | |
| 342 | 360 | q_deref(tq); |
| 343 | 361 | |
| … |
… |
|
| 369 | 387 | Aiequal(SEARCH_DOCS_SIZE - 10, top_docs->size); |
| 370 | 388 | td_destroy(top_docs); |
| | 389 | q_deref(tq); |
| | 390 | |
| | 391 | tq = tq_new(field, "quick"); |
| | 392 | /* test get_matchv_i */ |
| | 393 | check_hits(tc, searcher, tq, "1,11,14,16,17", -1); |
| | 394 | mv = searcher_get_match_vector(searcher, tq, 1, field); |
| | 395 | if (Aiequal(2, mv->size)) { |
| | 396 | Aiequal(3, mv->matches[0].start); |
| | 397 | Aiequal(3, mv->matches[0].end); |
| | 398 | Aiequal(7, mv->matches[1].start); |
| | 399 | Aiequal(7, mv->matches[1].end); |
| | 400 | } |
| | 401 | matchv_destroy(mv); |
| | 402 | |
| | 403 | /* test extract_terms */ |
| | 404 | hs = hs_new((hash_ft)&term_hash, (eq_ft)&term_eq, (free_ft)&term_destroy); |
| | 405 | tq->extract_terms(tq, hs); |
| | 406 | Aiequal(1, hs->size); |
| | 407 | Asequal("quick", ((Term *)hs->first->elem)->text); |
| | 408 | Apequal(field, ((Term *)hs->first->elem)->field); |
| | 409 | hs_destroy(hs); |
| 371 | 410 | q_deref(tq); |
| 372 | 411 | } |