Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
test-command-select-geo.c
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
2 /*
3  Copyright (C) 2011 Kouhei Sutou <kou@clear-code.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License version 2.1 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include <gcutter.h>
20 #include <glib/gstdio.h>
21 
22 #include "../lib/grn-assertions.h"
23 
24 
25 static gchar *tmp_directory;
26 
27 static grn_ctx *context;
28 static grn_obj *database;
29 
30 void
32 {
33  tmp_directory = g_build_filename(grn_test_get_tmp_dir(),
34  "command-select-geo-in-rectangle",
35  NULL);
36 }
37 
38 void
40 {
41  g_free(tmp_directory);
42 }
43 
44 static void
45 remove_tmp_directory(void)
46 {
47  cut_remove_path(tmp_directory, NULL);
48 }
49 
50 void
51 cut_setup(void)
52 {
53  const gchar *database_path;
54 
55  cut_set_fixture_data_dir(grn_test_get_base_dir(),
56  "fixtures",
57  "story",
58  "taiyaki",
59  NULL);
60 
61  remove_tmp_directory();
62  g_mkdir_with_parents(tmp_directory, 0700);
63 
64  context = g_new0(grn_ctx, 1);
65  grn_ctx_init(context, 0);
66 
67  database_path = cut_build_path(tmp_directory, "database.groonga", NULL);
68  database = grn_db_create(context, database_path, NULL);
69 
70  assert_send_commands(cut_get_fixture_data_string("ddl.grn", NULL));
71  assert_send_command(cut_get_fixture_data_string("areas.grn", NULL));
72  assert_send_command(cut_get_fixture_data_string("categories.grn", NULL));
73  assert_send_command(cut_get_fixture_data_string("shops.grn", NULL));
74  assert_send_command(cut_get_fixture_data_string("synonyms.grn", NULL));
75 }
76 
77 void
79 {
80  if (context) {
81  grn_obj_unlink(context, database);
82  grn_ctx_fin(context);
83  g_free(context);
84  }
85 
86  remove_tmp_directory();
87 }
88 
89