26 #include "../lib/grn-assertions.h"
28 static gchar *tmp_directory;
32 static grn_obj *cond, *res, *expr;
33 static grn_obj text_buf, int_buf, ptr_buf;
57 g_free(tmp_directory);
63 cut_remove_path(tmp_directory, NULL);
64 g_mkdir_with_parents(tmp_directory, 0700);
65 path = g_build_filename(tmp_directory,
"text-table-select", NULL);
94 cut_remove_path(tmp_directory, NULL);
98 static grn_obj *properties, *docs, *terms, *size, *body, *
author, *index_body;
101 insert_document(
const gchar *author_content,
const gchar *body_content)
103 uint32_t s = (uint32_t)strlen(body_content);
106 if (author_content) {
107 GRN_TEXT_SET(&context, &text_buf, author_content, strlen(author_content));
121 #define INSERT_DOCUMENT(author, body) \
122 cut_trace(insert_document(author, body))
125 create_properties_table(
void)
127 const gchar *table_name =
"properties";
128 properties =
grn_table_create(&context, table_name, strlen(table_name), NULL,
131 cut_assert_not_null(properties);
135 create_documents_table(
void)
139 cut_assert_not_null(docs);
144 cut_assert_not_null(size);
149 cut_assert_not_null(body);
154 cut_assert_not_null(author);
158 create_terms_table(
void)
163 cut_assert_not_null(terms);
170 cut_assert_not_null(index_body);
194 create_properties_table();
195 create_documents_table();
196 create_terms_table();
200 #define PARSE(expr, str, flags) \
201 grn_test_assert(grn_expr_parse(&context, (expr), (str), strlen(str), \
202 body, GRN_OP_MATCH, GRN_OP_AND, flags))
218 GRN_TEXT_SETS(&context, &text_buf,
"poyo moge hoge moge moge moge");
225 cut_assert_not_null(res);
230 gcut_take_new_list_string(
"poyo moge hoge "
257 cut_assert_not_null(res);
262 gcut_take_new_list_string(
"hoge", NULL),
275 cut_assert_not_null(cond);
276 cut_assert_not_null(v);
279 cut_assert_not_null(res);
282 gcut_take_new_list_string(
285 "poyo moge hoge moge moge moge",
299 cut_assert_not_null(cond);
300 cut_assert_not_null(v);
303 cut_assert_not_null(res);
332 cut_assert_not_null(res);
345 gcut_take_new_list_string(
"moge moge moge",
413 cut_assert_equal_substring(
"[[2],[14,4,\"moge moge moge\"],[14,2,\"moge hoge hoge\"]]",
477 cut_assert_equal_substring(
"[[2],[14,4,\"moge moge moge\"],[14,2,\"moge hoge hoge\"]]",
502 cut_assert_not_null(res);
507 gcut_take_new_list_string(
"moge moge moge",
508 "hoge moge moge moge",
510 "moge hoge fuga fuga",
511 "moge hoge moge moge moge",
552 cut_assert_not_null(res);
557 gcut_take_new_list_string(
"moge moge moge",
569 create_properties_table();
570 create_documents_table();
589 cut_assert_not_null(res);
595 gcut_take_new_list_string(
"moge moge moge",
596 "hoge moge moge moge",
598 "moge hoge fuga fuga",
599 "moge hoge moge moge moge",
600 "poyo moge hoge moge moge moge",