1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/ruby/test_shift_jis.rb

28 lines
798 B
Ruby
Raw Normal View History

# vim: set fileencoding=shift_jis
require "test/unit"
class TestShiftJIS < Test::Unit::TestCase
def test_mbc_case_fold
assert_match(/(<28><>)(a)\1\2/i, "<EFBFBD><EFBFBD>a<EFBFBD><EFBFBD>A")
assert_no_match(/(<28><>)(a)\1\2/i, "<EFBFBD><EFBFBD>a<EFBFBD>`A")
end
def test_property
assert_match(/<EFBFBD><EFBFBD>{0}\p{Hiragana}{4}/, "<EFBFBD>Ђ炪<EFBFBD><EFBFBD>")
assert_no_match(/<EFBFBD><EFBFBD>{0}\p{Hiragana}{4}/, "<EFBFBD>J<EFBFBD>^<5E>J<EFBFBD>i")
assert_no_match(/<EFBFBD><EFBFBD>{0}\p{Hiragana}{4}/, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
assert_no_match(/<EFBFBD><EFBFBD>{0}\p{Katakana}{4}/, "<EFBFBD>Ђ炪<EFBFBD><EFBFBD>")
assert_match(/<EFBFBD><EFBFBD>{0}\p{Katakana}{4}/, "<EFBFBD>J<EFBFBD>^<5E>J<EFBFBD>i")
assert_no_match(/<EFBFBD><EFBFBD>{0}\p{Katakana}{4}/, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
assert_raise(RegexpError) { Regexp.new('<27><>{0}\p{foobarbaz}') }
end
def test_code_to_mbclen
s = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
s << 0x82a9
assert_equal("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", s)
assert_raise(ArgumentError) { s << 0x82 }
end
end