Unverified Commit d2c325d0 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4325 from shuujii/fix-missing-assertions-in-mruby-string-ext-test

Fix missing assertions in `mruby-string-ext` test
parents 07b9a10c e3b339be
...@@ -33,62 +33,72 @@ assert('String#byteslice') do ...@@ -33,62 +33,72 @@ assert('String#byteslice') do
end end
assert('String#dump') do assert('String#dump') do
("\1" * 100).dump # should not raise an exception - regress #1210 assert_equal("\"\\x00\"", "\0".dump)
"\0".inspect == "\"\\000\"" and assert_equal("\"foo\"", "foo".dump)
"foo".dump == "\"foo\"" assert_nothing_raised { ("\1" * 100).dump } # regress #1210
end end
assert('String#strip') do assert('String#strip') do
s = " abc " s = " abc "
"".strip == "" and " \t\r\n\f\v".strip == "" and assert_equal("abc", s.strip)
"\0a\0".strip == "\0a" and assert_equal(" abc ", s)
"abc".strip == "abc" and assert_equal("", "".strip)
" abc".strip == "abc" and assert_equal("", " \t\r\n\f\v".strip)
"abc ".strip == "abc" and assert_equal("\0a", "\0a\0".strip)
" abc ".strip == "abc" and assert_equal("abc", "abc".strip)
s == " abc " assert_equal("abc", " abc".strip)
assert_equal("abc", "abc ".strip)
end end
assert('String#lstrip') do assert('String#lstrip') do
s = " abc " s = " abc "
s.lstrip assert_equal("abc ", s.lstrip)
"".lstrip == "" and " \t\r\n\f\v".lstrip == "" and assert_equal(" abc ", s)
"\0a\0".lstrip == "\0a\0" and assert_equal("", "".lstrip)
"abc".lstrip == "abc" and assert_equal("", " \t\r\n\f\v".lstrip)
" abc".lstrip == "abc" and assert_equal("\0a\0", "\0a\0".lstrip)
"abc ".lstrip == "abc " and assert_equal("abc", "abc".lstrip)
" abc ".lstrip == "abc " and assert_equal("abc", " abc".lstrip)
s == " abc " assert_equal("abc ", "abc ".lstrip)
end end
assert('String#rstrip') do assert('String#rstrip') do
s = " abc " s = " abc "
s.rstrip assert_equal(" abc", s.rstrip)
"".rstrip == "" and " \t\r\n\f\v".rstrip == "" and assert_equal(" abc ", s)
"\0a\0".rstrip == "\0a" and assert_equal("", "".rstrip)
"abc".rstrip == "abc" and assert_equal("", " \t\r\n\f\v".rstrip)
" abc".rstrip == " abc" and assert_equal("\0a", "\0a\0".rstrip)
"abc ".rstrip == "abc" and assert_equal("abc", "abc".rstrip)
" abc ".rstrip == " abc" and assert_equal(" abc", " abc".rstrip)
s == " abc " assert_equal("abc", "abc ".rstrip)
end end
assert('String#strip!') do assert('String#strip!') do
s = " abc " s = " abc "
t = "abc" t = "abc"
s.strip! == "abc" and s == "abc" and t.strip! == nil assert_equal("abc", s.strip!)
assert_equal("abc", s)
assert_nil(t.strip!)
assert_equal("abc", t)
end end
assert('String#lstrip!') do assert('String#lstrip!') do
s = " abc " s = " abc "
t = "abc " t = "abc "
s.lstrip! == "abc " and s == "abc " and t.lstrip! == nil assert_equal("abc ", s.lstrip!)
assert_equal("abc ", s)
assert_nil(t.lstrip!)
assert_equal("abc ", t)
end end
assert('String#rstrip!') do assert('String#rstrip!') do
s = " abc " s = " abc "
t = " abc" t = " abc"
s.rstrip! == " abc" and s == " abc" and t.rstrip! == nil assert_equal(" abc", s.rstrip!)
assert_equal(" abc", s)
assert_nil(t.rstrip!)
assert_equal(" abc", t)
end end
assert('String#swapcase') do assert('String#swapcase') do
...@@ -127,7 +137,7 @@ assert('String#count') do ...@@ -127,7 +137,7 @@ assert('String#count') do
assert_equal 4, s.count("a0-9") assert_equal 4, s.count("a0-9")
end end
assert('String#tr') do assert('String#tr') do
assert_equal "ABC", "abc".tr('a-z', 'A-Z') assert_equal "ABC", "abc".tr('a-z', 'A-Z')
assert_equal "hippo", "hello".tr('el', 'ip') assert_equal "hippo", "hello".tr('el', 'ip')
assert_equal "Ruby", "Lisp".tr("Lisp", "Ruby") assert_equal "Ruby", "Lisp".tr("Lisp", "Ruby")
...@@ -141,7 +151,7 @@ assert('String#tr!') do ...@@ -141,7 +151,7 @@ assert('String#tr!') do
assert_equal "ab12222hijklmnopqR", s assert_equal "ab12222hijklmnopqR", s
end end
assert('String#tr_s') do assert('String#tr_s') do
assert_equal "hero", "hello".tr_s('l', 'r') assert_equal "hero", "hello".tr_s('l', 'r')
assert_equal "h*o", "hello".tr_s('el', '*') assert_equal "h*o", "hello".tr_s('el', '*')
assert_equal "hhxo", "hello".tr_s('el', 'hx') assert_equal "hhxo", "hello".tr_s('el', 'hx')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment