Skip to content

Commit 0cfea2a

Browse files
committed
✅ Improve UIDPlusData#uid_mapping test coverage
Explicitly test how unsorted uid-sets are handled.
1 parent 3512246 commit 0cfea2a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/net/imap/test_uid_plus_data.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# frozen_string_literal: true
2+
3+
require "net/imap"
4+
require "test/unit"
5+
6+
class TestUIDPlusData < Test::Unit::TestCase
7+
8+
test "#uid_mapping with sorted source_uids" do
9+
uidplus = Net::IMAP::UIDPlusData.new(
10+
1, [19, 20, *(495..500)], [*(92..97), 100, 101],
11+
)
12+
assert_equal(
13+
{
14+
19 => 92,
15+
20 => 93,
16+
495 => 94,
17+
496 => 95,
18+
497 => 96,
19+
498 => 97,
20+
499 => 100,
21+
500 => 101,
22+
},
23+
uidplus.uid_mapping
24+
)
25+
end
26+
27+
test "#uid_mapping for with source_uids in unsorted order" do
28+
uidplus = Net::IMAP::UIDPlusData.new(
29+
1, [*(495..500), 19, 20], [*(92..97), 100, 101],
30+
)
31+
assert_equal(
32+
{
33+
495 => 92,
34+
496 => 93,
35+
497 => 94,
36+
498 => 95,
37+
499 => 96,
38+
500 => 97,
39+
19 => 100,
40+
20 => 101,
41+
},
42+
uidplus.uid_mapping
43+
)
44+
end
45+
46+
end

0 commit comments

Comments
 (0)