51 static const char wordchars[] =
52 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789^\0";
54 tout <<
"Stemming random text... (seed " <<
seed <<
")\n";
60 char ch = wordchars[(rand() >> 8) %
sizeof wordchars];
65 stemmed_size +=
stemmer(word).length();
68 stemmed_size +=
stemmer(word).length();
69 tout <<
"Input size " <<
JUNKSIZE <<
", stemmed size " << stemmed_size
72 if (stemmed_size >
JUNKSIZE * 101 / 100) {
73 FAIL_TEST(
"Stemmed data is significantly bigger than input: " 74 << stemmed_size <<
" vs. " <<
JUNKSIZE);
77 FAIL_TEST(
"Stemmed data is significantly smaller than input: " 78 << stemmed_size <<
" vs. " <<
JUNKSIZE);
86 tout <<
"Stemming random junk... (seed " <<
seed <<
")\n";
92 char ch = char(rand() >> 8);
97 stemmed_size +=
stemmer(word).length();
100 stemmed_size +=
stemmer(word).length();
101 tout <<
"Input size " <<
JUNKSIZE <<
", stemmed size " << stemmed_size
104 if (stemmed_size >
JUNKSIZE * 101 / 100) {
105 FAIL_TEST(
"Stemmed data is significantly bigger than input (" 106 << stemmed_size <<
" vs. " <<
JUNKSIZE);
109 FAIL_TEST(
"Stemmed data is significantly smaller than input (" 110 << stemmed_size <<
" vs. " <<
JUNKSIZE);
117 string dir =
srcdir +
"/../../xapian-data/stemming/";
119 ifstream voc((dir +
language +
"/voc.txt").c_str());
120 if (!voc.is_open()) {
124 ifstream st((dir +
language +
"/output.txt").c_str());
130 tout <<
"Testing " <<
language <<
" with Snowball dictionary...\n";
134 string word, stem, expect;
135 while (!voc.eof() && !st.eof()) {
146 if (pass == 2)
break;
148 voc.open((dir + language +
"/voc2.txt").c_str());
149 if (!voc.is_open())
break;
151 st.open((dir + language +
"/output2.txt").c_str());
154 FAIL_TEST(language <<
"/output2.txt not found");
156 tout <<
"Testing " << language <<
" with supplemental dictionary...\n";
173 int main(
int argc,
char **argv)
186 if (!seed_str.empty())
seed = atoi(seed_str.c_str());
187 cout <<
"The random seed is " <<
seed <<
'\n';
188 cout <<
"Please report the seed when reporting a test failure.\n";
190 string::size_type b = 0;
191 while (b != langs.size()) {
192 string::size_type a = b;
193 while (b < langs.size() && langs[b] !=
' ') ++b;
195 while (b < langs.size() && langs[b] ==
' ') ++b;
196 cout <<
"Running tests with " <<
language <<
" stemmer...\n";
201 }
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.