mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
parsers: cleanup warnings about errors and unused stuff
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
c224133382
commit
fbb0edd93b
8 changed files with 21 additions and 35 deletions
|
@ -90,7 +90,6 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::Element;
|
||||
use std::convert::TryFrom;
|
||||
use std::error::Error as StdError;
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[test]
|
||||
|
@ -165,7 +164,7 @@ mod tests {
|
|||
Error::ParseIntError(error) => error,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "invalid digit found in string");
|
||||
assert_eq!(message.to_string(), "invalid digit found in string");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -56,7 +56,6 @@ impl Into<Node> for DateTime {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use chrono::{Datelike, Timelike};
|
||||
use std::error::Error as StdError;
|
||||
|
||||
// DateTime’s size doesn’t depend on the architecture.
|
||||
#[test]
|
||||
|
@ -85,7 +84,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input is out of range");
|
||||
assert_eq!(message.to_string(), "input is out of range");
|
||||
|
||||
// Timezone ≥24:00 aren’t allowed.
|
||||
let error = DateTime::from_str("2017-05-27T12:11:02+25:00").unwrap_err();
|
||||
|
@ -93,7 +92,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input is out of range");
|
||||
assert_eq!(message.to_string(), "input is out of range");
|
||||
|
||||
// Timezone without the : separator aren’t allowed.
|
||||
let error = DateTime::from_str("2017-05-27T12:11:02+0100").unwrap_err();
|
||||
|
@ -101,7 +100,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input contains invalid characters");
|
||||
assert_eq!(message.to_string(), "input contains invalid characters");
|
||||
|
||||
// No seconds, error message could be improved.
|
||||
let error = DateTime::from_str("2017-05-27T12:11+01:00").unwrap_err();
|
||||
|
@ -109,7 +108,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input contains invalid characters");
|
||||
assert_eq!(message.to_string(), "input contains invalid characters");
|
||||
|
||||
// TODO: maybe we’ll want to support this one, as per XEP-0082 §4.
|
||||
let error = DateTime::from_str("20170527T12:11:02+01:00").unwrap_err();
|
||||
|
@ -117,7 +116,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input contains invalid characters");
|
||||
assert_eq!(message.to_string(), "input contains invalid characters");
|
||||
|
||||
// No timezone.
|
||||
let error = DateTime::from_str("2017-05-27T12:11:02").unwrap_err();
|
||||
|
@ -125,7 +124,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "premature end of input");
|
||||
assert_eq!(message.to_string(), "premature end of input");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -75,7 +75,6 @@ mod tests {
|
|||
use crate::util::error::Error;
|
||||
use crate::Element;
|
||||
use std::convert::TryFrom;
|
||||
use std::error::Error as StdError;
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[test]
|
||||
|
@ -146,7 +145,7 @@ mod tests {
|
|||
Error::ParseIntError(error) => error,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "invalid digit found in string");
|
||||
assert_eq!(message.to_string(), "invalid digit found in string");
|
||||
|
||||
let elem: Element = "<open xmlns='http://jabber.org/protocol/ibb' block-size='128'/>"
|
||||
.parse()
|
||||
|
|
|
@ -24,7 +24,6 @@ mod tests {
|
|||
use crate::util::error::Error;
|
||||
use crate::Element;
|
||||
use std::convert::TryFrom;
|
||||
use std::error::Error as StdError;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
|
@ -75,7 +74,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input is out of range");
|
||||
assert_eq!(message.to_string(), "input is out of range");
|
||||
|
||||
// Timezone ≥24:00 aren’t allowed.
|
||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='2017-05-27T12:11:02+25:00'/>"
|
||||
|
@ -86,7 +85,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input is out of range");
|
||||
assert_eq!(message.to_string(), "input is out of range");
|
||||
|
||||
// Timezone without the : separator aren’t allowed.
|
||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='2017-05-27T12:11:02+0100'/>"
|
||||
|
@ -97,7 +96,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input contains invalid characters");
|
||||
assert_eq!(message.to_string(), "input contains invalid characters");
|
||||
|
||||
// No seconds, error message could be improved.
|
||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='2017-05-27T12:11+01:00'/>"
|
||||
|
@ -108,7 +107,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input contains invalid characters");
|
||||
assert_eq!(message.to_string(), "input contains invalid characters");
|
||||
|
||||
// TODO: maybe we’ll want to support this one, as per XEP-0082 §4.
|
||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='20170527T12:11:02+01:00'/>"
|
||||
|
@ -119,7 +118,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "input contains invalid characters");
|
||||
assert_eq!(message.to_string(), "input contains invalid characters");
|
||||
|
||||
// No timezone.
|
||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='2017-05-27T12:11:02'/>"
|
||||
|
@ -130,7 +129,7 @@ mod tests {
|
|||
Error::ChronoParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "premature end of input");
|
||||
assert_eq!(message.to_string(), "premature end of input");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -27,7 +27,6 @@ mod tests {
|
|||
use crate::util::error::Error;
|
||||
use crate::Element;
|
||||
use std::convert::TryFrom;
|
||||
use std::error::Error as StdError;
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[test]
|
||||
|
@ -75,7 +74,7 @@ mod tests {
|
|||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(
|
||||
message.description(),
|
||||
message.to_string(),
|
||||
"number too large to fit in target type"
|
||||
);
|
||||
|
||||
|
@ -87,7 +86,7 @@ mod tests {
|
|||
Error::ParseIntError(error) => error,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message.description(), "invalid digit found in string");
|
||||
assert_eq!(message.to_string(), "invalid digit found in string");
|
||||
|
||||
let elem: Element =
|
||||
"<transport xmlns='urn:xmpp:jingle:transports:ibb:1' block-size='128'/>"
|
||||
|
|
|
@ -193,7 +193,6 @@ impl From<Prefs> for Element {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::data_forms::{DataFormType, Field, FieldType};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
|
|
|
@ -49,7 +49,6 @@ mod tests {
|
|||
use crate::util::error::Error;
|
||||
use crate::Element;
|
||||
use std::convert::TryFrom;
|
||||
use std::error::Error as StdError;
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[test]
|
||||
|
@ -103,10 +102,7 @@ mod tests {
|
|||
Error::ParseIntError(error) => error,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(
|
||||
error.description(),
|
||||
"cannot parse integer from empty string"
|
||||
);
|
||||
assert_eq!(error.to_string(), "cannot parse integer from empty string");
|
||||
|
||||
let elem: Element = "<media xmlns='urn:xmpp:media-element' width='coucou'/>"
|
||||
.parse()
|
||||
|
@ -116,7 +112,7 @@ mod tests {
|
|||
Error::ParseIntError(error) => error,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(error.description(), "invalid digit found in string");
|
||||
assert_eq!(error.to_string(), "invalid digit found in string");
|
||||
|
||||
let elem: Element = "<media xmlns='urn:xmpp:media-element' height=''/>"
|
||||
.parse()
|
||||
|
@ -126,10 +122,7 @@ mod tests {
|
|||
Error::ParseIntError(error) => error,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(
|
||||
error.description(),
|
||||
"cannot parse integer from empty string"
|
||||
);
|
||||
assert_eq!(error.to_string(), "cannot parse integer from empty string");
|
||||
|
||||
let elem: Element = "<media xmlns='urn:xmpp:media-element' height='-10'/>"
|
||||
.parse()
|
||||
|
@ -139,7 +132,7 @@ mod tests {
|
|||
Error::ParseIntError(error) => error,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(error.description(), "invalid digit found in string");
|
||||
assert_eq!(error.to_string(), "invalid digit found in string");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -236,7 +236,6 @@ generate_element!(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::error::Error as StdError;
|
||||
|
||||
#[test]
|
||||
fn test_simple() {
|
||||
|
@ -397,7 +396,7 @@ mod tests {
|
|||
Error::ParseIntError(error) => error,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(error.description(), "invalid digit found in string");
|
||||
assert_eq!(error.to_string(), "invalid digit found in string");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue