summaryrefslogtreecommitdiff
path: root/test/ruby/test_m17n.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-08 20:42:45 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-08 20:42:45 +0000
commit800f04c6a521c007e9837813b3564ae6b491e31c (patch)
treee91082d62cad55b091d9e7f42a1dad6090dc227e /test/ruby/test_m17n.rb
parent5393622dad7f5204333b8aa6a39263a961bdc77a (diff)
* numeric.c (rb_enc_uint_char): raise RangeError when added codepoint
is invalid. [Feature #5855] [Bug #5863] [Bug #5864] * string.c (rb_str_concat): ditto. * string.c (rb_str_concat): set encoding as ASCII-8BIT when the string is US-ASCII and the argument is an integer greater than 127. * regenc.c (onigenc_mb2_code_to_mbclen): rearrange error code. * enc/euc_jp.c (code_to_mbclen): ditto. * enc/shift_jis.c (code_to_mbclen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_m17n.rb')
-rw-r--r--test/ruby/test_m17n.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index fffcab3def..7c261138ba 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1161,6 +1161,7 @@ class TestM17N < Test::Unit::TestCase
def test_str_concat
assert_equal(1, "".concat(0xA2).size)
+ assert_equal(Encoding::ASCII_8BIT, "".force_encoding("US-ASCII").concat(0xA2).encoding)
assert_equal("A\x84\x31\xA4\x39".force_encoding("GB18030"),
"A".force_encoding("GB18030") << 0x8431A439)
end
@@ -1220,6 +1221,14 @@ class TestM17N < Test::Unit::TestCase
2206368128.chr(Encoding::UTF_8)
}
assert_not_match(/-\d+ out of char range/, e.message)
+
+ assert_raise(RangeError){ 0x80.chr("US-ASCII") }
+ assert_raise(RangeError){ 0x80.chr("SHIFT_JIS") }
+ assert_raise(RangeError){ 0xE0.chr("SHIFT_JIS") }
+ assert_raise(RangeError){ 0x100.chr("SHIFT_JIS") }
+ assert_raise(RangeError){ 0xA0.chr("EUC-JP") }
+ assert_raise(RangeError){ 0x100.chr("EUC-JP") }
+ assert_raise(RangeError){ 0xA1A0.chr("EUC-JP") }
end
def test_marshal