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

* encoding.c (rb_enc_compatible): empty strings are always compatible.

* string.c (rb_enc_cr_str_buf_cat): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-02-16 09:02:12 +00:00
parent de7c3793c0
commit 7eeba5f440
4 changed files with 62 additions and 3 deletions

View file

@ -169,9 +169,49 @@ EOT
enccall("aa".force_encoding("UTF-16BE"), :slice!, -1)
end
def test_concat
def test_plus_empty1
s1 = ""
s2 = "aa".force_encoding("utf-16be")
assert_nothing_raised("#{encdump s1} << #{encdump s2}") {
s1 + s2
}
end
def test_plus_empty2
s1 = "aa"
s2 = "".force_encoding("utf-16be")
assert_nothing_raised("#{encdump s1} << #{encdump s2}") {
s1 + s2
}
end
def test_plus_nonempty
s1 = "aa"
s2 = "bb".force_encoding("utf-16be")
assert_raise(ArgumentError, "#{encdump s1} << #{encdump s2}") {
s1 + s2
}
end
def test_concat_empty1
s1 = ""
s2 = "aa".force_encoding("utf-16be")
assert_nothing_raised("#{encdump s1} << #{encdump s2}") {
s1 << s2
}
end
def test_concat_empty2
s1 = "aa"
s2 = "".force_encoding("utf-16be")
assert_nothing_raised("#{encdump s1} << #{encdump s2}") {
s1 << s2
}
end
def test_concat_nonempty
s1 = "aa"
s2 = "bb".force_encoding("utf-16be")
assert_raise(ArgumentError, "#{encdump s1} << #{encdump s2}") {
s1 << s2
}