Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parser: fix a keep bug that some texts may be dropped unexpectedly
Ruby: [Bug #18245] [ruby-core:105587] Reported by Hassan Abdul Rehman.
- Loading branch information
Showing
2 changed files
with
88 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require_relative "../helper" | ||
|
||
class TestCSVParseInputsScanner < Test::Unit::TestCase | ||
include Helper | ||
|
||
def test_keep_over_chunks_nested_back | ||
input = CSV::Parser::UnoptimizedStringIO.new("abcdefghijklmnl") | ||
scanner = CSV::Parser::InputsScanner.new([input], | ||
Encoding::UTF_8, | ||
nil, | ||
chunk_size: 2) | ||
scanner.keep_start | ||
assert_equal("abc", scanner.scan_all(/[a-c]+/)) | ||
scanner.keep_start | ||
assert_equal("def", scanner.scan_all(/[d-f]+/)) | ||
scanner.keep_back | ||
scanner.keep_back | ||
assert_equal("abcdefg", scanner.scan_all(/[a-g]+/)) | ||
end | ||
|
||
|
||
def test_keep_over_chunks_nested_drop_back | ||
input = CSV::Parser::UnoptimizedStringIO.new("abcdefghijklmnl") | ||
scanner = CSV::Parser::InputsScanner.new([input], | ||
Encoding::UTF_8, | ||
nil, | ||
chunk_size: 3) | ||
scanner.keep_start | ||
assert_equal("ab", scanner.scan(/../)) | ||
scanner.keep_start | ||
assert_equal("c", scanner.scan(/./)) | ||
assert_equal("d", scanner.scan(/./)) | ||
scanner.keep_drop | ||
scanner.keep_back | ||
assert_equal("abcdefg", scanner.scan_all(/[a-g]+/)) | ||
end | ||
end |