From ad142e9e749adf64642168c0d221b0cf47f149c7 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 14 May 2023 19:51:17 +0200 Subject: refactor: use xml-stinks --- src/test_utils.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test_utils.rs (limited to 'src/test_utils.rs') diff --git a/src/test_utils.rs b/src/test_utils.rs new file mode 100644 index 0000000..0f80cb7 --- /dev/null +++ b/src/test_utils.rs @@ -0,0 +1,44 @@ +use std::convert::Infallible; + +use mockall::mock; +use xml_stinks::deserializer::{Deserializer, Error, IgnoreEnd, MaybeStatic}; +use xml_stinks::tagged::TagStart; +use xml_stinks::DeserializeTagged; + +mock! { + pub Deserializer {} + + impl Deserializer for Deserializer + { + fn de_tag( + &mut self, + tag_name: &str, + ignore_end: IgnoreEnd, + ) -> Result>; + + fn de_tag_with( + &mut self, + tag_name: &str, + ignore_end: IgnoreEnd, + deserialize: Func, + ) -> Result> + where + TOutput: MaybeStatic, + Err: std::error::Error + Send + Sync + 'static, + Func: FnOnce(&TagStart, &mut MockDeserializer) -> Result + MaybeStatic; + + fn de_tag_list( + &mut self, + tag_name: Option + ) -> Result, Error> + where + De: DeserializeTagged, + TagName: AsRef + MaybeStatic; + + fn de_text(&mut self) -> Result>; + + fn skip_to_tag_start(&mut self, tag_name: &str) -> Result<(), Error>; + + fn skip_to_tag_end(&mut self, tag_name: &str) -> Result<(), Error>; + } +} -- cgit v1.2.3-18-g5258