1require 'test/unit' 2 3require '../tool/jisx0208' 4 5class Test_JISX0208_Char < Test::Unit::TestCase 6 def test_create_with_row_cell 7 assert_equal JISX0208::Char.new(0x2121), JISX0208::Char.new(1, 1) 8 end 9 10 def test_succ 11 assert_equal JISX0208::Char.new(0x2221), JISX0208::Char.new(0x217e).succ 12 assert_equal JISX0208::Char.new(2, 1), JISX0208::Char.new(1, 94).succ 13 assert_equal JISX0208::Char.new(0x7f21), JISX0208::Char.new(0x7e7e).succ 14 end 15 16 def test_to_shift_jis 17 assert_equal 0x895C, JISX0208::Char.new(0x313D).to_sjis 18 assert_equal 0x895C, JISX0208::Char.from_sjis(0x895C).to_sjis 19 assert_equal 0xF3DE, JISX0208::Char.from_sjis(0xF3DE).to_sjis 20 assert_equal 0xFC40, JISX0208::Char.from_sjis(0xFC40).to_sjis 21 end 22 23 def test_from_sjis 24 assert_raise(ArgumentError) { JISX0208::Char.from_sjis(-1) } 25 assert_raise(ArgumentError) { JISX0208::Char.from_sjis(0x10000) } 26 assert_nothing_raised { JISX0208::Char.from_sjis(0x8140) } 27 assert_nothing_raised { JISX0208::Char.from_sjis(0xFCFC) } 28 assert_equal JISX0208::Char.new(0x313D), JISX0208::Char.from_sjis(0x895C) 29 end 30 31 def test_row 32 assert_equal 1, JISX0208::Char.new(0x2121).row 33 assert_equal 94, JISX0208::Char.new(0x7E7E).row 34 end 35 36 def test_cell 37 assert_equal 1, JISX0208::Char.new(0x2121).cell 38 assert_equal 94, JISX0208::Char.new(0x7E7E).cell 39 end 40end 41