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 super::*;
|
||||||
use crate::Element;
|
use crate::Element;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::error::Error as StdError;
|
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -165,7 +164,7 @@ mod tests {
|
||||||
Error::ParseIntError(error) => error,
|
Error::ParseIntError(error) => error,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message.description(), "invalid digit found in string");
|
assert_eq!(message.to_string(), "invalid digit found in string");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -56,7 +56,6 @@ impl Into<Node> for DateTime {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use chrono::{Datelike, Timelike};
|
use chrono::{Datelike, Timelike};
|
||||||
use std::error::Error as StdError;
|
|
||||||
|
|
||||||
// DateTime’s size doesn’t depend on the architecture.
|
// DateTime’s size doesn’t depend on the architecture.
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -85,7 +84,7 @@ mod tests {
|
||||||
Error::ChronoParseError(string) => string,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => 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.
|
// Timezone ≥24:00 aren’t allowed.
|
||||||
let error = DateTime::from_str("2017-05-27T12:11:02+25:00").unwrap_err();
|
let error = DateTime::from_str("2017-05-27T12:11:02+25:00").unwrap_err();
|
||||||
|
@ -93,7 +92,7 @@ mod tests {
|
||||||
Error::ChronoParseError(string) => string,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => 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.
|
// Timezone without the : separator aren’t allowed.
|
||||||
let error = DateTime::from_str("2017-05-27T12:11:02+0100").unwrap_err();
|
let error = DateTime::from_str("2017-05-27T12:11:02+0100").unwrap_err();
|
||||||
|
@ -101,7 +100,7 @@ mod tests {
|
||||||
Error::ChronoParseError(string) => string,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => 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.
|
// No seconds, error message could be improved.
|
||||||
let error = DateTime::from_str("2017-05-27T12:11+01:00").unwrap_err();
|
let error = DateTime::from_str("2017-05-27T12:11+01:00").unwrap_err();
|
||||||
|
@ -109,7 +108,7 @@ mod tests {
|
||||||
Error::ChronoParseError(string) => string,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => 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.
|
// 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();
|
let error = DateTime::from_str("20170527T12:11:02+01:00").unwrap_err();
|
||||||
|
@ -117,7 +116,7 @@ mod tests {
|
||||||
Error::ChronoParseError(string) => string,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message.description(), "input contains invalid characters");
|
assert_eq!(message.to_string(), "input contains invalid characters");
|
||||||
|
|
||||||
// No timezone.
|
// No timezone.
|
||||||
let error = DateTime::from_str("2017-05-27T12:11:02").unwrap_err();
|
let error = DateTime::from_str("2017-05-27T12:11:02").unwrap_err();
|
||||||
|
@ -125,7 +124,7 @@ mod tests {
|
||||||
Error::ChronoParseError(string) => string,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message.description(), "premature end of input");
|
assert_eq!(message.to_string(), "premature end of input");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -75,7 +75,6 @@ mod tests {
|
||||||
use crate::util::error::Error;
|
use crate::util::error::Error;
|
||||||
use crate::Element;
|
use crate::Element;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::error::Error as StdError;
|
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -146,7 +145,7 @@ mod tests {
|
||||||
Error::ParseIntError(error) => error,
|
Error::ParseIntError(error) => error,
|
||||||
_ => panic!(),
|
_ => 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'/>"
|
let elem: Element = "<open xmlns='http://jabber.org/protocol/ibb' block-size='128'/>"
|
||||||
.parse()
|
.parse()
|
||||||
|
|
|
@ -24,7 +24,6 @@ mod tests {
|
||||||
use crate::util::error::Error;
|
use crate::util::error::Error;
|
||||||
use crate::Element;
|
use crate::Element;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::error::Error as StdError;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -75,7 +74,7 @@ mod tests {
|
||||||
Error::ChronoParseError(string) => string,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => 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.
|
// Timezone ≥24:00 aren’t allowed.
|
||||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='2017-05-27T12:11:02+25:00'/>"
|
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,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => 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.
|
// Timezone without the : separator aren’t allowed.
|
||||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='2017-05-27T12:11:02+0100'/>"
|
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,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => 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.
|
// No seconds, error message could be improved.
|
||||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='2017-05-27T12:11+01:00'/>"
|
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,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => 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.
|
// 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'/>"
|
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,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message.description(), "input contains invalid characters");
|
assert_eq!(message.to_string(), "input contains invalid characters");
|
||||||
|
|
||||||
// No timezone.
|
// No timezone.
|
||||||
let elem: Element = "<idle xmlns='urn:xmpp:idle:1' since='2017-05-27T12:11:02'/>"
|
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,
|
Error::ChronoParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message.description(), "premature end of input");
|
assert_eq!(message.to_string(), "premature end of input");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -27,7 +27,6 @@ mod tests {
|
||||||
use crate::util::error::Error;
|
use crate::util::error::Error;
|
||||||
use crate::Element;
|
use crate::Element;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::error::Error as StdError;
|
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -75,7 +74,7 @@ mod tests {
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
message.description(),
|
message.to_string(),
|
||||||
"number too large to fit in target type"
|
"number too large to fit in target type"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -87,7 +86,7 @@ mod tests {
|
||||||
Error::ParseIntError(error) => error,
|
Error::ParseIntError(error) => error,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message.description(), "invalid digit found in string");
|
assert_eq!(message.to_string(), "invalid digit found in string");
|
||||||
|
|
||||||
let elem: Element =
|
let elem: Element =
|
||||||
"<transport xmlns='urn:xmpp:jingle:transports:ibb:1' block-size='128'/>"
|
"<transport xmlns='urn:xmpp:jingle:transports:ibb:1' block-size='128'/>"
|
||||||
|
|
|
@ -193,7 +193,6 @@ impl From<Prefs> for Element {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::data_forms::{DataFormType, Field, FieldType};
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
@ -49,7 +49,6 @@ mod tests {
|
||||||
use crate::util::error::Error;
|
use crate::util::error::Error;
|
||||||
use crate::Element;
|
use crate::Element;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::error::Error as StdError;
|
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -103,10 +102,7 @@ mod tests {
|
||||||
Error::ParseIntError(error) => error,
|
Error::ParseIntError(error) => error,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(error.to_string(), "cannot parse integer from empty string");
|
||||||
error.description(),
|
|
||||||
"cannot parse integer from empty string"
|
|
||||||
);
|
|
||||||
|
|
||||||
let elem: Element = "<media xmlns='urn:xmpp:media-element' width='coucou'/>"
|
let elem: Element = "<media xmlns='urn:xmpp:media-element' width='coucou'/>"
|
||||||
.parse()
|
.parse()
|
||||||
|
@ -116,7 +112,7 @@ mod tests {
|
||||||
Error::ParseIntError(error) => error,
|
Error::ParseIntError(error) => error,
|
||||||
_ => panic!(),
|
_ => 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=''/>"
|
let elem: Element = "<media xmlns='urn:xmpp:media-element' height=''/>"
|
||||||
.parse()
|
.parse()
|
||||||
|
@ -126,10 +122,7 @@ mod tests {
|
||||||
Error::ParseIntError(error) => error,
|
Error::ParseIntError(error) => error,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(error.to_string(), "cannot parse integer from empty string");
|
||||||
error.description(),
|
|
||||||
"cannot parse integer from empty string"
|
|
||||||
);
|
|
||||||
|
|
||||||
let elem: Element = "<media xmlns='urn:xmpp:media-element' height='-10'/>"
|
let elem: Element = "<media xmlns='urn:xmpp:media-element' height='-10'/>"
|
||||||
.parse()
|
.parse()
|
||||||
|
@ -139,7 +132,7 @@ mod tests {
|
||||||
Error::ParseIntError(error) => error,
|
Error::ParseIntError(error) => error,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(error.description(), "invalid digit found in string");
|
assert_eq!(error.to_string(), "invalid digit found in string");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -236,7 +236,6 @@ generate_element!(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::error::Error as StdError;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_simple() {
|
fn test_simple() {
|
||||||
|
@ -397,7 +396,7 @@ mod tests {
|
||||||
Error::ParseIntError(error) => error,
|
Error::ParseIntError(error) => error,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(error.description(), "invalid digit found in string");
|
assert_eq!(error.to_string(), "invalid digit found in string");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue