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.
21
#include "xesam2strigitest.h"
22
#include "xesam2strigi.h"
32
using namespace strigiunittest;
34
// Registers the fixture into the 'registry'
35
CPPUNIT_TEST_SUITE_REGISTRATION( Xesam2StrigiTest );
37
void Xesam2StrigiTest::setUp() {
39
m_ulQueries.insert ("type:image size>=1mb tag:flower africa");
41
m_ulQueries.insert ("type:image size>=1mb tag:flower south africa");
43
m_ulQueries.insert ("type:image size>=1mb tag:flower south africa");
45
m_ulQueries.insert ("\"hello world, how are you?\"cle");
47
m_ulQueries.insert ("\"hello world, how are you?\"CL fine thanks");
49
m_ulQueries.insert ("+ \"hello world, how are you?\"cS and fine thanks");
51
m_ulQueries.insert ("type:music hendrix");
53
m_ulQueries.insert ("type:music creator=\"James Marshall Hendrix\"");
55
m_ulQueries.insert ("-type:music hendrix");
57
xesam2strigi = new Xesam2Strigi();
60
void Xesam2StrigiTest::tearDown()
67
void Xesam2StrigiTest::parseUlFromString()
69
for (set<string>::iterator iter = m_ulQueries.begin();
70
iter != m_ulQueries.end(); iter++)
72
if (!xesam2strigi->parse (*iter, Xesam2Strigi::UserLanguage)) {
73
string msg = "Failed to parse xesam userlanguage query: |";
75
msg += "| from string";
81
void Xesam2StrigiTest::parseUlFromFile()
83
// create a temporary file
87
// generate index dir name
88
strcpy(filename, "strigiXXXXXX");
90
if (mkstemp(filename) == -1) {
91
printf ("Error creating temporary file because of: ");
92
printf ("%s\n", strerror (errno));
96
printf ("created temporary file: %s\n", filename);
98
for (set<string>::iterator iter = m_ulQueries.begin();
99
iter != m_ulQueries.end(); iter++)
105
if (!xesam2strigi->parse_file (filename, Xesam2Strigi::UserLanguage)) {
106
string msg = "Failed to parse xesam userlanguage query: |";
108
msg += "| from file";
113
if (unlink(filename) == -1) {
114
fprintf(stderr, "unable to delete temporary file %s because of: ",
116
printf ("%s\n", strerror (errno));