mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
[ruby/strscan] Add test to check encoding for empty string
(https://github.com/ruby/strscan/pull/80)
See: https://github.com/ruby/strscan/issues/78#issuecomment-1890849891
d0508518a9
This commit is contained in:
parent
ac636f5709
commit
91f3530580
1 changed files with 10 additions and 0 deletions
|
@ -558,6 +558,16 @@ module StringScannerTests
|
|||
assert_nil s.matched_size
|
||||
end
|
||||
|
||||
def test_empty_encoding_utf8
|
||||
ss = create_string_scanner('')
|
||||
assert_equal(Encoding::UTF_8, ss.rest.encoding)
|
||||
end
|
||||
|
||||
def test_empty_encoding_ascii_8bit
|
||||
ss = create_string_scanner(''.dup.force_encoding("ASCII-8BIT"))
|
||||
assert_equal(Encoding::ASCII_8BIT, ss.rest.encoding)
|
||||
end
|
||||
|
||||
def test_encoding
|
||||
ss = create_string_scanner("\xA1\xA2".dup.force_encoding("euc-jp"))
|
||||
assert_equal(Encoding::EUC_JP, ss.scan(/./e).encoding)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue