[Groonga-commit] ranguba/rroonga at c2c7162 [master] Add Operator::REGEXP

Back to archive index

Masafumi Yokoyama null+****@clear*****
Tue Apr 7 17:57:31 JST 2015


Masafumi Yokoyama	2015-04-07 17:57:31 +0900 (Tue, 07 Apr 2015)

  New Revision: c2c7162ac7870bcb85fc88f6e38768b7607be5b7
  https://github.com/ranguba/rroonga/commit/c2c7162ac7870bcb85fc88f6e38768b7607be5b7

  Merged 27eb6f9: Merge pull request #87 from ranguba/add-operator-regexp

  Message:
    Add Operator::REGEXP
    
    GitHub: #65

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

  Modified: ext/groonga/rb-grn-operator.c (+4 -0)
===================================================================
--- ext/groonga/rb-grn-operator.c    2015-04-03 14:51:52 +0900 (fc5860c)
+++ ext/groonga/rb-grn-operator.c    2015-04-07 17:57:31 +0900 (ea63f9a)
@@ -220,6 +220,8 @@ rb_grn_operator_from_ruby_object (VALUE rb_operator)
     } else if (rb_grn_equal_option(rb_operator, "json-put") ||
                rb_grn_equal_option(rb_operator, "json_put")) {
         operator = GRN_OP_JSON_PUT;
+    } else if (rb_grn_equal_option(rb_operator, "regexp")) {
+        operator = GRN_OP_REGEXP;
     } else {
         rb_raise(rb_eArgError,
                  "operator should be one of "
@@ -426,6 +428,8 @@ rb_grn_init_operator (VALUE mGrn)
                     UINT2NUM(GRN_OP_TABLE_GROUP));
     rb_define_const(rb_mGrnOperator, "JSON_PUT",
                     UINT2NUM(GRN_OP_JSON_PUT));
+    rb_define_const(rb_mGrnOperator, "REGEXP",
+                    UINT2NUM(GRN_OP_REGEXP));
 
 
 /*

  Added: test/test-operator.rb (+59 -0) 100644
===================================================================
--- /dev/null
+++ test/test-operator.rb    2015-04-07 17:57:31 +0900 (a23a0fe)
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015  Masafumi Yokoyama <yokoyama �� 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
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+class OperatorTest < Test::Unit::TestCase
+  include GroongaTestUtils
+
+  setup :setup_database
+
+  class RegexpTest < self
+    setup
+    def setup_expression
+      @expression = Groonga::Expression.new
+      @expression.append_constant(39)
+      @expression.append_constant(93)
+    end
+
+    def test_constant
+      @expression.append_operation(Groonga::Operator::REGEXP, 2)
+      assert_equal(<<-END_OF_INSPECT.chomp, @expression.inspect)
+#<Groonga::Expression
+  vars:{
+  },
+  codes:{
+    0:<push n_args:1, flags:0, modify:2, value:39>,
+    1:<push n_args:1, flags:0, modify:0, value:93>,
+    2:<regexp n_args:2, flags:0, modify:0, value:(NULL)>
+  }>
+      END_OF_INSPECT
+    end
+
+    def test_name
+      @expression.append_operation("regexp", 2)
+      assert_equal(<<-END_OF_INSPECT.chomp, @expression.inspect)
+#<Groonga::Expression
+  vars:{
+  },
+  codes:{
+    0:<push n_args:1, flags:0, modify:2, value:39>,
+    1:<push n_args:1, flags:0, modify:0, value:93>,
+    2:<regexp n_args:2, flags:0, modify:0, value:(NULL)>
+  }>
+      END_OF_INSPECT
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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