Thanks to visit codestin.com
Credit goes to github.com

Skip to content

🐛 Fix SequenceSet merging in another SequenceSet #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/net/imap/sequence_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1341,8 +1341,8 @@ def tuple_add(tuple)
modifying!
min, max = tuple
lower, lower_idx = tuple_gte_with_index(min - 1)
if lower.nil? then tuples << tuple
elsif (max + 1) < lower.first then tuples.insert(lower_idx, tuple)
if lower.nil? then tuples << [min, max]
elsif (max + 1) < lower.first then tuples.insert(lower_idx, [min, max])
else tuple_coalesce(lower, lower_idx, min, max)
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/net/imap/test_sequence_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ def obj.to_sequence_set; 192_168.001_255 end
assert_equal seqset["1:3,5,7:9"], seqset["1,3,5,7:8"].merge(seqset["2,8:9"])
assert_equal seqset["1:*"], seqset["5:*"].merge(1..4)
assert_equal seqset["1:5"], seqset["1,3,5"].merge(seqset["2,4"])
# when merging frozen SequenceSet
set = SequenceSet.new
set.merge SequenceSet[1, 3, 5]
set.merge SequenceSet[2..33]
assert_equal seqset[1..33], set
end

test "set - other" do
Expand Down
Loading