diff options
author | NAITOH Jun <[email protected]> | 2024-01-14 21:26:10 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-01-19 10:49:12 +0900 |
commit | 91f35305807f7303bfb58ccdffe86820a2300b8c (patch) | |
tree | 7e617e111a8c47b4cd692ed6ba76eb5dc66a2975 /test | |
parent | ac636f5709feb1d9d7a0c46a86be153be765cf21 (diff) |
[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
https://github.com/ruby/strscan/commit/d0508518a9
Diffstat (limited to 'test')
-rw-r--r-- | test/strscan/test_stringscanner.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/strscan/test_stringscanner.rb b/test/strscan/test_stringscanner.rb index 29626b159f..d15c1d8568 100644 --- a/test/strscan/test_stringscanner.rb +++ b/test/strscan/test_stringscanner.rb @@ -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) |