[Groonga-commit] ranguba/rroonga at 3dfde2e [master] Add tests for Regexp search for query string

Back to archive index

Masafumi Yokoyama null+****@clear*****
Wed Apr 8 12:31:19 JST 2015


Masafumi Yokoyama	2015-04-08 12:31:19 +0900 (Wed, 08 Apr 2015)

  New Revision: 3dfde2edbb0cc0a00c965f5ffef473c9854fabda
  https://github.com/ranguba/rroonga/commit/3dfde2edbb0cc0a00c965f5ffef473c9854fabda

  Merged 11f7364: Merge pull request #88 from ranguba/add-tests-for-regexp-search-for-query-string

  Message:
    Add tests for Regexp search for query string

  Modified files:
    test/test-expression-builder.rb

  Modified: test/test-expression-builder.rb (+43 -1)
===================================================================
--- test/test-expression-builder.rb    2015-04-08 11:17:14 +0900 (4294627)
+++ test/test-expression-builder.rb    2015-04-08 12:31:19 +0900 (31cc87b)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2014  Masafumi Yokoyama <myokoym �� gmail.com>
+# Copyright (C) 2014-2015  Masafumi Yokoyama <yokoyama �� clear-code.com>
 # Copyright (C) 2009-2012  Kouhei Sutou <kou �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
@@ -248,6 +248,48 @@ class ExpressionBuilderTest < Test::Unit::TestCase
     end
   end
 
+  class RegexpSearchTest < self
+    def setup_tables
+      Groonga::Schema.define do |schema|
+        schema.create_table("Users",
+                            :type => :hash,
+                            :key_type => "ShortText") do |table|
+          table.short_text("name")
+        end
+
+        schema.create_table("Terms",
+                            :type => :patricia_trie,
+                            :key_type => "ShortText",
+                            :default_tokenizer => "TokenRegexp",
+                            :normalizer => "NormalizerAuto") do |table|
+          table.index("Users.name")
+        end
+      end
+
+      @users = Groonga["Users"]
+    end
+
+    def setup_data
+      @users.add("sato",   :name => "taro sato")
+      @users.add("suzuki", :name => "Shiro SUZUKI")
+      @users.add("ito",    :name => "Takashi Ito")
+    end
+
+    class QueryStringTest < self
+      def test_match
+        result =****@users*****("name:~t")
+        assert_equal(["ito", "sato"],
+                     result.collect {|record| record.key.key}.sort)
+      end
+
+      def test_not_match
+        result =****@users*****("name:~x")
+        assert_equal([],
+                     result.collect {|record| record.key.key}.sort)
+      end
+    end
+  end
+
   class PrefixSearchTest < self
     def setup_tables
       Groonga::Schema.define do |schema|
-------------- next part --------------
HTML����������������������������...
Download 



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