aboutsummaryrefslogtreecommitdiff
path: root/src/test_utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test_utils.rs')
-rw-r--r--src/test_utils.rs44
1 files changed, 44 insertions, 0 deletions
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<De: DeserializeTagged>(
+ &mut self,
+ tag_name: &str,
+ ignore_end: IgnoreEnd,
+ ) -> Result<De, Error<De::Error>>;
+
+ fn de_tag_with<TOutput, Err, Func>(
+ &mut self,
+ tag_name: &str,
+ ignore_end: IgnoreEnd,
+ deserialize: Func,
+ ) -> Result<TOutput, Error<Err>>
+ where
+ TOutput: MaybeStatic,
+ Err: std::error::Error + Send + Sync + 'static,
+ Func: FnOnce(&TagStart, &mut MockDeserializer) -> Result<TOutput, Err> + MaybeStatic;
+
+ fn de_tag_list<De, TagName>(
+ &mut self,
+ tag_name: Option<TagName>
+ ) -> Result<Vec<De>, Error<De::Error>>
+ where
+ De: DeserializeTagged,
+ TagName: AsRef<str> + MaybeStatic;
+
+ fn de_text(&mut self) -> Result<String, Error<Infallible>>;
+
+ fn skip_to_tag_start(&mut self, tag_name: &str) -> Result<(), Error<Infallible>>;
+
+ fn skip_to_tag_end(&mut self, tag_name: &str) -> Result<(), Error<Infallible>>;
+ }
+}