summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorstomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-21 19:27:08 +0000
committerstomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-21 19:27:08 +0000
commit913afdf95c3edf40d49d31e9b153ad8ef3cd17dd (patch)
treeca4e96cfa480ad79d3ef52ef64be7b6e5ddf6097 /test
parent47f2bd93347b3acc04cbb2cd44ca25e87c0d0ab5 (diff)
test_string.rb,test_symbol.rb: add some tests
* test/ruby/test_string.rb: add more test cases for String#casecmp. * test/ruby/test_symbol.rb: ditto for Symbol#{casecmp,casecmp?}. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb3
-rw-r--r--test/ruby/test_symbol.rb6
2 files changed, 8 insertions, 1 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 0bfca5ad05..e1b27fc2be 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -2317,6 +2317,9 @@ CODE
=end
def test_casecmp
+ assert_equal(0, "FoO".casecmp("fOO"))
+ assert_equal(1, "FoO".casecmp("BaR"))
+ assert_equal(-1, "baR".casecmp("FoO"))
assert_equal(1, "\u3042B".casecmp("\u3042a"))
end
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 279c23cdb8..e7f3d5a527 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -286,15 +286,19 @@ class TestSymbol < Test::Unit::TestCase
assert_equal(0, :FoO.casecmp(:fOO))
assert_equal(1, :FoO.casecmp(:BaR))
assert_equal(-1, :baR.casecmp(:FoO))
+
assert_nil(:foo.casecmp("foo"))
+ assert_nil(:foo.casecmp(Object.new))
end
def test_casecmp?
assert_equal(true, :FoO.casecmp?(:fOO))
assert_equal(false, :FoO.casecmp?(:BaR))
assert_equal(false, :baR.casecmp?(:FoO))
- assert_nil(:foo.casecmp?("foo"))
assert_equal(true, :äöü.casecmp?(:ÄÖÜ))
+
+ assert_nil(:foo.casecmp?("foo"))
+ assert_nil(:foo.casecmp?(Object.new))
end
def test_length