Skip to content

Commit bb9d829

Browse files
committed
Improve C API specs
1 parent 40c6850 commit bb9d829

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

spec/ruby/optional/capi/string_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,10 @@ def inspect
12511251
result2 = @s.rb_enc_interned_str_cstr(str, Encoding::UTF_8)
12521252
result1.should_not.equal?(result2)
12531253
end
1254+
1255+
it "returns the same string as String#-@" do
1256+
@s.rb_enc_interned_str_cstr("hello", Encoding::UTF_8).should.equal?(-"hello")
1257+
end
12541258
end
12551259

12561260
describe "rb_str_to_interned_str" do
@@ -1267,5 +1271,15 @@ def inspect
12671271
result2 = @s.rb_str_to_interned_str(str)
12681272
result1.should.equal?(result2)
12691273
end
1274+
1275+
it "returns different frozen strings for different encodings" do
1276+
result1 = @s.rb_str_to_interned_str("hello".force_encoding(Encoding::US_ASCII))
1277+
result2 = @s.rb_str_to_interned_str("hello".force_encoding(Encoding::UTF_8))
1278+
result1.should_not.equal?(result2)
1279+
end
1280+
1281+
it "returns the same string as String#-@" do
1282+
@s.rb_str_to_interned_str("hello").should.equal?(-"hello")
1283+
end
12701284
end
12711285
end

0 commit comments

Comments
 (0)