Kouhei Sutou
null+****@clear*****
Thu Mar 24 22:45:25 JST 2016
Kouhei Sutou 2016-03-24 22:45:25 +0900 (Thu, 24 Mar 2016) New Revision: 52f5c277f223a20c8897ad8150fed1daacf98956 https://github.com/groonga/groonga/commit/52f5c277f223a20c8897ad8150fed1daacf98956 Message: Add grn_obj_is_text_family_type() Modified files: include/groonga/obj.h lib/obj.c test/unit/core/test-object.c Modified: include/groonga/obj.h (+1 -0) =================================================================== --- include/groonga/obj.h 2016-03-24 16:21:39 +0900 (35c04bf) +++ include/groonga/obj.h 2016-03-24 22:45:25 +0900 (4539467) @@ -37,6 +37,7 @@ GRN_API grn_bool grn_obj_is_reference_column(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_accessor(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_key_accessor(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_type(grn_ctx *ctx, grn_obj *obj); +GRN_API grn_bool grn_obj_is_text_family_type(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_proc(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_tokenizer_proc(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_function_proc(grn_ctx *ctx, grn_obj *obj); Modified: lib/obj.c (+10 -0) =================================================================== --- lib/obj.c 2016-03-24 16:21:39 +0900 (df1bb43) +++ lib/obj.c 2016-03-24 22:45:25 +0900 (37af1b6) @@ -186,6 +186,16 @@ grn_obj_is_type(grn_ctx *ctx, grn_obj *obj) } grn_bool +grn_obj_is_text_family_type(grn_ctx *ctx, grn_obj *obj) +{ + if (!grn_obj_is_type(ctx, obj)) { + return GRN_FALSE; + } + + return GRN_TYPE_IS_TEXT_FAMILY(obj->header.type); +} + +grn_bool grn_obj_is_proc(grn_ctx *ctx, grn_obj *obj) { if (!obj) { Modified: test/unit/core/test-object.c (+37 -0) =================================================================== --- test/unit/core/test-object.c 2016-03-24 16:21:39 +0900 (3dc4afe) +++ test/unit/core/test-object.c 2016-03-24 22:45:25 +0900 (159b269) @@ -39,6 +39,8 @@ void data_is_key_accessor(void); void test_is_key_accessor(gconstpointer data); void data_is_type(void); void test_is_type(gconstpointer data); +void data_is_text_family_type(void); +void test_is_text_family_type(gconstpointer data); void data_is_proc(void); void test_is_proc(gconstpointer data); void data_is_tokenizer_proc(void); @@ -363,6 +365,41 @@ test_is_type(gconstpointer data) } void +data_is_text_family_type(void) +{ +#define ADD_DATUM(expected, name) \ + gcut_add_datum((expected ? \ + "type - " name : \ + "not type - " name), \ + "expected", G_TYPE_BOOLEAN, expected, \ + "name", G_TYPE_STRING, name, \ + NULL) + + ADD_DATUM(FALSE, "Time"); + ADD_DATUM(TRUE, "ShortText"); + ADD_DATUM(TRUE, "Text"); + ADD_DATUM(TRUE, "LongText"); + ADD_DATUM(FALSE, "TokyoGeoPoint"); + +#undef ADD_DATUM +} + +void +test_is_text_family_type(gconstpointer data) +{ + const gchar *name; + grn_obj *object; + + name = gcut_data_get_string(data, "name"); + object = grn_ctx_get(context, name, strlen(name)); + if (gcut_data_get_string(data, "expected")) { + cut_assert_true(grn_obj_is_text_family_type(context, object)); + } else { + cut_assert_false(grn_obj_is_text_family_type(context, object)); + } +} + +void data_is_proc(void) { #define ADD_DATUM(expected, name) \ -------------- next part -------------- HTML����������������������������...다운로드