Skip to content

Commit

Permalink
✅ Improve UIDPlusData#uid_mapping test coverage
Browse files Browse the repository at this point in the history
Explicitly test how unsorted uid-sets are handled.
  • Loading branch information
nevans committed Jan 31, 2025
1 parent 3512246 commit 0cfea2a
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/net/imap/test_uid_plus_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

require "net/imap"
require "test/unit"

class TestUIDPlusData < Test::Unit::TestCase

test "#uid_mapping with sorted source_uids" do
uidplus = Net::IMAP::UIDPlusData.new(
1, [19, 20, *(495..500)], [*(92..97), 100, 101],
)
assert_equal(
{
19 => 92,
20 => 93,
495 => 94,
496 => 95,
497 => 96,
498 => 97,
499 => 100,
500 => 101,
},
uidplus.uid_mapping
)
end

test "#uid_mapping for with source_uids in unsorted order" do
uidplus = Net::IMAP::UIDPlusData.new(
1, [*(495..500), 19, 20], [*(92..97), 100, 101],
)
assert_equal(
{
495 => 92,
496 => 93,
497 => 94,
498 => 95,
499 => 96,
500 => 97,
19 => 100,
20 => 101,
},
uidplus.uid_mapping
)
end

end

0 comments on commit 0cfea2a

Please sign in to comment.