summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-04 05:19:36 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-04 05:19:36 +0000
commit27fbb1ea85ef572070c6548584cadbc1bc62140e (patch)
tree0bbdb16698914d0cdbda463eeac8e9bd1d2a7e0b /test
parent3567a062c85b03e5d8b1c084068237088070f8d3 (diff)
merges r20451 from trunk into ruby_1_9_1.
* test/ruby/test_string.rb: add some tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index cd32709658..eba0256439 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1714,4 +1714,47 @@ class TestString < Test::Unit::TestCase
def test_gsub_enumerator
assert_normal_exit %q{"abc".gsub(/./).next}, "[ruby-dev:34828]"
end
+
+ def test_clear_nonasciicompat
+ assert_equal("", "\u3042".encode("ISO-2022-JP").clear)
+ end
+
+ def test_try_convert
+ assert_equal(nil, String.try_convert(1))
+ assert_equal("foo", String.try_convert("foo"))
+ end
+
+ def test_substr_negative_begin
+ assert_equal("\u3042", ("\u3042" * 100)[-1])
+ end
+
+ def test_compare_different_encoding_string
+ s1 = "\xff".force_encoding("UTF-8")
+ s2 = "\xff".force_encoding("ISO-2022-JP")
+ #assert_equal([-1, 1], [s1 <=> s2, s2 <=> s1].sort)
+ end
+
+ def test_casecmp
+ assert_equal(1, "\u3042B".casecmp("\u3042a"))
+ end
+
+ def test_upcase2
+ assert_equal("\u3042AB", "\u3042aB".upcase)
+ end
+
+ def test_downcase2
+ assert_equal("\u3042ab", "\u3042aB".downcase)
+ end
+
+ def test_rstrip
+ assert_equal("\u3042", "\u3042 ".rstrip)
+ assert_raise(Encoding::CompatibilityError) { "\u3042".encode("ISO-2022-JP").rstrip }
+ end
+
+ def test_symbol_table_overflow
+ return
+ assert_in_out_err([], <<-INPUT, [], /symbol table overflow \(symbol [a-z]{8}\) \(RuntimeError\)/)
+ ("aaaaaaaa".."zzzzzzzz").each {|s| s.to_sym }
+ INPUT
+ end
end