Masafumi Yokoyama
null+****@clear*****
Fri Oct 7 15:52:29 JST 2016
Masafumi Yokoyama 2016-10-07 15:52:29 +0900 (Fri, 07 Oct 2016) New Revision: 9533e52c019fc7f7237f25f0f4b08f2b56a49ff3 https://github.com/ranguba/rroonga/commit/9533e52c019fc7f7237f25f0f4b08f2b56a49ff3 Message: Add Groonga::ID.builtin_type? to bind grn_id_is_builtin_type() GitHub: #131 Modified files: ext/groonga/rb-grn-id.c test/test-id.rb Modified: ext/groonga/rb-grn-id.c (+19 -0) =================================================================== --- ext/groonga/rb-grn-id.c 2016-10-06 17:27:15 +0900 (ff40eff) +++ ext/groonga/rb-grn-id.c 2016-10-07 15:52:29 +0900 (df2bc74) @@ -42,6 +42,24 @@ rb_grn_id_s_builtin_p (VALUE self, VALUE rb_id) return CBOOL2RVAL(grn_id_is_builtin(ctx, id)); } +/* + * @overload builtin_type?(id) + * @param [Integer] id The ID to be confirmed. + * @return [Boolean] `true` if the `id` is builtin_type, `false` otherwise. + * + * @since 6.0.9 + */ +static VALUE +rb_grn_id_s_builtin_type_p (VALUE self, VALUE rb_id) +{ + grn_ctx *ctx = NULL; + grn_id id; + + id = NUM2INT(rb_id); + + return CBOOL2RVAL(grn_id_is_builtin_type(ctx, id)); +} + void rb_grn_init_id (VALUE mGrn) { @@ -53,4 +71,5 @@ rb_grn_init_id (VALUE mGrn) rb_define_const(mGrnID, "MAX", INT2NUM(GRN_ID_MAX)); rb_define_singleton_method(mGrnID, "builtin?", rb_grn_id_s_builtin_p, 1); + rb_define_singleton_method(mGrnID, "builtin_type?", rb_grn_id_s_builtin_type_p, 1); } Modified: test/test-id.rb (+16 -0) =================================================================== --- test/test-id.rb 2016-10-06 17:27:15 +0900 (e4fb401) +++ test/test-id.rb 2016-10-07 15:52:29 +0900 (b8ac778) @@ -44,4 +44,20 @@ class IDTest < Test::Unit::TestCase end end end + + sub_test_case(".builtin_type?") do + test "true" do + assert do + Groonga::ID.builtin_type?(Groonga::Type::INT32) + end + end + + test "false" do + token_bigram_id = Groonga["TokenBigram"].id + + assert do + not Groonga::ID.builtin_type?(token_bigram_id) + end + end + end end -------------- next part -------------- HTML����������������������������...Download