Kouhei Sutou
null+****@clear*****
Tue Dec 30 15:59:23 JST 2014
Kouhei Sutou 2014-12-30 15:59:23 +0900 (Tue, 30 Dec 2014) New Revision: 0b200a89936f003cf5521e1278a98ee76d210db1 https://github.com/ranguba/rroonga/commit/0b200a89936f003cf5521e1278a98ee76d210db1 Message: test: add a test for indexed case Modified files: test/test-column.rb Modified: test/test-column.rb (+28 -1) =================================================================== --- test/test-column.rb 2014-12-30 15:54:25 +0900 (c54d5cb) +++ test/test-column.rb 2014-12-30 15:59:23 +0900 (ce9f9ab) @@ -538,7 +538,7 @@ class ColumnTest < Test::Unit::TestCase @posts = Groonga["Posts"] end - def test_truncate + def test_not_indexed body1 = "body1" body2 = "body2" records = [ @@ -552,5 +552,32 @@ class ColumnTest < Test::Unit::TestCase assert_equal([nil, nil], records.collect(&:body)) end + + def test_indexed + Groonga::Schema.define do |schema| + schema.create_table("Terms", + :type => :patricia_trie, + :key_type => "ShortText", + :default_tokenizer => "TokenBigram", + :normalizer => "NormalizerAuto") do |table| + table.index("Posts.body") + end + end + + post1 =****@posts*****("title1", :body => "body1") + post2 =****@posts*****("title2", :body => "body2") + + select = lambda do + @posts.select {|record| record.body =~ "1"}.collect(&:_key) + end + + assert_equal(["title1"], select.call) + @posts.column("body").truncate + assert_equal([], select.call) + + post1.body = "body1" + post2.body = "body2" + assert_equal(["title1"], select.call) + end end end -------------- next part -------------- HTML����������������������������...Télécharger