summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/casecmp_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/casecmp_spec.rb')
-rw-r--r--spec/ruby/core/string/casecmp_spec.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/spec/ruby/core/string/casecmp_spec.rb b/spec/ruby/core/string/casecmp_spec.rb
index 986fbc8718..90577aaac0 100644
--- a/spec/ruby/core/string/casecmp_spec.rb
+++ b/spec/ruby/core/string/casecmp_spec.rb
@@ -26,11 +26,11 @@ describe "String#casecmp independent of case" do
end
it "returns nil if other can't be converted to a string" do
- "abc".casecmp(mock('abc')).should be_nil
+ "abc".casecmp(mock('abc')).should == nil
end
it "returns nil if incompatible encodings" do
- "あれ".casecmp("れ".encode(Encoding::EUC_JP)).should be_nil
+ "あれ".casecmp("れ".encode(Encoding::EUC_JP)).should == nil
end
describe "in UTF-8 mode" do
@@ -117,6 +117,11 @@ describe "String#casecmp independent of case" do
"B".casecmp(a).should == 1
end
end
+
+ it "returns 0 for empty strings in different encodings" do
+ ''.b.casecmp('').should == 0
+ ''.b.casecmp(''.encode("UTF-32LE")).should == 0
+ end
end
describe 'String#casecmp? independent of case' do
@@ -138,7 +143,7 @@ describe 'String#casecmp? independent of case' do
end
it "returns nil if incompatible encodings" do
- "あれ".casecmp?("れ".encode(Encoding::EUC_JP)).should be_nil
+ "あれ".casecmp?("れ".encode(Encoding::EUC_JP)).should == nil
end
describe 'for UNICODE characters' do
@@ -185,10 +190,15 @@ describe 'String#casecmp? independent of case' do
end
it "case folds" do
- "ß".casecmp?("ss").should be_true
+ "ß".casecmp?("ss").should == true
end
it "returns nil if other can't be converted to a string" do
- "abc".casecmp?(mock('abc')).should be_nil
+ "abc".casecmp?(mock('abc')).should == nil
+ end
+
+ it "returns true for empty strings in different encodings" do
+ ''.b.should.casecmp?('')
+ ''.b.should.casecmp?(''.encode("UTF-32LE"))
end
end