minidom: Implement PartialEq manually for Node and Element

Move the NamespaceAwareCompare implementation from xmpp-parsers as Node
and Element's PartialEq implementation. Thanks Astro!

It's a lot more useful in tests to use `assert_eq!` than `assert!`, so
we get both items compared (left and right) instead of a "it failed."
message.

This "breaks" comparison for these two structs in the sense that it is
not strict object comparison anymore but it ensures that namespaces are
all present in the compared objects.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2019-11-29 14:33:17 +01:00
commit 1c5551a917
No known key found for this signature in database
GPG key ID: DEDA74AEECA9D0F2
20 changed files with 65 additions and 172 deletions

View file

@ -246,7 +246,6 @@ impl From<PubSubEvent> for Element {
#[cfg(test)]
mod tests {
use super::*;
use crate::util::compare_elements::NamespaceAwareCompare;
use std::str::FromStr;
#[test]
@ -420,6 +419,6 @@ mod tests {
}
let elem2: Element = event.into();
assert!(elem.compare_to(&elem2));
assert_eq!(elem, elem2);
}
}

View file

@ -518,7 +518,6 @@ impl From<PubSub> for Element {
#[cfg(test)]
mod tests {
use super::*;
use crate::util::compare_elements::NamespaceAwareCompare;
#[test]
fn create() {
@ -536,7 +535,7 @@ mod tests {
}
let elem2 = Element::from(pubsub);
assert!(elem1.compare_to(&elem2));
assert_eq!(elem1, elem2);
let elem: Element =
"<pubsub xmlns='http://jabber.org/protocol/pubsub'><create node='coucou'/></pubsub>"
@ -553,7 +552,7 @@ mod tests {
}
let elem2 = Element::from(pubsub);
assert!(elem1.compare_to(&elem2));
assert_eq!(elem1, elem2);
}
#[test]
@ -573,7 +572,7 @@ mod tests {
}
let elem2 = Element::from(pubsub);
assert!(elem1.compare_to(&elem2));
assert_eq!(elem1, elem2);
}
#[test]
@ -596,7 +595,7 @@ mod tests {
}
let elem2 = Element::from(pubsub);
assert!(elem1.compare_to(&elem2));
assert_eq!(elem1, elem2);
}
#[test]
@ -616,7 +615,7 @@ mod tests {
}
let elem2 = Element::from(pubsub);
assert!(elem1.compare_to(&elem2));
assert_eq!(elem1, elem2);
}
#[test]