[Groonga-commit] groonga/groonga [master] add a test for geo point index load.

Back to archive index

null+****@clear***** null+****@clear*****
2010年 9月 26日 (日) 15:45:39 JST


Kouhei Sutou	2010-09-26 06:45:39 +0000 (Sun, 26 Sep 2010)

  New Revision: e228be41f7e3b155fa715630fdd8537f28d40251

  Log:
    add a test for geo point index load.

  Modified files:
    test/unit/core/test-command-load.c

  Modified: test/unit/core/test-command-load.c (+46 -0)
===================================================================
--- test/unit/core/test-command-load.c    2010-09-26 06:25:02 +0000 (7a124e1)
+++ test/unit/core/test-command-load.c    2010-09-26 06:45:39 +0000 (7803606)
@@ -30,6 +30,7 @@ void test_bool(gconstpointer data);
 void test_int32_key(void);
 void data_null(void);
 void test_null(gconstpointer data);
+void test_index_geo_point(void);
 
 static gchar *tmp_directory;
 
@@ -277,3 +278,48 @@ test_null(gconstpointer data)
   cut_assert_equal_string(gcut_data_get_string(data, "expected"),
                           send_command("select Students"));
 }
+
+void
+test_index_geo_point(void)
+{
+  const gchar *query =
+    "select Shops "
+    "--filter 'geo_in_circle(location, \"128514964x502419287\", 1)'";
+  const gchar *hit_result =
+    "[[[1],"
+    "[[\"_id\",\"UInt32\"],"
+    "[\"_key\",\"ShortText\"],"
+    "[\"location\",\"WGS84GeoPoint\"]],"
+    "[1,\"たかね\",\"128514964x502419287\"]]]";
+  const gchar *no_hit_result =
+    "[[[0],"
+    "[[\"_id\",\"UInt32\"],"
+    "[\"_key\",\"ShortText\"],"
+    "[\"location\",\"WGS84GeoPoint\"]]]]";
+  const gchar *load_takane =
+    "load --table Shops\n"
+    "[{\"_key\": \"たかね\", \"location\": \"128514964x502419287\"}]";
+  const gchar *load_takane_with_empty_location =
+    "load --table Shops\n"
+    "[{\"_key\": \"たかね\", \"location\": \"\"}]";
+
+  assert_send_command("table_create Shops TABLE_HASH_KEY ShortText");
+  assert_send_command("column_create Shops location COLUMN_SCALAR WGS84GeoPoint");
+  assert_send_command("table_create Locations TABLE_PAT_KEY WGS84GeoPoint");
+  assert_send_command("column_create Locations shop COLUMN_INDEX Shops location");
+
+  cut_assert_equal_string("1",
+                          send_command(load_takane));
+  cut_assert_equal_string(hit_result,
+                          send_command(query));
+
+  cut_assert_equal_string("1",
+                          send_command(load_takane_with_empty_location));
+  cut_assert_equal_string(no_hit_result,
+                          send_command(query));
+
+  cut_assert_equal_string("1",
+                          send_command(load_takane));
+  cut_assert_equal_string(hit_result,
+                          send_command(query));
+}




Groonga-commit メーリングリストの案内
Back to archive index