# test_01.rb: test for suikyo.rb # $Id: test_01.rb,v 1.1 2003/06/02 17:36:25 komatsu Exp $ # # Copyright (C) 2003 Hiroyuki Komatsu # All rights reserved. # This is free software with ABSOLUTELY NO WARRANTY. # # You can redistribute it and/or modify it under the terms of # the GNU General Public License version 2. # $LOAD_PATH.push(File::dirname($0) + "/..") require 'suikyo/suikyo' require 'codetest' extend(CodeTest) $KCODE = 'e' # Beginning of Test suikyo = Suikyo.new suikyo.table.loadfile("romaji-kana") ### 普通にローマ字をひらがなに変換する. codetest("suikyo.convert(\"suikyou\")", __LINE__) { a = suikyo.convert("suikyou") suikyo.convert("suikyou") == "すいきょう".toeuc } ### 語尾が確定していない場合は, 取りうる候補を配列で返す. codetest("suikyo.expand(\"suiky\")", __LINE__) { (hiragana, hiragana_array) = suikyo.expand("suiky") hiragana == "すいky".toeuc and hiragana_array == ["すいきゃ".toeuc, "すいきょ".toeuc, "すいきぇ".toeuc, "すいきぃ".toeuc, "すいきゅ".toeuc] } ### SuikyoTable クラス codetest("SuikyoTable Class", __LINE__) { table1 = SuikyoTable.new table1.loadfile("romaji-kana") suikyo1 = Suikyo.new(table1) suikyo1.convert("SuIKyoU") == "SうIKよU".toeuc } ### SuikyoTable2 クラス codetest("SuikyoTable2 Class", __LINE__) { table2 = SuikyoTable2.new table2.loadfile("romaji-kana") suikyo2 = Suikyo.new(table2) suikyo2.convert("SuIKyoU") == "すいきょう".toeuc }