20 #include <glib/gstdio.h>
22 #include "../lib/grn-assertions.h"
27 #define get(name) grn_ctx_get(context, name, strlen(name))
36 static gchar *tmp_directory;
41 #define DEFINE_GEO_POINT(name) \
42 static grn_obj *name ## _wgs84, *name ## _text
51 #undef DEFINE_GEO_POINT
64 g_free(tmp_directory);
68 remove_tmp_directory(
void)
70 cut_remove_path(tmp_directory, NULL);
74 text_geo_point_open(
double latitude,
double longitude)
79 GRN_TEXT_PUTS(context, point, cut_take_printf(
"%f,%f", latitude, longitude));
84 wgs84_geo_point_open(
double latitude,
double longitude)
88 point_text = text_geo_point_open(latitude, longitude);
98 #define SETUP_GEO_POINT(name, latitude, longitude) \
99 name ## _wgs84 = wgs84_geo_point_open(latitude, longitude); \
100 name ## _text = text_geo_point_open(latitude, longitude)
112 #undef SETUP_GEO_POINT
125 const gchar *database_path;
133 remove_tmp_directory();
134 g_mkdir_with_parents(tmp_directory, 0700);
139 database_path = cut_build_path(tmp_directory,
"database.groonga", NULL);
145 shops =
get(
"Shops");
146 location_index =
get(
"Locations.shop");
156 teardown_values(
void)
158 #define UNLINK_GEO_POINT(name) \
159 grn_obj_unlink(context, name ## _wgs84); \
160 grn_obj_unlink(context, name ## _text)
172 #undef UNLINK_GEO_POINT
186 remove_tmp_directory();
220 gint result_key_size;
226 memcpy(&shop_id, result_key, result_key_size);
229 list = g_list_append(list, g_strndup(key, key_size));
231 gcut_take_list(list, g_free);
241 nerima_wgs84, tokyo_wgs84,
243 gcut_assert_equal_list_string(
244 gcut_take_new_list_string(
"soba-taiyaki-ku",
257 #define ADD_DATA(label, expected, offset, limit) \
258 gcut_add_datum(label, \
259 "expected", G_TYPE_POINTER, expected, gcut_list_string_free, \
260 "offset", G_TYPE_INT, offset, \
261 "limit", G_TYPE_INT, limit, \
265 gcut_list_string_new(
"soba-taiyaki-ku",
274 gcut_list_string_new(
"hirose-ya",
281 gcut_list_string_new(
"soba-taiyaki-ku",
287 gcut_list_string_new(
"hirose-ya",
305 GList *expected, *records = NULL;
310 offset = gcut_data_get_int(data,
"offset");
311 limit = gcut_data_get_int(data,
"limit");
314 nerima_wgs84, tokyo_wgs84,
323 records = g_list_append(records, g_strndup(key, key_size));
327 expected = (GList *)gcut_data_get_pointer(data,
"expected");
328 gcut_take_list(records, g_free);
329 gcut_assert_equal_list_string(expected, records);
335 cut_assert_equal_int(4,