25 #include "../lib/grn-assertions.h"
27 static gchar *tmp_directory;
32 static grn_obj textbuf, intbuf, floatbuf, timebuf;
50 g_free(tmp_directory);
56 cut_remove_path(tmp_directory, NULL);
57 g_mkdir_with_parents(tmp_directory, 0700);
58 path = g_build_filename(tmp_directory,
"text-expr", NULL);
86 cut_remove_path(tmp_directory, NULL);
90 #define PARSE(expr, str, flags) \
91 grn_test_assert(grn_expr_parse(&context, (expr), (str), strlen(str), \
92 body, GRN_OP_MATCH, GRN_OP_AND, flags))
94 static grn_obj *docs, *terms, *body, *created_at, *index_body;
95 static grn_obj *size, *size_in_string, *size_in_float;
98 insert_document(
const gchar *body_content)
100 uint32_t s = (uint32_t)strlen(body_content);
102 const gchar *size_string;
113 size_string = cut_take_printf(
"%u", s);
114 GRN_TEXT_SET(&context, &textbuf, size_string, strlen(size_string));
136 #define INSERT_DOCUMENT(body) \
137 cut_trace(insert_document(body))
140 create_documents_table(
void)
144 cut_assert_not_null(docs);
149 cut_assert_not_null(size);
154 cut_assert_not_null(size_in_string);
159 cut_assert_not_null(size_in_float);
164 cut_assert_not_null(created_at);
169 cut_assert_not_null(body);
173 create_terms_table(
void)
178 cut_assert_not_null(terms);
185 cut_assert_not_null(index_body);
210 create_documents_table();
211 create_terms_table();
218 #define ADD_DATUM(label, expected_keys, query) \
219 gcut_add_datum(label, \
220 "expected_keys", G_TYPE_POINTER, expected_keys, \
221 gcut_list_string_free, \
222 "query", G_TYPE_STRING, query, \
226 gcut_list_string_new(
"fuga fuga",
"hoge hoge", NULL),
229 gcut_list_string_new(
"=poyo_moge_hoge_moge_moge_moge", NULL),
230 "body:=poyo_moge_hoge_moge_moge_moge");
243 cut_assert_not_null(expr);
245 cut_assert_not_null(v);
248 gcut_data_get_string(data,
"query"),
252 cut_assert_not_null(res);
254 gcut_data_get_pointer(data,
"expected_keys"),
262 #define ADD_DATUM(label, expected_keys, query) \
263 gcut_add_datum(label, \
264 "expected_keys", G_TYPE_POINTER, expected_keys, \
265 gcut_list_string_free, \
266 "query", G_TYPE_STRING, query, \
270 gcut_list_string_new(
"fuga fuga",
"hoge",
"hoge hoge", NULL),
271 "size:<=9 size:=9 size:9");
284 cut_assert_not_null(expr);
286 cut_assert_not_null(v);
289 gcut_data_get_string(data,
"query"),
293 cut_assert_not_null(res);
295 gcut_data_get_pointer(data,
"expected_keys"),