1
/* This file is part of Strigi Desktop Search
3
* Copyright (C) 2007 Flavio Castelli <flavio.castelli@gmail.com>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library 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 GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public License
16
* along with this library; see the file COPYING.LIB. If not, write to
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
20
#include "indexreadertester.h"
22
#include "analysisresult.h"
23
#include "indexwriter.h"
24
#include "indexreader.h"
25
#include "fieldtypes.h"
27
#include "queryparser.h"
33
using namespace strigiunittest;
34
using namespace Strigi;
37
IndexReaderTest::setUp() {
39
m_streamAnalyzer = new Strigi::StreamAnalyzer( m_analyzerConfiguration );
43
IndexReaderTest::tearDown() {
44
delete m_streamAnalyzer;
45
IndexTest::tearDown();
49
IndexReaderTest::testChildrenRetrieval() {
54
IndexReaderTest::addAndCount() {
55
static const int m = 20;
57
m_writer->deleteAllEntries();
59
for (int i=0; i<m; ++i) {
62
{ AnalysisResult idx(s, 0, *m_writer, *m_streamAnalyzer); }
67
int n = m_reader->countDocuments();
70
CPPUNIT_ASSERT_EQUAL_MESSAGE(str.str(), m, n);
74
IndexReaderTest::testNumberQuery() {
75
m_writer->deleteAllEntries();
76
// add numbers to the database
79
for (int i=1; i<=m; ++i) {
81
string value(str.str());
82
string name('/'+value);
84
AnalysisResult idx(name, 0, *m_writer, *m_streamAnalyzer);
85
idx.addValue(idx.config().fieldRegister().sizeField, value);
91
Query q = parser.buildQuery("contentSize>0");
92
int count = m_reader->countHits(q);
95
CPPUNIT_ASSERT_EQUAL_MESSAGE(str.str(), m, count);