null+****@clear*****
null+****@clear*****
2010年 6月 8日 (火) 17:56:57 JST
Kouhei Sutou 2010-06-08 08:56:57 +0000 (Tue, 08 Jun 2010)
New Revision: 1bf5e3e942cb256be55ce97073834ea546036982
Log:
add tests for inspecting _score and _nsubrecs.
Modified files:
test/unit/core/test-inspect.c
Modified: test/unit/core/test-inspect.c (+48 -0)
===================================================================
--- test/unit/core/test-inspect.c 2010-06-08 08:27:50 +0000 (4eec949)
+++ test/unit/core/test-inspect.c 2010-06-08 08:56:57 +0000 (cc35ff8)
@@ -57,6 +57,8 @@ void test_pvector_empty(void);
void test_pvector_with_records(void);
void data_accessor_column_name(void);
void test_accessor_column_name(gconstpointer data);
+void data_accessor_dynamic_pseudo_column_name(void);
+void test_accessor_dynamic_pseudo_column_name(gconstpointer data);
static gchar *tmp_directory;
@@ -536,3 +538,49 @@ test_accessor_column_name(gconstpointer data)
inspected = grn_inspect(context, NULL, accessor);
cut_assert_equal_string(accessor_name, inspected_string());
}
+
+void
+data_accessor_dynamic_pseudo_column_name(void)
+{
+#define ADD_DATUM(accessor) \
+ gcut_add_datum(accessor, \
+ "accessor", G_TYPE_STRING, accessor, \
+ NULL)
+
+ ADD_DATUM("_score");
+ ADD_DATUM("_nsubrecs");
+
+#undef ADD_DATUM
+}
+
+void
+test_accessor_dynamic_pseudo_column_name(gconstpointer data)
+{
+ const char *query, *accessor_name;
+ grn_obj *table, *result, *expression, *variable, *accessor;
+
+ assert_send_command("table_create Sites TABLE_PAT_KEY ShortText");
+ assert_send_command("column_create Sites uri COLUMN_SCALAR ShortText");
+ assert_send_command("load "
+ "'["
+ "[\"_key\",\"uri\"],"
+ "[\"groonga\",\"http://groonga.org/\"]"
+ "]' "
+ "Sites");
+
+ accessor_name = gcut_data_get_string(data, "accessor");
+
+ table = get_object("Sites");
+ GRN_EXPR_CREATE_FOR_QUERY(context, table, expression, variable);
+ query = "_key:groonga";
+ grn_expr_parse(context, expression,
+ query, strlen(query),
+ NULL, GRN_OP_MATCH, GRN_OP_AND,
+ GRN_EXPR_SYNTAX_QUERY | GRN_EXPR_ALLOW_COLUMN);
+ result = grn_table_select(context, table, expression, NULL, GRN_OP_AND);
+ accessor = grn_obj_column(context, result,
+ accessor_name, strlen(accessor_name));
+ cut_assert_not_null(accessor);
+ inspected = grn_inspect(context, NULL, accessor);
+ cut_assert_equal_string(accessor_name, inspected_string());
+}