TestComponent: Display assert errors as Display not Debug for easier xml coloring
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
dc9a56857c
commit
4d00060817
1 changed files with 12 additions and 2 deletions
|
@ -43,7 +43,7 @@ impl fmt::Debug for Expect {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Expect::")?;
|
write!(f, "Expect::")?;
|
||||||
match self {
|
match self {
|
||||||
Expect::Element(el) => write!(f, "Element({:?})", String::from(el)),
|
Expect::Element(el) => write!(f, "Element({})", String::from(el)),
|
||||||
Expect::Iq(_, desc) => write!(f, "Iq(<cb>, {})", desc),
|
Expect::Iq(_, desc) => write!(f, "Iq(<cb>, {})", desc),
|
||||||
Expect::Message(_, desc) => write!(f, "Message(<cb>, {})", desc),
|
Expect::Message(_, desc) => write!(f, "Message(<cb>, {})", desc),
|
||||||
Expect::Presence(_, desc) => write!(f, "Presence(<cb>, {})", desc),
|
Expect::Presence(_, desc) => write!(f, "Presence(<cb>, {})", desc),
|
||||||
|
@ -167,7 +167,17 @@ impl Component {
|
||||||
|
|
||||||
match expected {
|
match expected {
|
||||||
Some(expected) => match expected {
|
Some(expected) => match expected {
|
||||||
Expect::Element(el) => assert_eq!(String::from(&el), String::from(&out)),
|
Expect::Element(el) => {
|
||||||
|
let (expected, actual) = (String::from(&el), String::from(&out));
|
||||||
|
if expected != actual {
|
||||||
|
panic!(
|
||||||
|
r#"assertion failed: `(actual == expected)`
|
||||||
|
actual: `{}`,
|
||||||
|
expected: `{}`"#,
|
||||||
|
actual, expected
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Expect::Iq(cb, _) => match Iq::try_from(out.0.clone()) {
|
Expect::Iq(cb, _) => match Iq::try_from(out.0.clone()) {
|
||||||
Ok(iq) => cb(iq),
|
Ok(iq) => cb(iq),
|
||||||
_ => panic!(
|
_ => panic!(
|
||||||
|
|
Loading…
Reference in a new issue