test-fts-filter.c revision 632d2181914a1ef7752495b9740df11dcc2112f5
/* Copyright (c) 2014-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "sha2.h"
#include "test-common.h"
#include "fts-language.h"
#include "fts-filter.h"
#include <stdio.h>
static void test_fts_filter_stopwords_eng(void)
{
const struct fts_filter *filter_class;
struct fts_filter *filter;
const char *error;
int ret;
"drive", "by", "for", "no", "reason",
const char *filtered;
test_begin("fts filter stopwords, English");
test_assert(ret == 0);
else {
}
op++;
ip++;
}
test_end();
}
static void test_fts_filter_stopwords_fin(void)
{
const struct fts_filter *filter_class;
struct fts_filter *filter;
const char *error;
int ret;
"kenest\xC3\xA4", "ja", "joista", "jonka",
"testi", NULL};
const char *input2[] =
const char *filtered;
test_begin("fts filter stopwords, Finnish");
test_assert(ret == 0);
else {
}
op++;
ip++;
}
test_assert(ret == 0);
else {
}
op++;
ip++;
}
test_end();
}
static void test_fts_filter_stopwords_fra(void)
{
const struct fts_filter *filter_class;
struct fts_filter *filter;
const char *error;
int ret;
"quelconque", "\xC3\xA9t\xC3\xA9",
"l\xE2\x80\x99""av\xC3\xA8nement",
NULL};
"quelconque", NULL,
"l\xE2\x80\x99""av\xC3\xA8nement",};
const char *filtered;
test_begin("fts filter stopwords, French");
test_assert(ret == 0);
else {
}
op++;
ip++;
}
test_end();
}
static void test_fts_filter_stopwords_fail_create(void)
{
const struct fts_filter *filter_class;
const char *error;
int ret;
test_begin("fts filter stopwords, fail create()");
test_end();
}
#ifdef HAVE_FTS_STEMMER
static void test_fts_filter_stemmer_snowball_stem_english(void)
{
int ret;
const struct fts_filter *filter_class;
struct fts_filter *stemmer;
const char *error;
const char * const tokens[] = {
"dries" ,"friendlies", "All", "human", "beings", "are",
"born", "free", "and", "equal", "in", "dignity", "and",
"rights", "They", "are", "endowed", "with", "reason", "and",
"conscience", "and", "should", "act", "towards", "one",
const char * const bases[] = {
"dri" ,"friend", "All", "human", "be", "are", "born", "free",
"and", "equal", "in", "digniti", "and", "right", "They", "are",
"endow", "with", "reason", "and", "conscienc", "and", "should",
"act", "toward", "one", "anoth", "in", "a", "spirit", "of",
"brotherhood", NULL};
const char * const *tpp;
const char * const *bpp;
test_begin("fts filter stem English");
test_assert(ret == 0);
bpp++;
}
test_end();
}
static void test_fts_filter_stemmer_snowball_stem_french(void)
{
int ret;
const struct fts_filter *filter_class;
struct fts_filter *stemmer;
const char *error;
const char * const tokens[] = {
"Tous", "les", "\xC3\xAAtres", "humains", "naissent",
"libres", "et", "\xC3\xA9gaux", "en", "dignit\xC3\xA9",
const char * const bases[] = {
"Tous" ,"le", "\xC3\xAAtre", "humain", "naissent", "libr", "et",
const char * const *tpp;
const char * const *bpp;
test_begin("fts filter stem French");
test_assert(ret == 0);
bpp++;
}
test_end();
}
static void test_fts_filter_stopwords_stemmer_eng(void)
{
int ret;
const struct fts_filter *filter_class;
struct fts_filter *stemmer;
struct fts_filter *filter;
const char *error;
const char * const tokens[] = {
"dries" ,"friendlies", "All", "human", "beings", "are",
"born", "free", "and", "equal", "in", "dignity", "and",
"rights", "They", "are", "endowed", "with", "reason", "and",
"conscience", "and", "should", "act", "towards", "one",
const char * const bases[] = {
"brotherhood", NULL};
const char * const *tpp;
const char * const *bpp;
test_begin("fts filters stopwords and stemming chained, English");
test_assert(ret == 0);
test_assert(ret == 0);
else {
}
bpp++;
}
test_end();
}
#endif
#ifdef HAVE_FTS_NORMALIZER
static void test_fts_filter_normalizer_swedish_short(void)
{
const struct fts_filter *filter_class;
int ret;
const char *input[] = {
NULL,
"",
"Vem",
"Å",
"ÅÄÖ",
"Vem kan segla f\xC3\xB6rutan vind?\n"
"\xC3\x85\xC3\x84\xC3\x96\xC3\xB6\xC3\xA4\xC3\xA5"
};
const char *expected_output[] = {
NULL,
"",
"vem",
"a",
"aao",
"vem kan segla forutan vind?\naaooaa"
};
const char * const settings[] =
const char *normalized = NULL;
unsigned int i;
test_begin("fts filter normalizer Swedish short text");
T_BEGIN {
test_assert(ret == 0);
for (i = 0; i < N_ELEMENTS(input); i++) {
}
}
} T_END;
test_end();
}
static void test_fts_filter_normalizer_swedish_short_default_id(void)
{
const struct fts_filter *filter_class;
int ret;
const char *input[] = {
NULL,
"",
"Vem",
"Å",
"ÅÄÖ",
"Vem kan segla f\xC3\xB6rutan vind?\n"
"\xC3\x85\xC3\x84\xC3\x96\xC3\xB6\xC3\xA4\xC3\xA5"
};
const char *expected_output[] = {
NULL,
"",
"vem",
"a",
"aao",
"vem kan segla forutan vind?\naaooaa"
};
const char *normalized = NULL;
unsigned int i;
test_begin("fts filter normalizer Swedish short text using default ID");
T_BEGIN {
test_assert(ret == 0);
for (i = 0; i < N_ELEMENTS(input); i++) {
}
}
} T_END;
test_end();
}
/* UDHRDIR comes from Automake AM_CPPFLAGS */
#define UDHR_FRA_NAME "/udhr_fra.txt"
static void test_fts_filter_normalizer_french(void)
{
const struct fts_filter *filter_class;
const char * const settings[] =
char buf[4096] = {0};
const char *normalized = NULL;
int ret;
unsigned char sha512_digest[SHA512_RESULTLEN];
struct sha512_ctx ctx;
const unsigned char correct_digest[] = {
0x78, 0x1e, 0xb9, 0x04, 0xa4, 0x92, 0xca, 0x88,
0x1e, 0xef, 0x7b, 0xc8, 0x3e, 0x4a, 0xa8, 0xdb,
0x9c, 0xd4, 0x42, 0x5c, 0x64, 0x81, 0x06, 0xd5,
0x72, 0x93, 0x38, 0x0c, 0x09, 0xce, 0xbe, 0xdf,
0x65, 0xff, 0x36, 0x35, 0x05, 0x77, 0xcc, 0xc6,
0xff, 0x44, 0x2c, 0x31, 0x10, 0x00, 0xf6, 0x8d,
0x15, 0x25, 0x1e, 0x54, 0x67, 0x2a, 0x5b, 0xc1,
0xdb, 0x84, 0xc5, 0x0d, 0x43, 0x7e, 0x8c, 0x70};
const char *udhr_path;
test_begin("fts filter normalizer French UDHR");
T_BEGIN {
test_assert(ret == 0);
sha512_init(&ctx);
break;
}
}
sizeof(sha512_digest)) == 0);
} T_END;
test_end();
}
static void test_fts_filter_normalizer_invalid_id(void)
{
const struct fts_filter *filter_class;
const char *settings[] =
{"id", "Any-One-Out-There; DKFN; [: Nonspacing Mark :] Remove",
NULL};
int ret;
test_begin("fts filter normalizer invalid id");
test_end();
}
static void test_fts_filter_normalizer_stopwords_stemmer_eng(void)
{
int ret;
const struct fts_filter *filter_class;
struct fts_filter *normalizer;
struct fts_filter *stemmer;
struct fts_filter *filter;
const char *error;
const char * const id_settings[] =
//{"id", "Any-Lower; NFKD; [: Nonspacing Mark :] Remove; NFC", NULL};
const char * const tokens[] = {
"dries" ,"friendlies", "All", "human", "beings", "are",
"born", "free", "and", "equal", "in", "dignity", "and",
"rights", "They", "are", "endowed", "with", "reason", "and",
"conscience", "and", "should", "act", "towards", "one",
"another", "in", "a", "spirit", "of", "brotherhood", "ABCFoo",
NULL};
const char * const bases[] = {
const char * const *tpp;
const char * const *bpp;
test_begin("fts filters normalizer, stopwords and stemming chained, English");
test_assert(ret == 0);
test_assert(ret == 0);
test_assert(ret == 0);
else {
}
bpp++;
}
test_end();
}
#endif
/* TODO: Functions to test 1. ref-unref pairs 2. multiple registers +
an unregister + find */
int main(void)
{
static void (*test_functions[])(void) = {
#ifdef HAVE_FTS_STEMMER
#endif
#ifdef HAVE_FTS_NORMALIZER
#endif
};
int ret;
return ret;
}