mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 07:26:00 +02:00
* enc/utf_16be.c (UTF16_IS_SURROGATE_FIRST): avoid branch.
(UTF16_IS_SURROGATE_SECOND): ditto. (UTF16_IS_SURROGATE): defined. (utf16be_mbc_enc_len): validation implemented. * enc/utf_16le.c (UTF16_IS_SURROGATE_FIRST): avoid branch. (UTF16_IS_SURROGATE_SECOND): ditto. (UTF16_IS_SURROGATE): defined. (utf16le_mbc_enc_len): validation implemented. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8e36fa69fd
commit
44cfd58dc5
4 changed files with 108 additions and 9 deletions
|
@ -48,8 +48,59 @@ EOT
|
|||
# tests start
|
||||
|
||||
def test_utf16be_valid_encoding
|
||||
s = "\xd8\x00\xd8\x00".force_encoding("utf-16be")
|
||||
assert_equal(false, s.valid_encoding?, "#{encdump s}.valid_encoding?")
|
||||
[
|
||||
"\x00\x00",
|
||||
"\xd7\xff",
|
||||
"\xd8\x00\xdc\x00",
|
||||
"\xdb\xff\xdf\xff",
|
||||
"\xe0\x00",
|
||||
"\xff\xff",
|
||||
].each {|s|
|
||||
s.force_encoding("utf-16be")
|
||||
assert_equal(true, s.valid_encoding?, "#{encdump s}.valid_encoding?")
|
||||
}
|
||||
[
|
||||
"\x00",
|
||||
"\xd7",
|
||||
"\xd8\x00",
|
||||
"\xd8\x00\xd8\x00",
|
||||
"\xdc\x00",
|
||||
"\xdc\x00\xd8\x00",
|
||||
"\xdc\x00\xdc\x00",
|
||||
"\xe0",
|
||||
"\xff",
|
||||
].each {|s|
|
||||
s.force_encoding("utf-16be")
|
||||
assert_equal(false, s.valid_encoding?, "#{encdump s}.valid_encoding?")
|
||||
}
|
||||
end
|
||||
|
||||
def test_utf16le_valid_encoding
|
||||
[
|
||||
"\x00\x00",
|
||||
"\xff\xd7",
|
||||
"\x00\xd8\x00\xdc",
|
||||
"\xff\xdb\xff\xdf",
|
||||
"\x00\xe0",
|
||||
"\xff\xff",
|
||||
].each {|s|
|
||||
s.force_encoding("utf-16le")
|
||||
assert_equal(true, s.valid_encoding?, "#{encdump s}.valid_encoding?")
|
||||
}
|
||||
[
|
||||
"\x00",
|
||||
"\xd7",
|
||||
"\x00\xd8",
|
||||
"\x00\xd8\x00\xd8",
|
||||
"\x00\xdc",
|
||||
"\x00\xdc\x00\xd8",
|
||||
"\x00\xdc\x00\xdc",
|
||||
"\xe0",
|
||||
"\xff",
|
||||
].each {|s|
|
||||
s.force_encoding("utf-16le")
|
||||
assert_equal(false, s.valid_encoding?, "#{encdump s}.valid_encoding?")
|
||||
}
|
||||
end
|
||||
|
||||
def test_strftime
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue