blocking, jingle_ft: Split #[cfg] sections into their own tests.
This commit is contained in:
parent
ee511e653a
commit
8b15728bb2
2 changed files with 46 additions and 42 deletions
|
@ -155,17 +155,6 @@ mod tests {
|
|||
},
|
||||
];
|
||||
|
||||
#[cfg(not(feature = "compat"))]
|
||||
{
|
||||
let request_elem = elem.clone();
|
||||
let error = BlocklistRequest::try_from(request_elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown child in blocklist element.");
|
||||
}
|
||||
|
||||
let result_elem = elem.clone();
|
||||
let result = BlocklistResult::try_from(result_elem).unwrap();
|
||||
assert_eq!(result.items, two_items);
|
||||
|
@ -221,4 +210,16 @@ mod tests {
|
|||
};
|
||||
assert_eq!(message, "Unknown attribute in unblock element.");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "compat"))]
|
||||
#[test]
|
||||
fn test_non_empty_blocklist_request() {
|
||||
let elem: Element = "<blocklist xmlns='urn:xmpp:blocking'><item jid='coucou@coucou'/><item jid='domain'/></blocklist>".parse().unwrap();
|
||||
let error = BlocklistRequest::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown child in blocklist element.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -510,17 +510,6 @@ mod tests {
|
|||
};
|
||||
assert_eq!(message, "Unknown child in received element.");
|
||||
|
||||
#[cfg(not(feature = "compat"))]
|
||||
{
|
||||
let elem: Element = "<received xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator' coucou=''/>".parse().unwrap();
|
||||
let error = Received::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in received element.");
|
||||
}
|
||||
|
||||
let elem: Element =
|
||||
"<received xmlns='urn:xmpp:jingle:apps:file-transfer:5' creator='initiator'/>"
|
||||
.parse()
|
||||
|
@ -541,6 +530,18 @@ mod tests {
|
|||
assert_eq!(message, "Unknown value for 'creator' attribute.");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "compat"))]
|
||||
#[test]
|
||||
fn test_invalid_received() {
|
||||
let elem: Element = "<received xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator' coucou=''/>".parse().unwrap();
|
||||
let error = Received::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in received element.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_checksum() {
|
||||
let elem: Element = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator'><file><hash xmlns='urn:xmpp:hashes:2' algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash></file></checksum>".parse().unwrap();
|
||||
|
@ -578,17 +579,6 @@ mod tests {
|
|||
};
|
||||
assert_eq!(message, "This is not a file element.");
|
||||
|
||||
#[cfg(not(feature = "compat"))]
|
||||
{
|
||||
let elem: Element = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator' coucou=''><file><hash xmlns='urn:xmpp:hashes:2' algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash></file></checksum>".parse().unwrap();
|
||||
let error = Checksum::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in checksum element.");
|
||||
}
|
||||
|
||||
let elem: Element = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' creator='initiator'><file><hash xmlns='urn:xmpp:hashes:2' algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash></file></checksum>".parse().unwrap();
|
||||
let error = Checksum::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
|
@ -606,6 +596,18 @@ mod tests {
|
|||
assert_eq!(message, "Unknown value for 'creator' attribute.");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "compat"))]
|
||||
#[test]
|
||||
fn test_invalid_checksum() {
|
||||
let elem: Element = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator' coucou=''><file><hash xmlns='urn:xmpp:hashes:2' algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash></file></checksum>".parse().unwrap();
|
||||
let error = Checksum::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in checksum element.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range() {
|
||||
let elem: Element = "<range xmlns='urn:xmpp:jingle:apps:file-transfer:5'/>"
|
||||
|
@ -633,18 +635,19 @@ mod tests {
|
|||
assert_eq!(range2.offset, 2048);
|
||||
assert_eq!(range2.length, Some(1024));
|
||||
assert_eq!(range2.hashes, hashes);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "compat"))]
|
||||
#[test]
|
||||
fn test_invalid_range() {
|
||||
let elem: Element = "<range xmlns='urn:xmpp:jingle:apps:file-transfer:5' coucou=''/>"
|
||||
.parse()
|
||||
.unwrap();
|
||||
#[cfg(not(feature = "compat"))]
|
||||
{
|
||||
let error = Range::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in range element.");
|
||||
}
|
||||
let error = Range::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in range element.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue