diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-19 09:52:46 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-19 09:52:46 +0000 |
commit | 7213568733f673da0d82f95e8a1bccf79ba3f0d3 (patch) | |
tree | e2c85abdef41de0ae9d641ce7e9ba6174c0e0b20 /test/ruby/test_m17n.rb | |
parent | d13724306efdebd4557a02f30ea9368dcbb3e465 (diff) |
string.c: setbyte silently ignores upper bits
The behaviour of String#setbyte has been depending on the width
of int, which is not portable. Must check explicitly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_m17n.rb')
-rw-r--r-- | test/ruby/test_m17n.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 80750baf30..0251315fcf 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1524,6 +1524,17 @@ class TestM17N < Test::Unit::TestCase } end + def test_setbyte_range + s = u("\xE3\x81\x82\xE3\x81\x84") + assert_raise(RangeError) { s.setbyte(0, -1) } + assert_nothing_raised { s.setbyte(0, 0x00) } + assert_nothing_raised { s.setbyte(0, 0x7F) } + assert_nothing_raised { s.setbyte(0, 0x80) } + assert_nothing_raised { s.setbyte(0, 0xff) } + assert_raise(RangeError) { s.setbyte(0, 0x100) } + assert_raise(RangeError) { s.setbyte(0, 0x4f7574206f6620636861722072616e6765) } + end + def test_compatible assert_nil Encoding.compatible?("",0) assert_equal(Encoding::UTF_8, Encoding.compatible?(u(""), ua("abc"))) |