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:
Maxime “pep” Buquet 2022-10-15 19:05:12 +02:00
parent dc9a56857c
commit 4d00060817
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -43,7 +43,7 @@ impl fmt::Debug for Expect {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Expect::")?;
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::Message(_, desc) => write!(f, "Message(<cb>, {})", desc),
Expect::Presence(_, desc) => write!(f, "Presence(<cb>, {})", desc),
@ -167,7 +167,17 @@ impl Component {
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()) {
Ok(iq) => cb(iq),
_ => panic!(