[Groonga-commit] ranguba/rroonga at 53f483c [master] Add Groonga::Type#text_family?

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Apr 20 22:14:29 JST 2016


Kouhei Sutou	2016-04-20 22:14:29 +0900 (Wed, 20 Apr 2016)

  New Revision: 53f483cf8ced152c73e377d18830949f14ff8630
  https://github.com/ranguba/rroonga/commit/53f483cf8ced152c73e377d18830949f14ff8630

  Message:
    Add Groonga::Type#text_family?

  Modified files:
    ext/groonga/rb-grn-type.c
    test/test-type.rb

  Modified: ext/groonga/rb-grn-type.c (+12 -1)
===================================================================
--- ext/groonga/rb-grn-type.c    2016-04-20 15:01:18 +0900 (d0024f7)
+++ ext/groonga/rb-grn-type.c    2016-04-20 22:14:29 +0900 (9767e9a)
@@ -1,6 +1,6 @@
 /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
-  Copyright (C) 2009-2012  Kouhei Sutou <kou �� clear-code.com>
+  Copyright (C) 2009-2016  Kouhei Sutou <kou �� clear-code.com>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -217,6 +217,16 @@ rb_grn_type_geo_point_p (VALUE self)
     return CBOOL2RVAL(key_type == GRN_OBJ_KEY_GEO_POINT);
 }
 
+static VALUE
+rb_grn_type_text_family_p (VALUE self)
+{
+    grn_ctx *context = NULL;
+    grn_obj *type;
+
+    type = RVAL2GRNOBJECT(self, &context);
+    return CBOOL2RVAL(grn_obj_is_text_family_type(context, type));
+}
+
 void
 rb_grn_init_type (VALUE mGrn)
 {
@@ -238,6 +248,7 @@ 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);
 
     /* 任意のテーブルに属する全てのレコード(Object型はv1.2で
        サポートされます)。 */

  Modified: test/test-type.rb (+33 -1)
===================================================================
--- test/test-type.rb    2016-04-20 15:01:18 +0900 (9defdbf)
+++ test/test-type.rb    2016-04-20 22:14:29 +0900 (fe92470)
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2012  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2009-2016  Kouhei Sutou <kou �� clear-code.com>
 # Copyright (C) 2015  Masafumi Yokoyama <yokoyama �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
@@ -91,6 +91,38 @@ class TypeTest < Test::Unit::TestCase
     assert_false(Groonga["UInt32"].geo_point?)
   end
 
+  class TextFamilyTest < self
+    def test_short_text
+      assert do
+        Groonga["ShortText"].text_family?
+      end
+    end
+
+    def test_text
+      assert do
+        Groonga["Text"].text_family?
+      end
+    end
+
+    def test_long_text
+      assert do
+        Groonga["LongText"].text_family?
+      end
+    end
+
+    def test_under_short_text
+      assert do
+        not Groonga["Time"].text_family?
+      end
+    end
+
+    def test_over_long_text
+      assert do
+        not Groonga["TokyoGeoPoint"].text_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����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index