Skip to content

Commit d8d8428

Browse files
authored
πŸ”€ Merge pull request #392 from ruby/uidplus_data_test_coverage
βœ… Improve UIDPlusData test coverage
2 parents a4f98ba + 3d52d84 commit d8d8428

File tree

4 files changed

+94
-58
lines changed

4 files changed

+94
-58
lines changed

β€Žtest/net/imap/test_imap_response_data.rb

Lines changed: 0 additions & 58 deletions
This file was deleted.

β€Žtest/net/imap/test_imap_response_parser.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,25 @@ def test_fetch_binary_and_binary_size
202202
Net::IMAP.debug = debug
203203
end
204204

205+
test "COPYUID with backwards ranges" do
206+
parser = Net::IMAP::ResponseParser.new
207+
response = parser.parse(
208+
"A004 OK [copyUID 9999 20:19,500:495 92:97,101:100] Done\r\n"
209+
)
210+
code = response.data.code
211+
assert_equal(
212+
{
213+
19 => 92,
214+
20 => 93,
215+
495 => 94,
216+
496 => 95,
217+
497 => 96,
218+
498 => 97,
219+
499 => 100,
220+
500 => 101,
221+
},
222+
code.data.uid_mapping
223+
)
224+
end
225+
205226
end
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# frozen_string_literal: true
2+
3+
require "net/imap"
4+
require "test/unit"
5+
6+
class ThreadMemberTest < Test::Unit::TestCase
7+
8+
test "#to_sequence_set" do
9+
# copied from the fourth example in RFC5256: (3 6 (4 23)(44 7 96))
10+
thmember = Net::IMAP::ThreadMember.method :new
11+
thread = thmember.(3, [
12+
thmember.(6, [
13+
thmember.(4, [
14+
thmember.(23, [])
15+
]),
16+
thmember.(44, [
17+
thmember.(7, [
18+
thmember.(96, [])
19+
])
20+
])
21+
])
22+
])
23+
expected = Net::IMAP::SequenceSet.new("3:4,6:7,23,44,96")
24+
assert_equal(expected, thread.to_sequence_set)
25+
end
26+
27+
end
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)