[Groonga-commit] groonga/groonga [master] test for #268.

Back to archive index

null+****@clear***** null+****@clear*****
2010年 6月 22日 (火) 10:04:01 JST


Nobuyoshi Nakada	2010-06-22 01:04:01 +0000 (Tue, 22 Jun 2010)

  New Revision: ecca179fd1d933b739049434fc3aeac204bd3b8e

  Log:
    test for #268.

  Added files:
    test/unit/core/test-command-select.c
  Modified files:
    test/unit/core/Makefile.am

  Modified: test/unit/core/Makefile.am (+3 -1)
===================================================================
--- test/unit/core/Makefile.am    2010-06-21 08:05:36 +0000 (d8f6cbc)
+++ test/unit/core/Makefile.am    2010-06-22 01:04:01 +0000 (679c973)
@@ -37,7 +37,8 @@ noinst_LTLIBRARIES =				\
 	test-log.la				\
 	test-table-sort-key.la			\
 	test-inspect.la				\
-	test-command-column-list.la
+	test-command-column-list.la		\
+	test-command-select.la
 endif
 
 INCLUDES =			\
@@ -99,3 +100,4 @@ test_log_la_SOURCES			= test-log.c
 test_table_sort_key_la_SOURCES		= test-table-sort-key.c
 test_inspect_la_SOURCES			= test-inspect.c
 test_command_column_list_la_SOURCES	= test-command-column-list.c
+test_command_select_la_SOURCES		= test-command-select.c

  Added: test/unit/core/test-command-select.c (+99 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/core/test-command-select.c    2010-06-22 01:04:01 +0000 (fb0c395)
@@ -0,0 +1,99 @@
+/* -*- c-basic-offset: 2; coding: utf-8 -*- */
+/* Copyright(C) 2009 Brazil
+
+  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include "str.h"
+#include <stdio.h>
+
+#include <gcutter.h>
+
+#include "../lib/grn-assertions.h"
+
+static gchar *tmp_directory;
+
+static grn_ctx *context;
+static grn_obj *database;
+
+void
+cut_startup(void)
+{
+  tmp_directory = g_build_filename(grn_test_get_base_dir(),
+                                   "tmp",
+                                   "command-select",
+                                   NULL);
+}
+
+void
+cut_shutdown(void)
+{
+  g_free(tmp_directory);
+}
+
+static void
+remove_tmp_directory(void)
+{
+  cut_remove_path(tmp_directory, NULL);
+}
+
+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);
+}
+
+void
+cut_teardown(void)
+{
+  if (context) {
+    grn_obj_unlink(context, database);
+    grn_ctx_fin(context);
+    g_free(context);
+  }
+
+  remove_tmp_directory();
+}
+
+void
+test_nil_column_reference_value(void)
+{
+  const gchar *actual;
+
+  assert_send_commands("table_create Sites TABLE_PAT_KEY ShortText Int32\n"
+                       "column_create Sites link COLUMN_SCALAR Sites\n"
+                       "load --table Sites\n"
+                       "[\n"
+                       "[\"_key\",\"_value\"],\n"
+                       "[\"groonga.org\",0],\n"
+                       "[\"razil.jp\",0]\n"
+                       "]");
+  actual = send_command("select Sites");
+  cut_assert_equal_string("[[[2],"
+                          "[[\"_id\",\"UInt32\"],"
+                           "[\"_key\",\"ShortText\"],"
+                           "[\"_value\",\"Int32\"],"
+                           "[\"link\",\"Sites\"]],"
+                          "[1,\"groonga.org\",0,\"\"],"
+                          "[2,\"razil.jp\",0,\"\"]]]", actual);
+}




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