23 #include <glib/gstdio.h>
25 #include "../lib/grn-assertions.h"
29 static gchar *tmp_directory;
46 g_free(tmp_directory);
50 remove_tmp_directory(
void)
52 cut_remove_path(tmp_directory, NULL);
58 const gchar *database_path;
60 remove_tmp_directory();
61 g_mkdir_with_parents(tmp_directory, 0700);
66 database_path = cut_build_path(tmp_directory,
"database.groonga", NULL);
102 remove_tmp_directory();
106 create_int32_table(
const gchar *load_data)
108 const char *table_name =
"Data";
109 const char *column_name =
"number";
110 const char *index_table_name =
"Index";
113 cut_take_printf(
"table_create %s TABLE_NO_KEY", table_name));
115 cut_take_printf(
"column_create %s %s COLUMN_SCALAR Int32",
116 table_name, column_name));
118 cut_take_printf(
"table_create %s TABLE_PAT_KEY Int32",
121 cut_take_printf(
"column_create %s %s_%s COLUMN_INDEX %s %s",
123 table_name, column_name,
124 table_name, column_name));
126 cut_take_printf(
"load --table %s\n"
135 table =
grn_ctx_get(context, table_name, strlen(table_name));
136 column =
grn_obj_column(context, table, column_name, strlen(column_name));
137 index_table =
grn_ctx_get(context, index_table_name, strlen(index_table_name));
141 int_list_new(gint n, gint value, ...)
147 va_start(args, value);
148 for (i = 0; i < n; i++) {
149 list = g_list_prepend(list, GINT_TO_POINTER(value));
150 value = va_arg(args, gint);
154 return g_list_reverse(list);
161 GList *expected_keys, *actual_keys = NULL;
163 cut_omit(
"null value support is required.");
164 create_int32_table(
" [0],\n"
171 NULL, 0, NULL, 0, 0, -1,
179 actual_keys = g_list_append(actual_keys, GINT_TO_POINTER(*key));
181 gcut_take_list(actual_keys, NULL);
183 expected_keys = int_list_new(5, 0, 1, 2, 3, 4);
184 gcut_take_list(expected_keys, NULL);
185 gcut_assert_equal_list_int(expected_keys, actual_keys);