Skip to content

Commit

Permalink
Add assert_xml_format
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Sep 5, 2023
1 parent ce15ccc commit 151b0f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/game/move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ impl From<Move> for Element {
todo!()
}
}

#[cfg(test)]
mod tests {
use crate::{util::assert_xml_format, game::Move};

#[test]
fn test_to_xml() {
assert_xml_format!(Move, "");
}
}
16 changes: 16 additions & 0 deletions src/util/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,20 @@ macro_rules! assert_xml_parse {
};
}

macro_rules! assert_xml_format {
($actual:expr, $xml:expr) => {
{
use ::std::str::FromStr;

use crate::util::Element;

assert_eq!(
Element::try_from($actual).unwrap(),
Element::from_str($xml).unwrap()
)
}
};
}

pub(crate) use assert_xml_parse;
pub(crate) use assert_xml_format;

0 comments on commit 151b0f8

Please sign in to comment.