Kouhei Sutou
null+****@clear*****
Mon May 16 16:49:57 JST 2016
Kouhei Sutou 2016-05-16 16:49:57 +0900 (Mon, 16 May 2016) New Revision: 1a51d583e70e3b75266ee411e9ad04ced5cf190e https://github.com/ranguba/rroonga/commit/1a51d583e70e3b75266ee411e9ad04ced5cf190e Message: Add Groonga::Type#number_family? Modified files: ext/groonga/rb-grn-type.c test/test-type.rb Modified: ext/groonga/rb-grn-type.c (+14 -0) =================================================================== --- ext/groonga/rb-grn-type.c 2016-05-16 16:35:19 +0900 (9767e9a) +++ ext/groonga/rb-grn-type.c 2016-05-16 16:49:57 +0900 (05ecccc) @@ -227,6 +227,18 @@ rb_grn_type_text_family_p (VALUE self) return CBOOL2RVAL(grn_obj_is_text_family_type(context, type)); } +static VALUE +rb_grn_type_number_family_p (VALUE self) +{ + grn_ctx *context = NULL; + grn_obj *type; + grn_id id; + + type = RVAL2GRNOBJECT(self, &context); + id = grn_obj_id(context, type); + return CBOOL2RVAL(grn_type_id_is_number_family(context, id)); +} + void rb_grn_init_type (VALUE mGrn) { @@ -249,6 +261,8 @@ rb_grn_init_type (VALUE mGrn) rb_define_method(rb_cGrnType, "float?", rb_grn_type_float_p, 0); rb_define_method(rb_cGrnType, "geo_point?", rb_grn_type_geo_point_p, 0); rb_define_method(rb_cGrnType, "text_family?", rb_grn_type_text_family_p, 0); + rb_define_method(rb_cGrnType, "number_family?", + rb_grn_type_number_family_p, 0); /* 任意のテーブルに属する全てのレコード(Object型はv1.2で サポートされます)。 */ Modified: test/test-type.rb (+68 -0) =================================================================== --- test/test-type.rb 2016-05-16 16:35:19 +0900 (fe92470) +++ test/test-type.rb 2016-05-16 16:49:57 +0900 (f00b606) @@ -123,6 +123,74 @@ class TypeTest < Test::Unit::TestCase end end + class NumberFamilyTest < self + def test_int8 + assert do + Groonga["Int8"].number_family? + end + end + + def test_uint8 + assert do + Groonga["UInt8"].number_family? + end + end + + def test_int16 + assert do + Groonga["Int16"].number_family? + end + end + + def test_uint16 + assert do + Groonga["UInt16"].number_family? + end + end + + def test_int32 + assert do + Groonga["Int32"].number_family? + end + end + + def test_uint32 + assert do + Groonga["UInt32"].number_family? + end + end + + def test_int64 + assert do + Groonga["Int64"].number_family? + end + end + + def test_uint64 + assert do + Groonga["UInt64"].number_family? + end + end + + def test_float + assert do + Groonga["Float"].number_family? + end + end + + def test_under_int8 + assert do + not Groonga["Bool"].number_family? + end + end + + def test_over_float + assert do + not Groonga["Time"].number_family? + end + end + end + def test_builtins assert_equal_type("Object", Groonga::Type::OBJECT) # FIXME!!! assert_equal_type("Bool", Groonga::Type::BOOLEAN) -------------- next part -------------- HTML����������������������������... Download