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

more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-12-09 00:31:02 +00:00
parent 78eae5da62
commit 56f8092459

View file

@ -63,3 +63,61 @@ assert_equal 'ok', %q{
s1.casecmp(s2) == 0 ? :ng : :ok
}
assert_equal 'EUC-JP', %q{ ("\xc2\xa1 %s".force_encoding("EUC-JP") % "foo").encoding.name }
assert_equal 'true', %q{ "\xa1\xa2\xa3\xa4".force_encoding("euc-jp")["\xa2\xa3".force_encoding("euc-jp")] == nil }
assert_equal 'ok', %q{
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
begin
s["\xb0\xa3"] = "foo"
:ng
rescue IndexError
:ok
end
}
assert_equal 'EUC-JP', %q{ "\xa3\xb0".force_encoding("EUC-JP").center(10).encoding.name }
assert_equal 'ok', %q{
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
begin
s.chomp("\xa3\xb4".force_encoding("shift_jis"))
:ng
rescue ArgumentError
:ok
end
}
assert_equal 'ok', %q{
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
begin
s.count("\xa3\xb0".force_encoding("ascii-8bit"))
:ng
rescue ArgumentError
:ok
end
}
assert_equal 'ok', %q{
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
begin
s.delete("\xa3\xb2".force_encoding("ascii-8bit"))
:ng
rescue ArgumentError
:ok
end
}
assert_equal 'ok', %q{
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
begin
s.each_line("\xa3\xb1".force_encoding("ascii-8bit")) {|l| }
:ng
rescue ArgumentError
:ok
end
}
assert_equal 'true', %q{
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
s.gsub(/\xa3\xb1/e, "z") == "\xa3\xb0z\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
}