diff options
| author | h2so5 <[email protected]> | 2013-04-19 14:10:10 +0900 |
|---|---|---|
| committer | h2so5 <[email protected]> | 2013-04-19 21:01:37 +0900 |
| commit | 79e7bbc8e819da79928dbf928382c17d85239497 (patch) | |
| tree | ed3a33b241bc0e7aa2794f069776fadebf8b6b66 /mrbgems/mruby-string-ext/test | |
| parent | b9674c735e7b06205c3b8bface31792ee1354778 (diff) | |
| download | mruby-79e7bbc8e819da79928dbf928382c17d85239497.tar.gz mruby-79e7bbc8e819da79928dbf928382c17d85239497.zip | |
Add String#swapcase,swapcase!,concat,casecmp,start_with,end_with
Diffstat (limited to 'mrbgems/mruby-string-ext/test')
| -rw-r--r-- | mrbgems/mruby-string-ext/test/string.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb index eaff81890..ce4bc7352 100644 --- a/mrbgems/mruby-string-ext/test/string.rb +++ b/mrbgems/mruby-string-ext/test/string.rb @@ -70,3 +70,41 @@ assert('String#rstrip!') do t = " abc" s.rstrip! == " abc" and s == " abc" and t.rstrip! == nil end + +assert('String#swapcase') do + assert_equal "Hello".swapcase, "hELLO" + assert_equal "cYbEr_PuNk11".swapcase, "CyBeR_pUnK11" +end + +assert('String#swapcase!') do + s = "Hello" + t = s.clone + t.swapcase! + assert_equal s.swapcase, t +end + +assert('String#concat') do + s = "Hello " + s.concat "World!" + t = "Hello " + t << "World!" + assert_equal "Hello World!", t + assert_equal "Hello World!", s +end + +assert('String#casecmp') do + assert_equal "abcdef".casecmp("abcde"), 1 + assert_equal "aBcDeF".casecmp("abcdef"), 0 + assert_equal "abcdef".casecmp("abcdefg"),-1 + assert_equal "abcdef".casecmp("ABCDEF"), 0 +end + +assert('String#start_with?') do + assert_true "hello".start_with?("heaven", "hell") + assert_true !"hello".start_with?("heaven", "paradise") +end + +assert('String#end_with?') do + assert_true "string".end_with?("ing", "mng") + assert_true !"string".end_with?("str", "tri") +end |
