52 static const char wordchars[] =
53 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789^\0";
55 tout <<
"Stemming random text... (seed " <<
seed <<
")\n";
61 char ch = wordchars[(rand() >> 8) %
sizeof wordchars];
66 stemmed_size +=
stemmer(word).length();
69 stemmed_size +=
stemmer(word).length();
70 tout <<
"Input size " <<
JUNKSIZE <<
", stemmed size " << stemmed_size
73 if (stemmed_size >
JUNKSIZE * 101 / 100) {
74 FAIL_TEST(
"Stemmed data is significantly bigger than input: " 75 << stemmed_size <<
" vs. " <<
JUNKSIZE);
78 FAIL_TEST(
"Stemmed data is significantly smaller than input: " 79 << stemmed_size <<
" vs. " <<
JUNKSIZE);
87 tout <<
"Stemming random junk... (seed " <<
seed <<
")\n";
93 char ch = char(rand() >> 8);
98 stemmed_size +=
stemmer(word).length();
101 stemmed_size +=
stemmer(word).length();
102 tout <<
"Input size " <<
JUNKSIZE <<
", stemmed size " << stemmed_size
105 if (stemmed_size >
JUNKSIZE * 101 / 100) {
106 FAIL_TEST(
"Stemmed data is significantly bigger than input (" 107 << stemmed_size <<
" vs. " <<
JUNKSIZE);
110 FAIL_TEST(
"Stemmed data is significantly smaller than input (" 111 << stemmed_size <<
" vs. " <<
JUNKSIZE);
118 string dir =
srcdir +
"/../../xapian-data/stemming/";
120 gzFile voc = gzopen((dir +
language +
"/voc.txt").c_str(),
"rb");
122 voc = gzopen((dir +
language +
"/voc.txt.gz").c_str(),
"rb");
128 gzFile st = gzopen((dir +
language +
"/output.txt").c_str(),
"rb");
130 st = gzopen((dir +
language +
"/output.txt.gz").c_str(),
"rb");
137 tout <<
"Testing " <<
language <<
" with Snowball dictionary...\n";
142 while (!gzeof(voc) && !gzeof(st)) {
145 int ch = gzgetc(voc);
146 if (ch == EOF || ch ==
'\n')
break;
153 if (ch == EOF || ch ==
'\n')
break;
164 if (pass == 2)
break;
166 voc = gzopen((dir + language +
"/voc2.txt").c_str(),
"rb");
169 st = gzopen((dir + language +
"/output2.txt").c_str(),
"rb");
172 FAIL_TEST(language <<
"/output2.txt not found");
174 tout <<
"Testing " << language <<
" with supplemental dictionary...\n";
191 int main(
int argc,
char **argv)
204 if (!seed_str.empty())
seed = atoi(seed_str.c_str());
205 cout <<
"The random seed is " <<
seed <<
'\n';
206 cout <<
"Please report the seed when reporting a test failure.\n";
208 string::size_type b = 0;
209 while (b != langs.size()) {
210 string::size_type a = b;
211 while (b < langs.size() && langs[b] !=
' ') ++b;
213 while (b < langs.size() && langs[b] ==
' ') ++b;
214 cout <<
"Running tests with " <<
language <<
" stemmer...\n";
219 }
catch (
const char * e) {
static const int JUNKSIZE
static void test_stemrandom()
static const test_desc tests[]
The lists of tests to perform.
static void parse_command_line(int argc, char **argv)
Parse the command line arguments.
Class representing a stemming algorithm.
static void test_stemjunk()
a generic test suite engine
static Xapian::Stem stemmer
static std::string get_srcdir()
Read srcdir from environment and if not present, make a valiant attempt to guess a value...
static void add_command_line_option(const std::string &l, char s, std::string *arg)
Add a test-specific command line option.
static void test_stemdict()
std::ostringstream tout
The debug printing stream.
Public interfaces for the Xapian library.
static std::string get_available_languages()
Return a list of available languages.
int main(int argc, char **argv)
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
#define SKIP_TEST(MSG)
Skip the current testcase with message MSG.
static int run(const test_desc *tests)
Structure holding a description of a test.
#define TEST_EQUAL(a, b)
Test for equality of two things.