テストプログラム

  • setup()で初期化
     require 'test/unit'
     require 'romakana'
     $KCODE = 'utf8' # 指定が必要
     class TestRomakana < Test::Unit::TestCase
      def setup
       @hira = "あいうえおぁぃぅぇぉ\
     かきくけこがぎぐげごさしすせそ\
     ざじずぜぞたちつてとっだぢづでどっ\
     なにぬねのはひふへほまみむめも\
     やゆよゃゅょらりるれろわをんー".split(//)
      end
      def test_001
       10.times { |count|
        h = (0..7).collect { |i|
         @hira[rand(@hira.length)]
        }.join
        roma = h.hiragana2roma
        assert(roma.length > 0)
        h2 = roma.roma2hiragana
        assert_equal(h,h2)
       
      end
     end