1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#[cfg(test)]
mod tests {
use imap_types::{
command::{Command, CommandBody},
core::{Literal, NonEmptyVec},
response::{Capability, Code, Greeting},
};
use crate::testing::{kat_inverse_command, kat_inverse_greeting};
#[test]
fn test_kat_inverse_command_login_literal_plus() {
kat_inverse_command(&[
(
b"A LOGIN {0}\r\n {1}\r\nA\r\n".as_ref(),
b"".as_ref(),
Command::new(
"A",
CommandBody::login(
Literal::try_from("").unwrap(),
Literal::try_from("A").unwrap(),
)
.unwrap(),
)
.unwrap(),
),
(
b"A LOGIN {1}\r\nA {2}\r\nAB\r\n?".as_ref(),
b"?".as_ref(),
Command::new(
"A",
CommandBody::login(
Literal::try_from("A").unwrap(),
Literal::try_from("AB").unwrap(),
)
.unwrap(),
)
.unwrap(),
),
(
b"A LOGIN {0+}\r\n {1+}\r\nA\r\n??".as_ref(),
b"??".as_ref(),
Command::new(
"A",
CommandBody::login(
Literal::try_from("").unwrap().into_non_sync(),
Literal::try_from("A").unwrap().into_non_sync(),
)
.unwrap(),
)
.unwrap(),
),
(
b"A LOGIN {1+}\r\nA {2+}\r\nAB\r\n???".as_ref(),
b"???".as_ref(),
Command::new(
"A",
CommandBody::login(
Literal::try_from("A").unwrap().into_non_sync(),
Literal::try_from("AB").unwrap().into_non_sync(),
)
.unwrap(),
)
.unwrap(),
),
]);
}
#[test]
fn test_kat_inverse_greeting_capability_literal_plus() {
kat_inverse_greeting(&[
(
b"* OK [CAPABILITY LITERAL+] ...\r\n".as_ref(),
b"".as_ref(),
Greeting::ok(
Some(Code::Capability(NonEmptyVec::from(Capability::LiteralPlus))),
"...",
)
.unwrap(),
),
(
b"* OK [CAPABILITY LITERAL-] ...\r\n?",
b"?",
Greeting::ok(
Some(Code::Capability(NonEmptyVec::from(
Capability::LiteralMinus,
))),
"...",
)
.unwrap(),
),
]);
}
}