diff options
| author | Tomoyuki Sahara <[email protected]> | 2013-03-08 09:45:04 +0900 |
|---|---|---|
| committer | Tomoyuki Sahara <[email protected]> | 2013-03-08 09:45:04 +0900 |
| commit | 11edea38804e2a7021c27e9d905bb001f3fce156 (patch) | |
| tree | a40a2142bbf8ae8ae99e7b13e6b60c619bbd6fea /mrbgems/mruby-string-ext/test | |
| parent | aa73a1068f2fd5cbff7e4623ab2036d360933ff9 (diff) | |
| download | mruby-11edea38804e2a7021c27e9d905bb001f3fce156.tar.gz mruby-11edea38804e2a7021c27e9d905bb001f3fce156.zip | |
add "strip" family to String.
Diffstat (limited to 'mrbgems/mruby-string-ext/test')
| -rw-r--r-- | mrbgems/mruby-string-ext/test/string.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb index d61ece351..eaff81890 100644 --- a/mrbgems/mruby-string-ext/test/string.rb +++ b/mrbgems/mruby-string-ext/test/string.rb @@ -16,3 +16,57 @@ end assert('String#dump') do "foo".dump == "\"foo\"" end + +assert('String#strip') do + s = " abc " + s.strip + "".strip == "" and " \t\r\n\f\v".strip == "" and + "\0a\0".strip == "\0a" and + "abc".strip == "abc" and + " abc".strip == "abc" and + "abc ".strip == "abc" and + " abc ".strip == "abc" and + s == " abc " +end + +assert('String#lstrip') do + s = " abc " + s.lstrip + "".lstrip == "" and " \t\r\n\f\v".lstrip == "" and + "\0a\0".lstrip == "\0a\0" and + "abc".lstrip == "abc" and + " abc".lstrip == "abc" and + "abc ".lstrip == "abc " and + " abc ".lstrip == "abc " and + s == " abc " +end + +assert('String#rstrip') do + s = " abc " + s.rstrip + "".rstrip == "" and " \t\r\n\f\v".rstrip == "" and + "\0a\0".rstrip == "\0a" and + "abc".rstrip == "abc" and + " abc".rstrip == " abc" and + "abc ".rstrip == "abc" and + " abc ".rstrip == " abc" and + s == " abc " +end + +assert('String#strip!') do + s = " abc " + t = "abc" + s.strip! == "abc" and s == "abc" and t.strip! == nil +end + +assert('String#lstrip!') do + s = " abc " + t = "abc " + s.lstrip! == "abc " and s == "abc " and t.lstrip! == nil +end + +assert('String#rstrip!') do + s = " abc " + t = " abc" + s.rstrip! == " abc" and s == " abc" and t.rstrip! == nil +end |
