[Groonga-commit] groonga/groonga [master] Move Cutter tests to grntest tests

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Oct 9 15:18:44 JST 2012


Kouhei Sutou	2012-10-09 15:18:44 +0900 (Tue, 09 Oct 2012)

  New Revision: 2ff4c78052e4c13fcac13630db194c4b0ea3fd7a
  https://github.com/groonga/groonga/commit/2ff4c78052e4c13fcac13630db194c4b0ea3fd7a

  Log:
    Move Cutter tests to grntest tests
    
    Tests for --query_expansion with normalized key is moved.
    
    All Cutter tests are migrated! Yay!

  Added files:
    test/command/suite/select/query_expansion/scalar/normalize.expected
    test/command/suite/select/query_expansion/scalar/normalize.test
    test/command/suite/select/query_expansion/vector/normalize.expected
    test/command/suite/select/query_expansion/vector/normalize.test
  Removed files:
    test/unit/core/test-command-select-query-expansion.c
  Modified files:
    test/unit/core/Makefile.am

  Added: test/command/suite/select/query_expansion/scalar/normalize.expected (+59 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query_expansion/scalar/normalize.expected    2012-10-09 15:18:44 +0900 (a243a79)
@@ -0,0 +1,59 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Lexicon diary_content COLUMN_INDEX|WITH_POSITION Memos content
+[[0,0.0,0.0],true]
+table_create Synonyms TABLE_PAT_KEY|KEY_NORMALIZE ShortText
+[[0,0.0,0.0],true]
+column_create Synonyms words COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Memos
+[
+["content"],
+["Start groonga!"],
+["Start rroonga!"],
+["Start Ruby and groonga!"]
+]
+[[0,0.0,0.0],3]
+load --table Synonyms
+[
+["_key", "words"],
+["Ruby", "(Ruby OR rroonga)"]
+]
+[[0,0.0,0.0],1]
+select --table Memos --query_expansion Synonyms.words   --match_columns content --query ruby
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "content",
+          "ShortText"
+        ]
+      ],
+      [
+        3,
+        "Start Ruby and groonga!"
+      ],
+      [
+        2,
+        "Start rroonga!"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/query_expansion/scalar/normalize.test (+25 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query_expansion/scalar/normalize.test    2012-10-09 15:18:44 +0900 (da2b4ed)
@@ -0,0 +1,25 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos content COLUMN_SCALAR ShortText
+
+table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Lexicon diary_content COLUMN_INDEX|WITH_POSITION Memos content
+
+table_create Synonyms TABLE_PAT_KEY|KEY_NORMALIZE ShortText
+column_create Synonyms words COLUMN_SCALAR ShortText
+
+load --table Memos
+[
+["content"],
+["Start groonga!"],
+["Start rroonga!"],
+["Start Ruby and groonga!"]
+]
+
+load --table Synonyms
+[
+["_key", "words"],
+["Ruby", "(Ruby OR rroonga)"]
+]
+
+select --table Memos --query_expansion Synonyms.words \
+  --match_columns content --query ruby

  Added: test/command/suite/select/query_expansion/vector/normalize.expected (+59 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query_expansion/vector/normalize.expected    2012-10-09 15:18:44 +0900 (44de57e)
@@ -0,0 +1,59 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Lexicon diary_content COLUMN_INDEX|WITH_POSITION Memos content
+[[0,0.0,0.0],true]
+table_create Synonyms TABLE_PAT_KEY|KEY_NORMALIZE ShortText
+[[0,0.0,0.0],true]
+column_create Synonyms words COLUMN_VECTOR ShortText
+[[0,0.0,0.0],true]
+load --table Memos
+[
+["content"],
+["Start groonga!"],
+["Start rroonga!"],
+["Start Ruby and groonga!"]
+]
+[[0,0.0,0.0],3]
+load --table Synonyms
+[
+["_key", "words"],
+["Ruby", ["Ruby", "rroonga"]]
+]
+[[0,0.0,0.0],1]
+select --table Memos --query_expansion Synonyms.words   --match_columns content --query ruby
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "content",
+          "ShortText"
+        ]
+      ],
+      [
+        3,
+        "Start Ruby and groonga!"
+      ],
+      [
+        2,
+        "Start rroonga!"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/query_expansion/vector/normalize.test (+25 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query_expansion/vector/normalize.test    2012-10-09 15:18:44 +0900 (d4a10f0)
@@ -0,0 +1,25 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos content COLUMN_SCALAR ShortText
+
+table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Lexicon diary_content COLUMN_INDEX|WITH_POSITION Memos content
+
+table_create Synonyms TABLE_PAT_KEY|KEY_NORMALIZE ShortText
+column_create Synonyms words COLUMN_VECTOR ShortText
+
+load --table Memos
+[
+["content"],
+["Start groonga!"],
+["Start rroonga!"],
+["Start Ruby and groonga!"]
+]
+
+load --table Synonyms
+[
+["_key", "words"],
+["Ruby", ["Ruby", "rroonga"]]
+]
+
+select --table Memos --query_expansion Synonyms.words \
+  --match_columns content --query ruby

  Modified: test/unit/core/Makefile.am (+0 -2)
===================================================================
--- test/unit/core/Makefile.am    2012-10-09 15:12:34 +0900 (9d876f7)
+++ test/unit/core/Makefile.am    2012-10-09 15:18:44 +0900 (fb5be8a)
@@ -55,7 +55,6 @@ noinst_LTLIBRARIES =				\
 	test-command-select-filter-invalid.la	\
 	test-command-select-query.la		\
 	test-command-select-filter.la		\
-	test-command-select-query-expansion.la	\
 	test-command-select-geo.la		\
 	test-command-define-selector.la		\
 	test-command-cache-limit.la		\
@@ -147,7 +146,6 @@ test_command_select_prefix_search_la_SOURCES	= test-command-select-prefix-search
 test_command_select_filter_invalid_la_SOURCES	= test-command-select-filter-invalid.c
 test_command_select_query_la_SOURCES	= test-command-select-query.c
 test_command_select_filter_la_SOURCES	= test-command-select-filter.c
-test_command_select_query_expansion_la_SOURCES	= test-command-select-query-expansion.c
 test_command_select_geo_la_SOURCES	= test-command-select-geo.c
 test_command_define_selector_la_SOURCES	= test-command-define-selector.c
 test_command_cache_limit_la_SOURCES	= test-command-cache-limit.c

  Deleted: test/unit/core/test-command-select-query-expansion.c (+0 -231) 100644
===================================================================
--- test/unit/core/test-command-select-query-expansion.c    2012-10-09 15:12:34 +0900 (c744d9e)
+++ /dev/null
@@ -1,231 +0,0 @@
-/* -*- c-basic-offset: 2; coding: utf-8 -*- */
-/*
-  Copyright(C) 2011 Kouhei Sutou <kou �� clear-code.com>
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License version 2.1 as published by the Free Software Foundation.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#include "str.h"
-#include <stdio.h>
-
-#include <gcutter.h>
-
-#include "../lib/grn-assertions.h"
-
-void data_expand_equal(void);
-void test_expand_equal(gconstpointer data);
-void data_expand_prefix(void);
-void test_expand_prefix(gconstpointer data);
-void data_not_expand_OR(void);
-void test_not_expand_OR(gconstpointer data);
-void data_not_expand_OR_at_the_end(void);
-void test_not_expand_OR_at_the_end(gconstpointer data);
-void data_not_expand_OR_with_leading_space(void);
-void test_not_expand_OR_with_leading_space(gconstpointer data);
-void data_not_expand_and(void);
-void test_not_expand_and(gconstpointer data);
-void data_not_expand_but(void);
-void test_not_expand_but(gconstpointer data);
-void data_not_expand_paren(void);
-void test_not_expand_paren(gconstpointer data);
-void data_no_expand(void);
-void test_no_expand(gconstpointer data);
-void data_no_expand_word_with_space(void);
-void test_no_expand_word_with_space(gconstpointer data);
-void data_nonexistent_expansion_column(void);
-void test_nonexistent_expansion_column(gconstpointer data);
-void data_key_normalize(void);
-void test_key_normalize(gconstpointer data);
-
-static gchar *tmp_directory;
-
-static grn_ctx *context;
-static grn_obj *database;
-
-void
-cut_startup(void)
-{
-  tmp_directory = g_build_filename(grn_test_get_tmp_dir(),
-                                   "command-select-query-expansion",
-                                   NULL);
-}
-
-void
-cut_shutdown(void)
-{
-  g_free(tmp_directory);
-}
-
-static void
-remove_tmp_directory(void)
-{
-  cut_remove_path(tmp_directory, NULL);
-}
-
-static void
-setup_data(void)
-{
-  assert_send_command("table_create Diaries TABLE_HASH_KEY Time");
-  assert_send_command("column_create Diaries content COLUMN_SCALAR Text");
-  assert_send_command("table_create Lexicon TABLE_PAT_KEY ShortText "
-                      "--default_tokenizer TokenBigram");
-  assert_send_command("column_create Lexicon diary_content "
-                      "COLUMN_INDEX|WITH_POSITION Diaries content");
-  assert_send_command("table_create Synonyms TABLE_PAT_KEY ShortText");
-  assert_send_command("column_create Synonyms words_scalar "
-                      "COLUMN_SCALAR ShortText");
-  assert_send_command("column_create Synonyms words_vector "
-                      "COLUMN_VECTOR ShortText");
-  assert_send_command("load --table Diaries\n"
-                      "[\n"
-                      "[\"_key\", \"content\"],\n"
-                      "[\"2011-09-11 00:00:00\", \"Start groonga!\"],\n"
-                      "[\"2011-09-12 00:00:00\", \"Start mroonga!\"],\n"
-                      "[\"2011-09-13 00:00:00\", \"Start rroonga!\"],\n"
-                      "[\"2011-09-14 00:00:00\", \"Start Ruby!\"],\n"
-                      "[\"2011-09-15 00:00:00\", \"Start MySQL!\"],\n"
-                      "[\"2011-09-16 00:00:00\", "
-                       "\"Setup groonga storage engine!\"],\n"
-                      "[\"2011-09-17 00:00:00\", \"Learning MySQL...\"],\n"
-                      "[\"2011-09-18 00:00:00\", "
-                       "\"Learning MySQL and groonga...\"],\n"
-                      "[\"2011-09-19 00:00:00\", "
-                       "\"Learning Ruby and groonga...\"],\n"
-                      "[\"2011-09-20 00:00:00\", "
-                       "\"明日は日本語あるいは中国語を勉強します。\"],\n"
-                      "[\"2011-09-21 00:00:00\", "
-                       "\"かつ 差集合 より重要 重要度を下げる "
-                         "補集合 前方一致 かっこ こっか\"]\n"
-                      "]");
-  assert_send_command("load --table Synonyms\n"
-                      "[\n"
-                      "[\"_key\", \"words_scalar\", \"words_vector\"],\n"
-                      "[\"groonga\", "
-                       "\"(groonga OR rroonga OR mroonga)\", "
-                       "[\"groonga\", \"rroonga\", \"mroonga\"]],\n"
-                      "[\"rroonga\", "
-                       "\"(rroonga OR (Ruby groonga))\", "
-                       "[\"rroonga\", \"Ruby groonga\"]],\n"
-                      "[\"mroonga\", "
-                       "\"(mroonga OR (groonga MySQL) OR "
-                          "\\\"groonga storage engine\\\")\", "
-                       "[\"mroonga\", "
-                        "\"groonga MySQL\", "
-                        "\"\\\"groonga storage engine\\\"\"]],\n"
-                      "[\"groonga storage engine\", "
-                       "\"(\\\"groonga storage engine\\\" OR mroonga)\", "
-                       "[\"\\\"groonga storage engine\\\"\", \"mroonga\"]],\n"
-                      "[\"OR\", \"あるいは\", [\"あるいは\"]],\n"
-                      "[\"+\", \"かつ\", [\"かつ\"]],\n"
-                      "[\"-\", \"差集合\", [\"差集合\"]],\n"
-                      "[\">\", \"より重要\", [\"より重要\"]],\n"
-                      "[\"<\", \"重要度を下げる\", [\"重要度を下げる\"]],\n"
-                      "[\"~\", \"補集合\", [\"補集合\"]],\n"
-                      "[\"*\", \"前方一致\", [\"前方一致\"]],\n"
-                      "[\"(\", \"かっこ\", [\"かっこ\"]],\n"
-                      "[\")\", \"こっか\", [\"こっか\"]]\n"
-                      "[\"=start-rroonga\", "
-                       "\"\\\"Start rroonga!\\\"\", "
-                       "[\"\\\"Start rroonga!\\\"\"]],\n"
-                      "[\"Japan\", \"日本\", [\"日本\"]]\n"
-                      "]");
-}
-
-void
-cut_setup(void)
-{
-  const gchar *database_path;
-
-  remove_tmp_directory();
-  g_mkdir_with_parents(tmp_directory, 0700);
-
-  context = g_new0(grn_ctx, 1);
-  grn_ctx_init(context, 0);
-
-  database_path = cut_build_path(tmp_directory, "database.groonga", NULL);
-  database = grn_db_create(context, database_path, NULL);
-
-  setup_data();
-}
-
-void
-cut_teardown(void)
-{
-  if (context) {
-    grn_obj_unlink(context, database);
-    grn_ctx_fin(context);
-    g_free(context);
-  }
-
-  remove_tmp_directory();
-}
-
-static void
-data_scalar_and_vector(void)
-{
-#define ADD_DATA(label, column_name)                            \
-  gcut_add_datum(label,                                         \
-                 "column-name", G_TYPE_STRING, column_name,     \
-                 NULL)
-
-  ADD_DATA("scalar", "words_scalar");
-  ADD_DATA("vector", "words_vector");
-
-#undef ADD_DATA
-}
-
-void
-data_nonexistent_expansion_column(void)
-{
-  data_scalar_and_vector();
-}
-
-void
-data_key_normalize(void)
-{
-  data_scalar_and_vector();
-}
-
-void
-test_key_normalize(gconstpointer data)
-{
-  assert_send_command("table_create NormalizedSynonyms "
-                      "TABLE_PAT_KEY|KEY_NORMALIZE ShortText");
-  assert_send_command("column_create NormalizedSynonyms words_scalar "
-                      "COLUMN_SCALAR ShortText");
-  assert_send_command("column_create NormalizedSynonyms words_vector "
-                      "COLUMN_VECTOR ShortText");
-  assert_send_command("load --table NormalizedSynonyms\n"
-                      "[\n"
-                      "[\"_key\", \"words_scalar\", \"words_vector\"],\n"
-                      "[\"Ruby\", "
-                       "\"(Ruby OR rroonga)\", "
-                       "[\"Ruby\", \"rroonga\"]]\n"
-                      "]");
-
-  cut_assert_equal_string(
-    "[[[3],"
-     "[[\"_id\",\"UInt32\"],"
-      "[\"_key\",\"Time\"],"
-      "[\"content\",\"Text\"]],"
-     "[3,1315839600.0,\"Start rroonga!\"],"
-     "[4,1315926000.0,\"Start Ruby!\"],"
-     "[9,1316358000.0,\"Learning Ruby and groonga...\"]]]",
-    send_command(
-      cut_take_printf("select Diaries "
-                      "--sortby _id "
-                      "--match_columns content --query ruby "
-                      "--query_expansion NormalizedSynonyms.%s",
-                      gcut_data_get_string(data, "column-name"))));
-}
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index