-#!/usr/bin/env ruby
-# Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
-
-$VERBOSE = true
-$LOAD_PATH.unshift("..")
-require "test/unit"
-require "libchise_c"
-require "chise/qp"
-
-class TestLibChise < Test::Unit::TestCase
- def test_libchise
- db_dir = CHISE::DB_DIR
- assert_equal("/cygdrive/c/chise/chise-db", db_dir)
-
- @ds = CHISE::DataSource.new(CHISE::DataSource::Berkeley_DB, db_dir, 0, 0755)
- assert_instance_of(CHISE::DataSource, @ds)
-
- char_id = @ds.decode_char("=daikanwa", 364)
- assert_equal(0x4ECF, char_id)
-
- ccs = @ds.get_ccs("=daikanwa")
- assert_instance_of(CHISE::CCS, ccs)
- char_id = ccs.decode(364)
- assert_equal(0x4ECF, char_id)
-
- feature = @ds.get_feature("ideographic-structure")
- assert_instance_of(CHISE::Feature, feature)
- value = feature.get_value(char_id)
- assert_instance_of(CHISE::Value, value)
- assert_equal("(?\342\277\260 ?\344\272\273 ?\345\216\266)", value.to_s)
-
- @ds.each_feature_name {|name|
- assert_instance_of(String, name)
- }
-
- feature = @ds.get_feature("numeric-value")
- feature.each_char {|cid, valdatum|
- assert_kind_of(Numeric, cid)
- assert_instance_of(CHISE::Value, valdatum)
-
- ucs = @ds.get_feature("=ucs").get_value(cid)
- if ucs
- assert_instance_of(CHISE::Value, ucs)
- else
- ucs = @ds.get_feature("=>ucs").get_value(cid)
- if ucs
- assert_instance_of(CHISE::Value, ucs)
- end
- end
-
- name = @ds.get_feature("name").get_value(cid)
- if name
- assert_instance_of(CHISE::Value, name)
- end
- }
-
- @ds.close
- end
-end