[tracker] libtracker-common: Move and fix tracker-parser unit tests from libtracker-fts
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-common: Move and fix tracker-parser unit tests from libtracker-fts
- Date: Wed, 3 Dec 2014 11:31:52 +0000 (UTC)
commit 8d14867631b59ecdfadcd77ac407f19fc15ba4d8
Author: Martyn Russell <martyn lanedo com>
Date: Wed Dec 3 10:31:18 2014 +0000
libtracker-common: Move and fix tracker-parser unit tests from libtracker-fts
src/libtracker-common/tracker-common.h | 1 +
src/libtracker-common/tracker-parser-utils.h | 6 ++--
src/libtracker-common/tracker-parser.h | 6 ++--
tests/libtracker-common/Makefile.am | 9 ++++++-
.../tracker-parser-test.c | 0
.../tracker-parser.c | 24 ++++++++++---------
tests/libtracker-fts/Makefile.am | 10 +-------
7 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/src/libtracker-common/tracker-common.h b/src/libtracker-common/tracker-common.h
index 60c556b..1af7393 100644
--- a/src/libtracker-common/tracker-common.h
+++ b/src/libtracker-common/tracker-common.h
@@ -34,6 +34,7 @@
#include "tracker-ioprio.h"
#include "tracker-language.h"
#include "tracker-log.h"
+#include "tracker-parser.h"
#include "tracker-sched.h"
#include "tracker-type-utils.h"
#include "tracker-utils.h"
diff --git a/src/libtracker-common/tracker-parser-utils.h b/src/libtracker-common/tracker-parser-utils.h
index 614740f..b244021 100644
--- a/src/libtracker-common/tracker-parser-utils.h
+++ b/src/libtracker-common/tracker-parser-utils.h
@@ -17,8 +17,8 @@
* 02110-1301 USA
*/
-#ifndef __TRACKER_PARSER_UTILS_H__
-#define __TRACKER_PARSER_UTILS_H__
+#ifndef __LIBTRACKER_COMMON_PARSER_UTILS_H__
+#define __LIBTRACKER_COMMON_PARSER_UTILS_H__
#include "config.h"
@@ -79,4 +79,4 @@ void tracker_parser_message_hex (const gchar *message,
G_END_DECLS
-#endif /* __TRACKER_PARSER_UTILS_H__ */
+#endif /* __LIBTRACKER_COMMON_PARSER_UTILS_H__ */
diff --git a/src/libtracker-common/tracker-parser.h b/src/libtracker-common/tracker-parser.h
index e6cb10e..1de905b 100644
--- a/src/libtracker-common/tracker-parser.h
+++ b/src/libtracker-common/tracker-parser.h
@@ -18,8 +18,8 @@
* 02110-1301 USA
*/
-#ifndef __LIBTRACKER_FTS_PARSER_H__
-#define __LIBTRACKER_FTS_PARSER_H__
+#ifndef __LIBTRACKER_COMMON_PARSER_H__
+#define __LIBTRACKER_COMMON_PARSER_H__
#include <glib.h>
@@ -57,4 +57,4 @@ gboolean tracker_parser_unaccent_nfkd_string (gpointer str,
G_END_DECLS
-#endif /* __LIBTRACKER_FTS_PARSER_H__ */
+#endif /* __LIBTRACKER_COMMON_PARSER_H__ */
diff --git a/tests/libtracker-common/Makefile.am b/tests/libtracker-common/Makefile.am
index 68d6cbe..d82ca6c 100644
--- a/tests/libtracker-common/Makefile.am
+++ b/tests/libtracker-common/Makefile.am
@@ -2,13 +2,16 @@ include $(top_srcdir)/Makefile.decl
noinst_PROGRAMS += $(test_programs)
+check_PROGRAMS += tracker-parser
+
test_programs = \
tracker-type-utils \
tracker-dbus \
tracker-file-utils \
tracker-utils \
tracker-sched-test \
- tracker-date-time-test
+ tracker-date-time-test \
+ tracker-parser-test
AM_CPPFLAGS = \
-DTOP_SRCDIR=\"$(abs_top_srcdir)\" \
@@ -37,4 +40,8 @@ tracker_sched_test_SOURCES = tracker-sched-test.c
tracker_date_time_test_SOURCES = tracker-date-time-test.c
+tracker_parser_test_SOURCES = tracker-parser-test.c
+
+tracker_parser_SOURCES = tracker-parser.c
+
EXTRA_DIST += non-utf8.txt
diff --git a/tests/libtracker-fts/tracker-parser-test.c b/tests/libtracker-common/tracker-parser-test.c
similarity index 100%
rename from tests/libtracker-fts/tracker-parser-test.c
rename to tests/libtracker-common/tracker-parser-test.c
diff --git a/tests/libtracker-fts/tracker-parser.c b/tests/libtracker-common/tracker-parser.c
similarity index 91%
rename from tests/libtracker-fts/tracker-parser.c
rename to tests/libtracker-common/tracker-parser.c
index 2c725d8..932cc2e 100644
--- a/tests/libtracker-fts/tracker-parser.c
+++ b/tests/libtracker-common/tracker-parser.c
@@ -25,10 +25,15 @@
#include <glib.h>
#include <gio/gio.h>
-#include <libtracker-fts/tracker-parser.h>
-#include <libtracker-fts/tracker-fts-config.h>
#include <libtracker-common/tracker-common.h>
+/* Normally this would be in the libtracker-fts config */
+#define DEFAULT_MAX_WORD_LENGTH 30
+#define DEFAULT_ENABLE_STEMMER FALSE
+#define DEFAULT_ENABLE_UNACCENT TRUE
+#define DEFAULT_IGNORE_STOP_WORDS TRUE
+#define DEFAULT_IGNORE_NUMBERS TRUE
+
static gchar *text;
static gchar *filename;
static gboolean verbose;
@@ -109,7 +114,6 @@ load_file_contents (void)
static gboolean
run_parsing (void)
{
- TrackerFTSConfig *config;
TrackerLanguage *language;
TrackerParser *parser;
GTimer *timer;
@@ -117,9 +121,6 @@ run_parsing (void)
/* Initialize timing */
timer = g_timer_new ();
- /* Read config file */
- config = tracker_fts_config_new ();
-
/* Setup language for parser */
language = tracker_language_new (NULL);
if (!language) {
@@ -136,15 +137,16 @@ run_parsing (void)
}
/* Reset the parser with our string, reading the current FTS config */
+
tracker_parser_reset (parser,
text,
strlen (text),
- tracker_fts_config_get_max_word_length (config),
- tracker_fts_config_get_enable_stemmer (config),
- tracker_fts_config_get_enable_unaccent (config),
- tracker_fts_config_get_ignore_stop_words (config),
+ DEFAULT_MAX_WORD_LENGTH,
+ DEFAULT_ENABLE_STEMMER,
+ DEFAULT_ENABLE_UNACCENT,
+ DEFAULT_IGNORE_STOP_WORDS,
TRUE,
- tracker_fts_config_get_ignore_numbers (config));
+ DEFAULT_IGNORE_NUMBERS);
/* Loop through all words! */
while (1) {
diff --git a/tests/libtracker-fts/Makefile.am b/tests/libtracker-fts/Makefile.am
index aa2be7f..7e86b2d 100644
--- a/tests/libtracker-fts/Makefile.am
+++ b/tests/libtracker-fts/Makefile.am
@@ -4,14 +4,10 @@ SUBDIRS = \
limits \
prefix
-check_PROGRAMS += \
- tracker-parser
-
noinst_PROGRAMS += $(test_programs)
test_programs = \
- tracker-fts-test \
- tracker-parser-test
+ tracker-fts-test
AM_CPPFLAGS = \
$(BUILD_CFLAGS) \
@@ -32,10 +28,6 @@ LDADD = \
tracker_fts_test_SOURCES = tracker-fts-test.c
-tracker_parser_test_SOURCES = tracker-parser-test.c
-
-tracker_parser_SOURCES = tracker-parser.c
-
EXTRA_DIST += \
data.ontology \
fts3aa-data.rq \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]