# Copyright (C) 2009 Kouhei Sutou # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA class SchemaTest < Test::Unit::TestCase include GroongaTestUtils setup :setup_database def test_create_table assert_nil(context[""]) Groonga::Schema.create_table("") do |table| end assert_not_nil(context[""]) end def test_define_hash Groonga::Schema.create_table("", :type => :hash) do |table| end assert_kind_of(Groonga::Hash, context[""]) end def test_define_hash_with_full_option path = @tmp_dir + "hash.groonga" tokenizer = context[""] Groonga::Schema.create_table("", :type => :hash, :key_type => "integer", :path => path.to_s, :value_size => 29, :default_tokenizer => tokenizer) do |table| end table = context[""] assert_equal("#, " + "name: <>, " + "path: <#{path}>, " + "domain: <#{context[''].inspect}>, " + "range: , " + "encoding: <#{Groonga::Encoding.default.inspect}>, " + "size: <0>>", table.inspect) assert_equal(tokenizer, table.default_tokenizer) end def test_define_patricia_trie Groonga::Schema.create_table("", :type => :patricia_trie) do |table| end assert_kind_of(Groonga::PatriciaTrie, context[""]) end def test_define_patricia_trie_with_full_option path = @tmp_dir + "patricia-trie.groonga" Groonga::Schema.create_table("", :type => :patricia_trie, :key_type => "integer", :path => path.to_s, :value_size => 29, :default_tokenizer => "", :key_normalize => true, :key_with_sis => true) do |table| end table = context[""] assert_equal("#, " + "name: <>, " + "path: <#{path}>, " + "domain: <#{context[''].inspect}>, " + "range: , " + "encoding: <#{Groonga::Encoding.default.inspect}>, " + "size: <0>>", table.inspect) assert_equal(context[""], table.default_tokenizer) end def test_define_array Groonga::Schema.create_table("", :type => :array) do |table| end assert_kind_of(Groonga::Array, context[""]) end def test_define_array_with_full_option path = @tmp_dir + "array.groonga" Groonga::Schema.create_table("", :type => :array, :path => path.to_s, :value_size => 29) do |table| end table = context[""] assert_equal("#, " + "name: <>, " + "path: <#{path}>, " + "domain: , " + "range: , " + "size: <0>>", table.inspect) end def test_integer32_column assert_nil(context[".rate"]) Groonga::Schema.create_table("") do |table| table.integer32 :rate end assert_equal(context[""], context[".rate"].range) end def test_integer64_column assert_nil(context[".rate"]) Groonga::Schema.create_table("") do |table| table.integer64 :rate end assert_equal(context[""], context[".rate"].range) end def test_unsigned_integer32_column assert_nil(context[".n_viewed"]) Groonga::Schema.create_table("") do |table| table.unsigned_integer32 :n_viewed end assert_equal(context[""], context[".n_viewed"].range) end def test_unsigned_integer64_column assert_nil(context[".n_viewed"]) Groonga::Schema.create_table("") do |table| table.unsigned_integer64 :n_viewed end assert_equal(context[""], context[".n_viewed"].range) end def test_float_column assert_nil(context[".rate"]) Groonga::Schema.create_table("") do |table| table.float :rate end assert_equal(context[""], context[".rate"].range) end def test_time_column assert_nil(context[".last_modified"]) Groonga::Schema.create_table("") do |table| table.time :last_modified end assert_equal(context["